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/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); 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..0fb35d4 100755 --- a/tests/Validate/Rule/EmailRuleTest.php +++ b/tests/Validate/Rule/EmailRuleTest.php @@ -4,14 +4,13 @@ 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 +19,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];