From 3bbb354481a9de980bd4a70125ed91ca0c648d0e Mon Sep 17 00:00:00 2001 From: Simon R Jones Date: Tue, 23 Jun 2026 14:45:47 +0100 Subject: [PATCH 1/3] fix: Fix some minor deprecations --- src/Cache/DataHistory.php | 2 +- src/Exception/GraphQLException.php | 2 +- src/Exception/HttpException.php | 2 +- src/Http/GraphQL.php | 1 + src/Http/Http.php | 3 +-- src/Traits/CheckPermissionsTrait.php | 2 +- src/Traits/FlagsTrait.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Cache/DataHistory.php b/src/Cache/DataHistory.php index b0809c5..e4fc07f 100644 --- a/src/Cache/DataHistory.php +++ b/src/Cache/DataHistory.php @@ -106,7 +106,7 @@ public function hasItem($key): bool * @return mixed|array|null Return last history item or null on failure * @throws CacheException */ - public function getLastItem($key, string $field = null) + public function getLastItem($key, ?string $field = null) { $history = $this->getAll($key); $item = array_pop($history); diff --git a/src/Exception/GraphQLException.php b/src/Exception/GraphQLException.php index 31e7f27..da321f6 100755 --- a/src/Exception/GraphQLException.php +++ b/src/Exception/GraphQLException.php @@ -25,7 +25,7 @@ class GraphQLException extends HttpException * @param ?string $lastQuery * @param \Exception|null $previous */ - public function __construct(string $message, string $uri, string $method, array $options, ResponseInterface $response, array $errorData = [], array $responseData = [], \Exception $previous = null, ?string $lastQuery = null) + public function __construct(string $message, string $uri, string $method, array $options, ResponseInterface $response, array $errorData = [], array $responseData = [], ?\Exception $previous = null, ?string $lastQuery = null) { if (null !== $lastQuery) { $this->setLastQuery($lastQuery); diff --git a/src/Exception/HttpException.php b/src/Exception/HttpException.php index 3343c7f..3124d7a 100755 --- a/src/Exception/HttpException.php +++ b/src/Exception/HttpException.php @@ -27,7 +27,7 @@ class HttpException extends \Exception * @param array $responseData * @param \Exception|null $previous */ - public function __construct(string $message, private string $requestUri, private string $requestMethod, private array $requestOptions, private ResponseInterface $response, private array $responseErrorData = [], private array $responseData = [], \Exception $previous = null) + public function __construct(string $message, private string $requestUri, private string $requestMethod, private array $requestOptions, private ResponseInterface $response, private array $responseErrorData = [], private array $responseData = [], ?\Exception $previous = null) { // Append error data if set $message .= $this->getMessageFromErrorData($this->responseErrorData); diff --git a/src/Http/GraphQL.php b/src/Http/GraphQL.php index 26a2479..f641fc4 100644 --- a/src/Http/GraphQL.php +++ b/src/Http/GraphQL.php @@ -56,6 +56,7 @@ public function getDefaultDecoder(): DecoderInterface */ public function getRequestIdentifier(string $uri, array $context = []): string { + // The "Strata\Data\Http\GraphQL::getRequestIdentifier()" method will require a new "$method" argument in the next major version of its parent class "Strata\Data\Http\Http", not defining it is deprecated. if (!empty($context['query'])) { $uri .= '?' . http_build_query($context['query']); } diff --git a/src/Http/Http.php b/src/Http/Http.php index e2d725f..fdaef7b 100644 --- a/src/Http/Http.php +++ b/src/Http/Http.php @@ -398,7 +398,6 @@ public function throwExceptionOnFailedRequest(ResponseInterface $response): void * * Hash generated from: URI + GET params * - * @param $method * @param $uri * @param array $context * @return string Unique identifier for this request @@ -720,7 +719,7 @@ public function get(string $uri, array $queryParams = [], array $options = []): * @throws HttpException * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface */ - public function post(string $uri, string|array $postData = null, array $options = []): CacheableResponse + public function post(string $uri, string|array|null $postData = null, array $options = []): CacheableResponse { if (is_array($postData)) { if (isset($options['body']) && is_array($options['body'])) { diff --git a/src/Traits/CheckPermissionsTrait.php b/src/Traits/CheckPermissionsTrait.php index 9c5e354..e11dbc2 100644 --- a/src/Traits/CheckPermissionsTrait.php +++ b/src/Traits/CheckPermissionsTrait.php @@ -22,7 +22,7 @@ trait CheckPermissionsTrait * Set permissions for accessing the API, defaults to read-only * @param Permissions $permissions */ - public function setPermissions(Permissions $permissions = null) + public function setPermissions(?Permissions $permissions = null) { if ($permissions instanceof Permissions) { $this->permissions = $permissions; diff --git a/src/Traits/FlagsTrait.php b/src/Traits/FlagsTrait.php index 2aaf893..51bd36b 100644 --- a/src/Traits/FlagsTrait.php +++ b/src/Traits/FlagsTrait.php @@ -33,7 +33,7 @@ trait FlagsTrait { protected $flags; - public function __construct(int $options = null) + public function __construct(?int $options = null) { if ($options !== null) { $this->setFlags($options); From 45be82f12eeacfc90ba616c5fe40e2e59f33e211 Mon Sep 17 00:00:00 2001 From: Simon R Jones Date: Tue, 23 Jun 2026 14:51:46 +0100 Subject: [PATCH 2/3] Remove comment, update phpunit to attributes --- src/Http/GraphQL.php | 1 - tests/Decode/DecoderFactoryTest.php | 5 ++--- tests/Validate/Rule/EmailRuleTest.php | 10 ++++------ tests/Validate/Rule/NumberRuleTest.php | 9 +++------ tests/Validate/Rule/RequiredRuleTest.php | 9 +++------ 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/Http/GraphQL.php b/src/Http/GraphQL.php index f641fc4..26a2479 100644 --- a/src/Http/GraphQL.php +++ b/src/Http/GraphQL.php @@ -56,7 +56,6 @@ public function getDefaultDecoder(): DecoderInterface */ public function getRequestIdentifier(string $uri, array $context = []): string { - // The "Strata\Data\Http\GraphQL::getRequestIdentifier()" method will require a new "$method" argument in the next major version of its parent class "Strata\Data\Http\Http", not defining it is deprecated. if (!empty($context['query'])) { $uri .= '?' . http_build_query($context['query']); } diff --git a/tests/Decode/DecoderFactoryTest.php b/tests/Decode/DecoderFactoryTest.php index 4611948..f79e916 100644 --- a/tests/Decode/DecoderFactoryTest.php +++ b/tests/Decode/DecoderFactoryTest.php @@ -4,6 +4,7 @@ namespace Strata\Data\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Strata\Data\Decode\DecoderFactory; use Symfony\Component\HttpClient\MockHttpClient; @@ -25,9 +26,7 @@ public function testFilenameFactory() $this->assertNull(DecoderFactory::fromFilename('https://example.com/feed')); } - /** - * @dataProvider responseDataProvider - */ + #[DataProvider('responseDataProvider')] public function testResponseFactory($contentType, $expectedClass) { $mockResponse = new MockResponse('', ['response_headers' => ['Content-type' => $contentType]]); diff --git a/tests/Validate/Rule/EmailRuleTest.php b/tests/Validate/Rule/EmailRuleTest.php index efd5e3a..3035ae4 100755 --- a/tests/Validate/Rule/EmailRuleTest.php +++ b/tests/Validate/Rule/EmailRuleTest.php @@ -4,14 +4,14 @@ namespace Strata\Data\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Strata\Data\Validate\Rule\EmailRule; class EmailRuleTest extends TestCase { - /** - * @dataProvider validDataProvider - */ + + #[DataProvider('validDataProvider')] public function testValid(string $email) { $validator = new EmailRule('[email]'); @@ -20,9 +20,7 @@ public function testValid(string $email) $this->assertTrue($validator->validate($data)); } - /** - * @dataProvider invalidDataProvider - */ + #[DataProvider('invalidDataProvider')] public function testInvalid(string $email) { $validator = new EmailRule('[email]'); diff --git a/tests/Validate/Rule/NumberRuleTest.php b/tests/Validate/Rule/NumberRuleTest.php index d6a1c57..6ee7ff5 100755 --- a/tests/Validate/Rule/NumberRuleTest.php +++ b/tests/Validate/Rule/NumberRuleTest.php @@ -4,14 +4,13 @@ namespace Strata\Data\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Strata\Data\Validate\Rule\NumberRule; class NumberRuleTest extends TestCase { - /** - * @dataProvider validDataProvider - */ + #[DataProvider('validDataProvider')] public function testValid($number) { $validator = new NumberRule('[data]'); @@ -20,9 +19,7 @@ public function testValid($number) $this->assertTrue($validator->validate($data)); } - /** - * @dataProvider invalidDataProvider - */ + #[DataProvider('invalidDataProvider')] public function testInvalid($number) { $validator = new NumberRule('[data]'); diff --git a/tests/Validate/Rule/RequiredRuleTest.php b/tests/Validate/Rule/RequiredRuleTest.php index c3b4c15..1ab0a7f 100755 --- a/tests/Validate/Rule/RequiredRuleTest.php +++ b/tests/Validate/Rule/RequiredRuleTest.php @@ -4,14 +4,13 @@ namespace Strata\Data\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Strata\Data\Validate\Rule\RequiredRule; class RequiredRuleTest extends TestCase { - /** - * @dataProvider validDataProvider - */ + #[DataProvider('validDataProvider')] public function testValid(string $propertyPath) { $data = ['email' => 'hello@studio24.net', 'title' => '', 'number' => 0, 'things' => [], 'null' => null]; @@ -20,9 +19,7 @@ public function testValid(string $propertyPath) $this->assertTrue($validator->validate($data)); } - /** - * @dataProvider invalidDataProvider - */ + #[DataProvider('invalidDataProvider')] public function testInvalid(string $propertyPath) { $data = ['email' => 'hello@studio24.net', 'title' => '', 'number' => 0, 'things' => [], 'null' => null]; From a33dca25d4e4f85ee58d538b57599781af4befaa Mon Sep 17 00:00:00 2001 From: Simon R Jones Date: Tue, 23 Jun 2026 14:53:52 +0100 Subject: [PATCH 3/3] Coding standard --- tests/Validate/Rule/EmailRuleTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Validate/Rule/EmailRuleTest.php b/tests/Validate/Rule/EmailRuleTest.php index 3035ae4..0fb35d4 100755 --- a/tests/Validate/Rule/EmailRuleTest.php +++ b/tests/Validate/Rule/EmailRuleTest.php @@ -10,7 +10,6 @@ class EmailRuleTest extends TestCase { - #[DataProvider('validDataProvider')] public function testValid(string $email) {