From 8cba1963f2395ca2fb606c157f64694b7476197e Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 28 Nov 2023 14:39:50 +0100 Subject: [PATCH 1/7] Remove support for PHP 7.4 and PHP 8.0 --- .github/workflows/unit-tests.yml | 2 +- composer.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 01609e7..e070a53 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: operating-system: ['ubuntu-latest'] - php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + php: ['8.1', '8.2', '8.3', '8.4'] steps: - name: Checkout diff --git a/composer.json b/composer.json index f01bf94..7f52884 100644 --- a/composer.json +++ b/composer.json @@ -13,13 +13,13 @@ } ], "require": { - "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0" + "php": "^~8.1.0 || ~8.2.0 || ~8.3.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.35", + "friendsofphp/php-cs-fixer": "^3.40", "phpstan/phpstan": "^1.10", "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9 || ^10" + "phpunit/phpunit": "^10.4" }, "autoload": { "psr-4": { From 5554b2efc2686da69b3cab432c33d4bfac4ac31c Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 28 Nov 2023 14:41:48 +0100 Subject: [PATCH 2/7] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7547f7c..d853df2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased](https://github.com/Art4/json-api-client/compare/1.2.0...v1.x) +### Changed + +- Dropped support for PHP 7.4 and PHP 8.0 + ## [1.2.0 - 2023-11-28](https://github.com/Art4/json-api-client/compare/1.1.0...1.2.0) ### Added From b1f4b0348ce7363f9043df647c21e6342495a947 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 28 Nov 2023 14:43:21 +0100 Subject: [PATCH 3/7] Fix composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7f52884..58a139b 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require": { - "php": "^~8.1.0 || ~8.2.0 || ~8.3.0" + "php": "~8.1.0 || ~8.2.0 || ~8.3.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.40", From 9a02a23eb67220641885a3fc2e29f35de6cd53a1 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 28 Nov 2023 14:54:54 +0100 Subject: [PATCH 4/7] Update php-cs-fixer rulesets --- .php-cs-fixer.dist.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 6de33d4..5e6d7a5 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -13,8 +13,8 @@ ->setRules([ '@PER-CS2.0' => true, '@PER-CS2.0:risky' => true, - '@PHP74Migration' => true, - '@PHP74Migration:risky' => true, + '@PHP81Migration' => true, + '@PHP80Migration:risky' => true, '@PHPUnit84Migration:risky' => true, 'no_alias_functions' => true, ]) From 0e3919de02972f197cf15595774d86d3a838d072 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 28 Nov 2023 16:05:33 +0100 Subject: [PATCH 5/7] Add mixed as parameter type, add plan to change return types to mixed in v2 --- CHANGELOG.md | 5 +++++ src/Accessable.php | 8 +++----- src/Element.php | 2 +- src/Helper/AbstractElement.php | 10 +++------- src/Manager.php | 4 ++-- tests/Unit/Helper/AccessableTraitTest.php | 8 ++------ 6 files changed, 16 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d853df2..b22d1ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Dropped support for PHP 7.4 and PHP 8.0 +### Deprecated + +- `\Art4\Accessable::get()` will add `mixed` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors. +- `\Art4\Manager::getParam()` will add `mixed` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors. + ## [1.2.0 - 2023-11-28](https://github.com/Art4/json-api-client/compare/1.1.0...1.2.0) ### Added diff --git a/src/Accessable.php b/src/Accessable.php index 11f3c93..90798ce 100644 --- a/src/Accessable.php +++ b/src/Accessable.php @@ -18,22 +18,20 @@ interface Accessable /** * Get a value by a key * - * @param mixed $key The key + * @return-type-will-change mixed `\Art4\JsonApiClient\Accessable::get()` will add `mixed` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors. * * @return mixed */ - public function get($key); + public function get(mixed $key)/*: mixed */; /** * Check if a value exists * * @return-type-will-change bool `\Art4\JsonApiClient\Accessable::has()` will add `bool` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors. * - * @param mixed $key The key - * * @return bool */ - public function has($key)/*: bool */; + public function has(mixed $key)/*: bool */; /** * Returns the keys of all setted values diff --git a/src/Element.php b/src/Element.php index 2951a2e..0bc71ba 100644 --- a/src/Element.php +++ b/src/Element.php @@ -18,5 +18,5 @@ interface Element * * @param mixed $data The data for this Element */ - public function __construct($data, Manager $manager, Accessable $parent); + public function __construct(mixed $data, Manager $manager, Accessable $parent); } diff --git a/src/Helper/AbstractElement.php b/src/Helper/AbstractElement.php index f15a62c..016b25e 100644 --- a/src/Helper/AbstractElement.php +++ b/src/Helper/AbstractElement.php @@ -30,7 +30,7 @@ abstract class AbstractElement implements Accessable, Element * * @param mixed $data The data for this Element */ - public function __construct($data, Manager $manager, Accessable $parent) + public function __construct(mixed $data, Manager $manager, Accessable $parent) { $this->manager = $manager; $this->parent = $parent; @@ -56,10 +56,8 @@ protected function getParent(): Accessable /** * Create an element - * - * @param mixed $data */ - protected function create(string $name, $data): Accessable + protected function create(string $name, mixed $data): Accessable { return $this->getManager()->getFactory()->make( $name, @@ -69,8 +67,6 @@ protected function create(string $name, $data): Accessable /** * Parse the data - * - * @param mixed $data */ - abstract protected function parse($data): void; + abstract protected function parse(mixed $data): void; } diff --git a/src/Manager.php b/src/Manager.php index 0610da0..4f38c72 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -39,9 +39,9 @@ public function getFactory()/*: Factory */; /** * Get a param by key * - * @param mixed $default + * @return-type-will-change mixed `\Art4\JsonApiClient\Manager::getParam()` will add `mixed` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors. * * @return mixed */ - public function getParam(string $key, $default); + public function getParam(string $key, mixed $default)/*: mixed*/; } diff --git a/tests/Unit/Helper/AccessableTraitTest.php b/tests/Unit/Helper/AccessableTraitTest.php index f52ef81..583f436 100644 --- a/tests/Unit/Helper/AccessableTraitTest.php +++ b/tests/Unit/Helper/AccessableTraitTest.php @@ -19,10 +19,8 @@ class AccessableTraitTest extends TestCase /** * @dataProvider jsonValuesProviderWithoutStringAndInt - * - * @param mixed $key */ - public function testHasWithInvalidKeyTypeTriggersDeprecationError($key): void + public function testHasWithInvalidKeyTypeTriggersDeprecationError(mixed $key): void { $resource = new AccessableTraitMock(); @@ -45,10 +43,8 @@ function ($errno, $errstr) use ($key): bool { /** * @dataProvider jsonValuesProviderWithoutStringAndInt - * - * @param mixed $key */ - public function testGetWithInvalidKeyTypeTriggersDeprecationError($key): void + public function testGetWithInvalidKeyTypeTriggersDeprecationError(mixed $key): void { $resource = new AccessableTraitMock(); From 8a18b4cab63d3f9433ad3e29c8c30c1251deb0f7 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 28 Nov 2023 16:27:35 +0100 Subject: [PATCH 6/7] Add mixed as parameter type and return type --- src/Helper/AccessableTrait.php | 12 ++----- src/Input/StringInputTrait.php | 4 +-- src/Manager/ErrorAbortManager.php | 6 +--- src/Serializer/ArraySerializer.php | 6 +--- src/V1/Attributes.php | 8 ++--- src/V1/Document.php | 8 ++--- src/V1/DocumentLink.php | 8 ++--- src/V1/Error.php | 8 ++--- src/V1/ErrorCollection.php | 8 ++--- src/V1/ErrorLink.php | 8 ++--- src/V1/ErrorSource.php | 8 ++--- src/V1/Jsonapi.php | 8 ++--- src/V1/Link.php | 12 ++----- src/V1/Meta.php | 8 ++--- src/V1/Relationship.php | 8 ++--- src/V1/RelationshipCollection.php | 8 ++--- src/V1/RelationshipLink.php | 8 ++--- src/V1/ResourceCollection.php | 8 ++--- src/V1/ResourceIdentifier.php | 8 ++--- src/V1/ResourceIdentifierCollection.php | 8 ++--- src/V1/ResourceItem.php | 8 ++--- src/V1/ResourceItemLink.php | 8 ++--- src/V1/ResourceNull.php | 8 ++--- tests/Fixtures/HelperTrait.php | 4 +-- tests/Unit/Input/RequestStringInputTest.php | 4 +-- tests/Unit/Input/ResponseStringInputTest.php | 4 +-- tests/Unit/V1/AttributesTest.php | 4 +-- tests/Unit/V1/DocumentLinkTest.php | 35 +++++-------------- tests/Unit/V1/DocumentTest.php | 8 ++--- tests/Unit/V1/ErrorCollectionTest.php | 4 +-- tests/Unit/V1/ErrorLinkTest.php | 12 ++----- tests/Unit/V1/ErrorSourceTest.php | 12 ++----- tests/Unit/V1/ErrorTest.php | 24 ++++--------- tests/Unit/V1/JsonapiTest.php | 8 ++--- tests/Unit/V1/LinkTest.php | 8 ++--- tests/Unit/V1/MetaTest.php | 4 +-- tests/Unit/V1/RelationshipCollectionTest.php | 4 +-- tests/Unit/V1/RelationshipLinkTest.php | 32 +++++------------ tests/Unit/V1/RelationshipTest.php | 4 +-- tests/Unit/V1/ResourceCollectionTest.php | 8 ++--- .../V1/ResourceIdentifierCollectionTest.php | 4 +-- tests/Unit/V1/ResourceIdentifierTest.php | 12 ++----- tests/Unit/V1/ResourceItemLinkTest.php | 8 ++--- tests/Unit/V1/ResourceItemTest.php | 12 ++----- tests/Unit/V1/ResourceNullTest.php | 4 +-- 45 files changed, 100 insertions(+), 303 deletions(-) diff --git a/src/Helper/AccessableTrait.php b/src/Helper/AccessableTrait.php index 6ab503d..6898173 100644 --- a/src/Helper/AccessableTrait.php +++ b/src/Helper/AccessableTrait.php @@ -25,10 +25,8 @@ trait AccessableTrait /** * Set a value - * - * @param mixed $value The Value */ - final protected function set(string $key, $value): void + final protected function set(string $key, mixed $value): void { // Allow non-associative array for collections if ($key === '') { @@ -93,10 +91,8 @@ final public function has($key): bool * Get a value by a key * * @param int|string|AccessKey $key The key - * - * @return mixed */ - public function get($key) + public function get($key): mixed { if (!is_int($key) && !is_string($key) && (!is_object($key) || !$key instanceof AccessKey)) { trigger_error(sprintf( @@ -131,10 +127,8 @@ public function get($key) * Get a value by the key * * @throws AccessException - * - * @return mixed The value */ - private function getValue(string $key) + private function getValue(string $key): mixed { if (array_key_exists($key, $this->data)) { return $this->data[$key]; diff --git a/src/Input/StringInputTrait.php b/src/Input/StringInputTrait.php index f04042c..f620b3e 100644 --- a/src/Input/StringInputTrait.php +++ b/src/Input/StringInputTrait.php @@ -41,10 +41,8 @@ final public function prepareString($string): string * Decodes a json string * * @throws InputException if something went wrong with the input - * - * @return mixed */ - final protected function decodeJson(string $jsonString) + final protected function decodeJson(string $jsonString): mixed { $jsonErrors = [ \JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded', diff --git a/src/Manager/ErrorAbortManager.php b/src/Manager/ErrorAbortManager.php index db8567c..5e937c5 100644 --- a/src/Manager/ErrorAbortManager.php +++ b/src/Manager/ErrorAbortManager.php @@ -78,12 +78,8 @@ public function getFactory(): Factory /** * Get a param by key - * - * @param mixed $default - * - * @return mixed */ - public function getParam(string $key, $default) + public function getParam(string $key, mixed $default): mixed { if (array_key_exists($key, $this->config)) { return $this->config[$key]; diff --git a/src/Serializer/ArraySerializer.php b/src/Serializer/ArraySerializer.php index 14efd00..0744999 100644 --- a/src/Serializer/ArraySerializer.php +++ b/src/Serializer/ArraySerializer.php @@ -62,12 +62,8 @@ public function serialize(Accessable $data): ?array /** * Transforms objects to arrays - * - * @param mixed $val - * - * @return mixed */ - private function objectTransform($val) + private function objectTransform(mixed $val): mixed { if (!is_object($val)) { return $val; diff --git a/src/V1/Attributes.php b/src/V1/Attributes.php index b9ae944..f831f03 100644 --- a/src/V1/Attributes.php +++ b/src/V1/Attributes.php @@ -23,11 +23,9 @@ final class Attributes extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('Attributes has to be an object, "' . gettype($object) . '" given.'); @@ -52,10 +50,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/Document.php b/src/V1/Document.php index 1717509..531b59f 100644 --- a/src/V1/Document.php +++ b/src/V1/Document.php @@ -24,11 +24,9 @@ final class Document extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('Document has to be an object, "' . gettype($object) . '" given.'); @@ -75,10 +73,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/DocumentLink.php b/src/V1/DocumentLink.php index 569c4e5..0d1daab 100644 --- a/src/V1/DocumentLink.php +++ b/src/V1/DocumentLink.php @@ -28,11 +28,9 @@ final class DocumentLink extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException( @@ -105,10 +103,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/Error.php b/src/V1/Error.php index 250f737..cab0cd0 100644 --- a/src/V1/Error.php +++ b/src/V1/Error.php @@ -23,11 +23,9 @@ final class Error extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException( @@ -107,10 +105,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/ErrorCollection.php b/src/V1/ErrorCollection.php index 39e4766..eccad3f 100644 --- a/src/V1/ErrorCollection.php +++ b/src/V1/ErrorCollection.php @@ -23,11 +23,9 @@ final class ErrorCollection extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_array($object)) { throw new ValidationException('Errors for a collection has to be in an array, "' . gettype($object) . '" given.'); @@ -46,10 +44,8 @@ protected function parse($object): void * Get a value by the key of this document * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/ErrorLink.php b/src/V1/ErrorLink.php index b4f8d2f..fb1ae16 100644 --- a/src/V1/ErrorLink.php +++ b/src/V1/ErrorLink.php @@ -27,11 +27,9 @@ final class ErrorLink extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('Link has to be an object, "' . gettype($object) . '" given.'); @@ -65,10 +63,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/ErrorSource.php b/src/V1/ErrorSource.php index c9730c3..30bb75f 100644 --- a/src/V1/ErrorSource.php +++ b/src/V1/ErrorSource.php @@ -23,11 +23,9 @@ final class ErrorSource extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('ErrorSource has to be an object, "' . gettype($object) . '" given.'); @@ -54,10 +52,8 @@ protected function parse($object): void * Get a value by the key of this document * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/Jsonapi.php b/src/V1/Jsonapi.php index 3e0cf53..7c31c96 100644 --- a/src/V1/Jsonapi.php +++ b/src/V1/Jsonapi.php @@ -23,11 +23,9 @@ final class Jsonapi extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('Jsonapi has to be an object, "' . gettype($object) . '" given.'); @@ -50,10 +48,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/Link.php b/src/V1/Link.php index 6a8088e..41bd8eb 100644 --- a/src/V1/Link.php +++ b/src/V1/Link.php @@ -23,11 +23,9 @@ final class Link extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('Link has to be an object or string, "' . gettype($object) . '" given.'); @@ -46,10 +44,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); @@ -60,10 +56,8 @@ public function get($key) /** * Set a link - * - * @param mixed $link The Link */ - private function setAsLink(string $name, $link): void + private function setAsLink(string $name, mixed $link): void { if ($name === 'meta') { $this->set($name, $this->create('Meta', $link)); diff --git a/src/V1/Meta.php b/src/V1/Meta.php index 30bce64..ed68e0a 100644 --- a/src/V1/Meta.php +++ b/src/V1/Meta.php @@ -23,11 +23,9 @@ final class Meta extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('Meta has to be an object, "' . gettype($object) . '" given.'); @@ -48,10 +46,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/Relationship.php b/src/V1/Relationship.php index b85017d..67444ee 100644 --- a/src/V1/Relationship.php +++ b/src/V1/Relationship.php @@ -23,11 +23,9 @@ final class Relationship extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('Relationship has to be an object, "' . gettype($object) . '" given.'); @@ -61,10 +59,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/RelationshipCollection.php b/src/V1/RelationshipCollection.php index e14a6de..8e47d44 100644 --- a/src/V1/RelationshipCollection.php +++ b/src/V1/RelationshipCollection.php @@ -23,11 +23,9 @@ final class RelationshipCollection extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('Relationships has to be an object, "' . gettype($object) . '" given.'); @@ -56,10 +54,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/RelationshipLink.php b/src/V1/RelationshipLink.php index 602b13c..e520267 100644 --- a/src/V1/RelationshipLink.php +++ b/src/V1/RelationshipLink.php @@ -32,11 +32,9 @@ final class RelationshipLink extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('RelationshipLink has to be an object, "' . gettype($object) . '" given.'); @@ -107,10 +105,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/ResourceCollection.php b/src/V1/ResourceCollection.php index 852ff5d..95a71b5 100644 --- a/src/V1/ResourceCollection.php +++ b/src/V1/ResourceCollection.php @@ -24,11 +24,9 @@ final class ResourceCollection extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_array($object)) { throw new ValidationException('Resources for a collection has to be in an array, "' . gettype($object) . '" given.'); @@ -49,10 +47,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/ResourceIdentifier.php b/src/V1/ResourceIdentifier.php index 6f6452c..9950667 100644 --- a/src/V1/ResourceIdentifier.php +++ b/src/V1/ResourceIdentifier.php @@ -23,11 +23,9 @@ final class ResourceIdentifier extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('Resource has to be an object, "' . gettype($object) . '" given.'); @@ -61,10 +59,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/ResourceIdentifierCollection.php b/src/V1/ResourceIdentifierCollection.php index 7c2af51..7b546cd 100644 --- a/src/V1/ResourceIdentifierCollection.php +++ b/src/V1/ResourceIdentifierCollection.php @@ -23,11 +23,9 @@ final class ResourceIdentifierCollection extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_array($object)) { throw new ValidationException('Resources for a collection has to be in an array, "' . gettype($object) . '" given.'); @@ -44,10 +42,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/ResourceItem.php b/src/V1/ResourceItem.php index 913f701..570a210 100644 --- a/src/V1/ResourceItem.php +++ b/src/V1/ResourceItem.php @@ -23,11 +23,9 @@ final class ResourceItem extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('Resource has to be an object, "' . gettype($object) . '" given.'); @@ -79,10 +77,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/ResourceItemLink.php b/src/V1/ResourceItemLink.php index 73964d8..c22a8a8 100644 --- a/src/V1/ResourceItemLink.php +++ b/src/V1/ResourceItemLink.php @@ -23,11 +23,9 @@ final class ResourceItemLink extends AbstractElement /** * Parses the data for this element * - * @param mixed $object The data - * * @throws ValidationException */ - protected function parse($object): void + protected function parse(mixed $object): void { if (!is_object($object)) { throw new ValidationException('ItemLink has to be an object, "' . gettype($object) . '" given.'); @@ -42,10 +40,8 @@ protected function parse($object): void * Get a value by the key of this object * * @param int|string|AccessKey $key The key of the value - * - * @return mixed The value */ - public function get($key) + public function get($key): mixed { try { return parent::get($key); diff --git a/src/V1/ResourceNull.php b/src/V1/ResourceNull.php index 93c71ab..a5f97f5 100644 --- a/src/V1/ResourceNull.php +++ b/src/V1/ResourceNull.php @@ -20,13 +20,11 @@ final class ResourceNull implements Accessable, Element { /** - * Constructor + * Sets the manager and parent * - * @param mixed $data The data for this Element - * @param \Art4\JsonApiClient\Manager $manager The manager - * @param \Art4\JsonApiClient\Accessable $parent The parent + * @param mixed $data The data for this Element */ - public function __construct($data, Manager $manager, Accessable $parent) {} + public function __construct(mixed $data, Manager $manager, Accessable $parent) {} /** * Check if a value exists in this resource diff --git a/tests/Fixtures/HelperTrait.php b/tests/Fixtures/HelperTrait.php index aae051e..8da7143 100644 --- a/tests/Fixtures/HelperTrait.php +++ b/tests/Fixtures/HelperTrait.php @@ -176,10 +176,8 @@ public function setUpManagerMock(): void /** * returns a json string from a file - * - * @param mixed $filename */ - protected function getJsonString($filename): string + protected function getJsonString(mixed $filename): string { return strval(file_get_contents(__DIR__ . '/../files/' . $filename)); } diff --git a/tests/Unit/Input/RequestStringInputTest.php b/tests/Unit/Input/RequestStringInputTest.php index f9d49e7..665d562 100644 --- a/tests/Unit/Input/RequestStringInputTest.php +++ b/tests/Unit/Input/RequestStringInputTest.php @@ -26,10 +26,8 @@ public function testGetAsObjectFromStringReturnsObject(): void /** * @dataProvider jsonValuesProviderWithoutString - * - * @param mixed $input */ - public function testCreateWithoutStringThrowsException($input): void + public function testCreateWithoutStringThrowsException(mixed $input): void { $this->expectException(InputException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/Input/ResponseStringInputTest.php b/tests/Unit/Input/ResponseStringInputTest.php index 8b6f24c..d7e0755 100644 --- a/tests/Unit/Input/ResponseStringInputTest.php +++ b/tests/Unit/Input/ResponseStringInputTest.php @@ -26,10 +26,8 @@ public function testGetAsObjectFromStringReturnsObject(): void /** * @dataProvider jsonValuesProviderWithoutString - * - * @param mixed $input */ - public function testCreateWithoutStringThrowsException($input): void + public function testCreateWithoutStringThrowsException(mixed $input): void { $this->expectException(InputException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/V1/AttributesTest.php b/tests/Unit/V1/AttributesTest.php index 865197c..c451bbe 100644 --- a/tests/Unit/V1/AttributesTest.php +++ b/tests/Unit/V1/AttributesTest.php @@ -82,10 +82,8 @@ public function testCreateWithObject(): void /** * @dataProvider jsonValuesProviderWithoutObject - * - * @param mixed $input */ - public function testCreateWithDataProvider($input): void + public function testCreateWithDataProvider(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/V1/DocumentLinkTest.php b/tests/Unit/V1/DocumentLinkTest.php index 6227032..90bd2d0 100644 --- a/tests/Unit/V1/DocumentLinkTest.php +++ b/tests/Unit/V1/DocumentLinkTest.php @@ -92,10 +92,8 @@ public function testOnlySelfRelatedPaginationPropertiesExists(): void * @dataProvider jsonValuesProviderWithoutObject * * links: a links object related to the primary data. - * - * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input): void + public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -109,10 +107,8 @@ public function testCreateWithoutObjectThrowsException($input): void * @dataProvider jsonValuesProviderWithoutObjectAndString * * test create without object or string attribute throws exception - * - * @param mixed $input */ - public function testCreateWithoutObjectOrStringAttributeThrowsException($input): void + public function testCreateWithoutObjectOrStringAttributeThrowsException(mixed $input): void { $object = new \stdClass(); $object->self = 'http://example.org/self'; @@ -130,10 +126,8 @@ public function testCreateWithoutObjectOrStringAttributeThrowsException($input): * @dataProvider jsonValuesProviderWithoutObjectAndString * * self: the link that generated the current response document. - * - * @param mixed $input */ - public function testSelfMustBeAStringOrObject($input): void + public function testSelfMustBeAStringOrObject(mixed $input): void { $object = new \stdClass(); $object->self = $input; @@ -162,10 +156,8 @@ public function testSelfMustBeAStringOrObject($input): void * } * } * } - * - * @param mixed $input */ - public function testRelatedMustBeAStringOrObject($input): void + public function testRelatedMustBeAStringOrObject(mixed $input): void { $object = new \stdClass(); $object->related = $input; @@ -182,10 +174,8 @@ public function testRelatedMustBeAStringOrObject($input): void * @dataProvider jsonValuesProvider * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. - * - * @param mixed $input */ - public function testFirstCanBeAnObjectOrStringOrNull($input): void + public function testFirstCanBeAnObjectOrStringOrNull(mixed $input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -232,10 +222,8 @@ public function testFirstCanBeAnObjectOrStringOrNull($input): void * @dataProvider jsonValuesProvider * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. - * - * @param mixed $input */ - public function testLastCanBeAStringOrNull($input): void + public function testLastCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -282,10 +270,8 @@ public function testLastCanBeAStringOrNull($input): void * @dataProvider jsonValuesProvider * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. - * - * @param mixed $input */ - public function testPrevCanBeAStringOrNull($input): void + public function testPrevCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -332,10 +318,8 @@ public function testPrevCanBeAStringOrNull($input): void * @dataProvider jsonValuesProvider * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. - * - * @param mixed $input */ - public function testNextCanBeAStringOrNull($input): void + public function testNextCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -378,9 +362,6 @@ public function testNextCanBeAStringOrNull($input): void $link = new DocumentLink($object, $this->manager, $this->parent); } - /** - * @test - */ public function testGetOnANonExistingKeyThrowsException(): void { $object = new \stdClass(); diff --git a/tests/Unit/V1/DocumentTest.php b/tests/Unit/V1/DocumentTest.php index 5a8e949..bbc7799 100644 --- a/tests/Unit/V1/DocumentTest.php +++ b/tests/Unit/V1/DocumentTest.php @@ -88,10 +88,8 @@ public function testCreateWithAllPossibleValues(): void * @dataProvider jsonValuesProviderWithoutObject * * A JSON object MUST be at the root of every JSON API request and response containing data. - * - * @param mixed $input */ - public function testCreateWithDataproviderThrowsException($input): void + public function testCreateWithDataproviderThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -232,10 +230,8 @@ public function testCreateDataWithResourceCollectionResources(): void * @dataProvider jsonValuesProviderWithoutObject * * Test create with any value in data - * - * @param mixed $input */ - public function testCreateWithDataproviderInValue($input): void + public function testCreateWithDataproviderInValue(mixed $input): void { // Test with empty array in data diff --git a/tests/Unit/V1/ErrorCollectionTest.php b/tests/Unit/V1/ErrorCollectionTest.php index e6fc4a1..7e15764 100644 --- a/tests/Unit/V1/ErrorCollectionTest.php +++ b/tests/Unit/V1/ErrorCollectionTest.php @@ -65,10 +65,8 @@ public function testCreate(): void /** * @dataProvider jsonValuesProvider - * - * @param mixed $input */ - public function testCreateWithoutArrayThrowsException($input): void + public function testCreateWithoutArrayThrowsException(mixed $input): void { // Input must be an array with at least one object if (gettype($input) === 'array') { diff --git a/tests/Unit/V1/ErrorLinkTest.php b/tests/Unit/V1/ErrorLinkTest.php index 7b66639..49d2da1 100644 --- a/tests/Unit/V1/ErrorLinkTest.php +++ b/tests/Unit/V1/ErrorLinkTest.php @@ -103,10 +103,8 @@ public function testAboutCanBeAnObject(): void * @dataProvider jsonValuesProviderWithoutObject * * The value of each links member MUST be an object (a "links object"). - * - * @param mixed $input */ - public function testCreateWithDataprovider($input): void + public function testCreateWithDataprovider(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -120,10 +118,8 @@ public function testCreateWithDataprovider($input): void * @dataProvider jsonValuesProviderWithoutObjectAndString * * test create without object or string attribute throws exception - * - * @param mixed $input */ - public function testCreateWithoutObjectOrStringAttributeThrowsException($input): void + public function testCreateWithoutObjectOrStringAttributeThrowsException(mixed $input): void { $object = new \stdClass(); $object->about = 'http://example.org/about'; @@ -141,10 +137,8 @@ public function testCreateWithoutObjectOrStringAttributeThrowsException($input): * @dataProvider jsonValuesProviderWithoutObjectAndString * * The value of the about member MUST be an object (a "links object") or a string. - * - * @param mixed $input */ - public function testAboutWithDataproviderThrowsException($input): void + public function testAboutWithDataproviderThrowsException(mixed $input): void { $object = new \stdClass(); $object->about = $input; diff --git a/tests/Unit/V1/ErrorSourceTest.php b/tests/Unit/V1/ErrorSourceTest.php index 553a99e..a17aa88 100644 --- a/tests/Unit/V1/ErrorSourceTest.php +++ b/tests/Unit/V1/ErrorSourceTest.php @@ -71,10 +71,8 @@ public function testOnlyPointerParameterPropertiesExists(): void * @dataProvider jsonValuesProviderWithoutObject * * source: an object containing references to ... - * - * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input): void + public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -88,10 +86,8 @@ public function testCreateWithoutObjectThrowsException($input): void * @dataProvider jsonValuesProviderWithoutString * * pointer: a JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute]. - * - * @param mixed $input */ - public function testPointerMustBeAString($input): void + public function testPointerMustBeAString(mixed $input): void { $object = new \stdClass(); $object->pointer = $input; @@ -108,10 +104,8 @@ public function testPointerMustBeAString($input): void * @dataProvider jsonValuesProviderWithoutString * * parameter: a string indicating which query parameter caused the error. - * - * @param mixed $input */ - public function testParameterMustBeAString($input): void + public function testParameterMustBeAString(mixed $input): void { $object = new \stdClass(); $object->parameter = $input; diff --git a/tests/Unit/V1/ErrorTest.php b/tests/Unit/V1/ErrorTest.php index a777c85..0030f5b 100644 --- a/tests/Unit/V1/ErrorTest.php +++ b/tests/Unit/V1/ErrorTest.php @@ -82,10 +82,8 @@ public function testCreateWithObjectReturnsSelf(): void /** * @dataProvider jsonValuesProviderWithoutObject - * - * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input): void + public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -97,10 +95,8 @@ public function testCreateWithoutObjectThrowsException($input): void /** * @dataProvider jsonValuesProviderWithoutString - * - * @param mixed $input */ - public function testCreateIdWithoutStringThrowsException($input): void + public function testCreateIdWithoutStringThrowsException(mixed $input): void { $object = new \stdClass(); $object->id = $input; @@ -115,10 +111,8 @@ public function testCreateIdWithoutStringThrowsException($input): void /** * @dataProvider jsonValuesProviderWithoutString - * - * @param mixed $input */ - public function testCreateStatusWithoutStringThrowsException($input): void + public function testCreateStatusWithoutStringThrowsException(mixed $input): void { $object = new \stdClass(); $object->status = $input; @@ -133,10 +127,8 @@ public function testCreateStatusWithoutStringThrowsException($input): void /** * @dataProvider jsonValuesProviderWithoutString - * - * @param mixed $input */ - public function testCreateCodeWithoutStringThrowsException($input): void + public function testCreateCodeWithoutStringThrowsException(mixed $input): void { $object = new \stdClass(); $object->code = $input; @@ -151,10 +143,8 @@ public function testCreateCodeWithoutStringThrowsException($input): void /** * @dataProvider jsonValuesProviderWithoutString - * - * @param mixed $input */ - public function testCreateTitleWithoutStringThrowsException($input): void + public function testCreateTitleWithoutStringThrowsException(mixed $input): void { $object = new \stdClass(); $object->title = $input; @@ -169,10 +159,8 @@ public function testCreateTitleWithoutStringThrowsException($input): void /** * @dataProvider jsonValuesProviderWithoutString - * - * @param mixed $input */ - public function testCreateDetailWithoutStringThrowsException($input): void + public function testCreateDetailWithoutStringThrowsException(mixed $input): void { $object = new \stdClass(); $object->detail = $input; diff --git a/tests/Unit/V1/JsonapiTest.php b/tests/Unit/V1/JsonapiTest.php index ccbeb0a..b0be61a 100644 --- a/tests/Unit/V1/JsonapiTest.php +++ b/tests/Unit/V1/JsonapiTest.php @@ -73,10 +73,8 @@ public function testCreateWithObject(): void * @dataProvider jsonValuesProviderWithoutObject * * If present, the value of the jsonapi member MUST be an object (a "jsonapi object"). - * - * @param mixed $input */ - public function testCreateWithDataprovider($input): void + public function testCreateWithDataprovider(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -90,10 +88,8 @@ public function testCreateWithDataprovider($input): void * @dataProvider jsonValuesProvider * * The jsonapi object MAY contain a version member whose value is a string - * - * @param mixed $input */ - public function testVersionCannotBeAnObjectOrArray($input): void + public function testVersionCannotBeAnObjectOrArray(mixed $input): void { $object = new \stdClass(); $object->version = $input; diff --git a/tests/Unit/V1/LinkTest.php b/tests/Unit/V1/LinkTest.php index e62d237..677bb37 100644 --- a/tests/Unit/V1/LinkTest.php +++ b/tests/Unit/V1/LinkTest.php @@ -67,10 +67,8 @@ public function testCreateWithObject(): void * * - an object ("link object") which can contain the following members: * - href: a string containing the link's URL. - * - * @param mixed $input */ - public function testHrefHasToBeAString($input): void + public function testHrefHasToBeAString(mixed $input): void { $object = new \stdClass(); $object->href = $input; @@ -130,10 +128,8 @@ public function testMetaIsParsedAsObject(): void * @dataProvider jsonValuesProviderWithoutObject * * The value of each links member MUST be an object (a "links object"). - * - * @param mixed $input */ - public function testCreateWithDataprovider($input): void + public function testCreateWithDataprovider(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/V1/MetaTest.php b/tests/Unit/V1/MetaTest.php index 218ed5f..3bc87d7 100644 --- a/tests/Unit/V1/MetaTest.php +++ b/tests/Unit/V1/MetaTest.php @@ -79,10 +79,8 @@ public function testCreateWithObject(): void * @dataProvider jsonValuesProviderWithoutObject * * The value of each meta member MUST be an object (a "meta object"). - * - * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input): void + public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage('Meta has to be an object, "' . gettype($input) . '" given.'); diff --git a/tests/Unit/V1/RelationshipCollectionTest.php b/tests/Unit/V1/RelationshipCollectionTest.php index fa6ef95..fe44aea 100644 --- a/tests/Unit/V1/RelationshipCollectionTest.php +++ b/tests/Unit/V1/RelationshipCollectionTest.php @@ -160,10 +160,8 @@ public function testCreateWithAuthorInRelationshipsAndAttributesThrowsException( /** * @dataProvider jsonValuesProviderWithoutObject - * - * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input): void + public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/V1/RelationshipLinkTest.php b/tests/Unit/V1/RelationshipLinkTest.php index 475e080..aaea75a 100644 --- a/tests/Unit/V1/RelationshipLinkTest.php +++ b/tests/Unit/V1/RelationshipLinkTest.php @@ -203,10 +203,8 @@ public function testPaginationNotParsedIfRelationshipIdentifierCollectionNotExis * @dataProvider jsonValuesProviderWithoutObject * * links: a links object containing at least one of the following: - * - * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input): void + public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -220,10 +218,8 @@ public function testCreateWithoutObjectThrowsException($input): void * @dataProvider jsonValuesProviderWithoutObjectAndString * * test create without object or string attribute throws exception - * - * @param mixed $input */ - public function testCreateWithoutObjectOrStringAttributeThrowsException($input): void + public function testCreateWithoutObjectOrStringAttributeThrowsException(mixed $input): void { $object = new \stdClass(); $object->self = 'http://example.org/self'; @@ -258,10 +254,8 @@ public function testCreateWithoutSelfAndRelatedPropertiesThrowsException(): void * @dataProvider jsonValuesProviderWithoutObjectAndString * * self: a link for the relationship itself (a "relationship link"). - * - * @param mixed $input */ - public function testSelfMustBeAStringOrObject($input): void + public function testSelfMustBeAStringOrObject(mixed $input): void { $object = new \stdClass(); $object->self = $input; @@ -279,10 +273,8 @@ public function testSelfMustBeAStringOrObject($input): void * * related: a related resource link when the primary data represents a resource relationship. * If present, a related resource link MUST reference a valid URL - * - * @param mixed $input */ - public function testRelatedMustBeAStringOrObject($input): void + public function testRelatedMustBeAStringOrObject(mixed $input): void { $object = new \stdClass(); $object->related = $input; @@ -299,10 +291,8 @@ public function testRelatedMustBeAStringOrObject($input): void * @dataProvider jsonValuesProvider * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. - * - * @param mixed $input */ - public function testFirstCanBeAStringOrNull($input): void + public function testFirstCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -340,10 +330,8 @@ public function testFirstCanBeAStringOrNull($input): void * @dataProvider jsonValuesProvider * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. - * - * @param mixed $input */ - public function testLastCanBeAStringOrNull($input): void + public function testLastCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -381,10 +369,8 @@ public function testLastCanBeAStringOrNull($input): void * @dataProvider jsonValuesProvider * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. - * - * @param mixed $input */ - public function testPrevCanBeAStringOrNull($input): void + public function testPrevCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -422,10 +408,8 @@ public function testPrevCanBeAStringOrNull($input): void * @dataProvider jsonValuesProvider * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. - * - * @param mixed $input */ - public function testNextCanBeAStringOrNull($input): void + public function testNextCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; diff --git a/tests/Unit/V1/RelationshipTest.php b/tests/Unit/V1/RelationshipTest.php index 7574890..f31cac1 100644 --- a/tests/Unit/V1/RelationshipTest.php +++ b/tests/Unit/V1/RelationshipTest.php @@ -62,10 +62,8 @@ public function testCreateWithObjectReturnsSelf(): void * @dataProvider jsonValuesProviderWithoutObject * * The value of the relationships key MUST be an object (a "relationships object"). - * - * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input): void + public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/V1/ResourceCollectionTest.php b/tests/Unit/V1/ResourceCollectionTest.php index 9955a9d..3a6d0a1 100644 --- a/tests/Unit/V1/ResourceCollectionTest.php +++ b/tests/Unit/V1/ResourceCollectionTest.php @@ -135,10 +135,8 @@ public function testCreateWithItem(): void /** * @dataProvider jsonValuesProviderWithoutArray - * - * @param mixed $input */ - public function testCreateWithoutArrayThrowsException($input): void + public function testCreateWithoutArrayThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -150,10 +148,8 @@ public function testCreateWithoutArrayThrowsException($input): void /** * @dataProvider jsonValuesProviderWithoutObject - * - * @param mixed $input */ - public function testCreateWithoutObjectInArrayThrowsException($input): void + public function testCreateWithoutObjectInArrayThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/V1/ResourceIdentifierCollectionTest.php b/tests/Unit/V1/ResourceIdentifierCollectionTest.php index 3ab6f02..2684a72 100644 --- a/tests/Unit/V1/ResourceIdentifierCollectionTest.php +++ b/tests/Unit/V1/ResourceIdentifierCollectionTest.php @@ -97,10 +97,8 @@ public function testCreateWithItem(): void /** * @dataProvider jsonValuesProviderWithoutArray - * - * @param mixed $input */ - public function testCreateWithoutArrayThrowsException($input): void + public function testCreateWithoutArrayThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/V1/ResourceIdentifierTest.php b/tests/Unit/V1/ResourceIdentifierTest.php index 65e4ff5..f8e0a50 100644 --- a/tests/Unit/V1/ResourceIdentifierTest.php +++ b/tests/Unit/V1/ResourceIdentifierTest.php @@ -75,10 +75,8 @@ public function testCreateWithObjectAndMeta(): void * @dataProvider jsonValuesProviderWithoutString * * The values of the id and type members MUST be strings. - * - * @param mixed $input */ - public function testTypeMustBeAString($input): void + public function testTypeMustBeAString(mixed $input): void { $object = new \stdClass(); $object->type = $input; @@ -98,10 +96,8 @@ public function testTypeMustBeAString($input): void * @dataProvider jsonValuesProviderWithoutString * * The values of the id and type members MUST be strings. - * - * @param mixed $input */ - public function testIdMustBeAString($input): void + public function testIdMustBeAString(mixed $input): void { $object = new \stdClass(); $object->type = 'posts'; @@ -120,10 +116,8 @@ public function testIdMustBeAString($input): void * * A "resource identifier object" is an object that identifies an individual resource. * A "resource identifier object" MUST contain type and id members. - * - * @param mixed $input */ - public function testCreateWithDataproviderThrowsException($input): void + public function testCreateWithDataproviderThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/V1/ResourceItemLinkTest.php b/tests/Unit/V1/ResourceItemLinkTest.php index 1d98f6f..baa5246 100644 --- a/tests/Unit/V1/ResourceItemLinkTest.php +++ b/tests/Unit/V1/ResourceItemLinkTest.php @@ -58,10 +58,8 @@ public function testParsingPropertiesExists(): void * @dataProvider jsonValuesProviderWithoutObject * * links: a links object related to the primary data. - * - * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input): void + public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -75,10 +73,8 @@ public function testCreateWithoutObjectThrowsException($input): void * @dataProvider jsonValuesProviderWithoutObjectAndString * * test create without object or string attribute throws exception - * - * @param mixed $input */ - public function testCreateWithoutObjectOrStringAttributeThrowsException($input): void + public function testCreateWithoutObjectOrStringAttributeThrowsException(mixed $input): void { $object = new \stdClass(); $object->input = $input; diff --git a/tests/Unit/V1/ResourceItemTest.php b/tests/Unit/V1/ResourceItemTest.php index 8641760..a4c7bbe 100644 --- a/tests/Unit/V1/ResourceItemTest.php +++ b/tests/Unit/V1/ResourceItemTest.php @@ -99,10 +99,8 @@ public function testCreateWithFullObject(): void * @dataProvider jsonValuesProviderWithoutString * * The values of the id and type members MUST be strings. - * - * @param mixed $input */ - public function testTypeMustBeAString($input): void + public function testTypeMustBeAString(mixed $input): void { $object = new \stdClass(); $object->type = $input; @@ -120,10 +118,8 @@ public function testTypeMustBeAString($input): void * @dataProvider jsonValuesProviderWithoutString * * The values of the id and type members MUST be strings. - * - * @param mixed $input */ - public function testIdMustBeAString($input): void + public function testIdMustBeAString(mixed $input): void { $object = new \stdClass(); $object->type = 'posts'; @@ -142,10 +138,8 @@ public function testIdMustBeAString($input): void * * A "resource object" is an object that identifies an individual resource. * A "resource object" MUST contain type and id members. - * - * @param mixed $input */ - public function testCreateWithDataproviderThrowsException($input): void + public function testCreateWithDataproviderThrowsException(mixed $input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/V1/ResourceNullTest.php b/tests/Unit/V1/ResourceNullTest.php index b476e3d..fa80032 100644 --- a/tests/Unit/V1/ResourceNullTest.php +++ b/tests/Unit/V1/ResourceNullTest.php @@ -31,10 +31,8 @@ public function setUp(): void /** * @dataProvider jsonValuesProvider - * - * @param mixed $input */ - public function testCreateWithDataProvider($input): void + public function testCreateWithDataProvider(mixed $input): void { $resource = new ResourceNull( $input, From 63e764aab81a8de384e6d6abf9a6193c3e8e95bb Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 28 Nov 2023 16:56:53 +0100 Subject: [PATCH 7/7] replace dataProvider annotations with DataProvider attribute --- tests/Functional/DotNotationTest.php | 6 --- tests/Functional/ErrorParsingTest.php | 6 --- tests/Functional/ParsingTest.php | 44 +------------------ tests/Functional/SerializerTest.php | 5 +-- tests/Unit/Helper/AccessableTraitTest.php | 9 ++-- tests/Unit/Input/RequestStringInputTest.php | 9 ++-- tests/Unit/Input/ResponseStringInputTest.php | 9 ++-- tests/Unit/Manager/ErrorAbortManagerTest.php | 6 --- tests/Unit/V1/AttributesTest.php | 8 +--- tests/Unit/V1/DocumentLinkTest.php | 25 ++++------- tests/Unit/V1/DocumentTest.php | 10 ++--- tests/Unit/V1/ErrorCollectionTest.php | 5 +-- tests/Unit/V1/ErrorLinkTest.php | 13 ++---- tests/Unit/V1/ErrorSourceTest.php | 10 ++--- tests/Unit/V1/ErrorTest.php | 25 +++-------- tests/Unit/V1/FactoryTest.php | 3 -- tests/Unit/V1/JsonapiTest.php | 7 ++- tests/Unit/V1/LinkTest.php | 7 ++- tests/Unit/V1/MetaTest.php | 4 +- tests/Unit/V1/RelationshipCollectionTest.php | 5 +-- tests/Unit/V1/RelationshipLinkTest.php | 28 ++++-------- tests/Unit/V1/RelationshipTest.php | 4 +- tests/Unit/V1/ResourceCollectionTest.php | 9 ++-- .../V1/ResourceIdentifierCollectionTest.php | 5 +-- tests/Unit/V1/ResourceIdentifierTest.php | 10 ++--- tests/Unit/V1/ResourceItemLinkTest.php | 10 ++--- tests/Unit/V1/ResourceItemTest.php | 10 ++--- tests/Unit/V1/ResourceNullTest.php | 5 +-- 28 files changed, 83 insertions(+), 214 deletions(-) diff --git a/tests/Functional/DotNotationTest.php b/tests/Functional/DotNotationTest.php index bb0a1f2..bb7f598 100644 --- a/tests/Functional/DotNotationTest.php +++ b/tests/Functional/DotNotationTest.php @@ -20,9 +20,6 @@ class DotNotationTest extends TestCase { use HelperTrait; - /** - * @test - */ public function testCompleteResourceObjectWithMultipleRelationships(): void { $manager = new ErrorAbortManager(new Factory()); @@ -189,9 +186,6 @@ public function testCompleteResourceObjectWithMultipleRelationships(): void $this->assertSame('http://example.com/comments/12', $document->get('included.2.links.self')); } - /** - * @test - */ public function testGetNotExistentValueThrowsException(): void { $manager = new ErrorAbortManager(new Factory()); diff --git a/tests/Functional/ErrorParsingTest.php b/tests/Functional/ErrorParsingTest.php index ce30a29..08d480d 100644 --- a/tests/Functional/ErrorParsingTest.php +++ b/tests/Functional/ErrorParsingTest.php @@ -16,9 +16,6 @@ class ErrorParsingTest extends TestCase { use HelperTrait; - /** - * @test - */ public function testParseErrors(): void { $string = $this->getJsonString('09_errors.json'); @@ -89,9 +86,6 @@ public function testParseErrors(): void $this->assertFalse($errors->has('3')); } - /** - * @test - */ public function testParseErrorWithLinks(): void { $string = $this->getJsonString('10_error_with_links.json'); diff --git a/tests/Functional/ParsingTest.php b/tests/Functional/ParsingTest.php index 8729849..ac3227f 100644 --- a/tests/Functional/ParsingTest.php +++ b/tests/Functional/ParsingTest.php @@ -14,6 +14,7 @@ use Art4\JsonApiClient\Manager\ErrorAbortManager; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\Factory; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ParsingTest extends TestCase @@ -38,9 +39,7 @@ public static function createParserProvider(): array ]; } - /** - * @dataProvider createParserProvider - */ + #[DataProvider('createParserProvider')] public function testParseSimpleResourceWithDifferentParser(callable $parser): void { $string = $this->getJsonString('01_simple_resource.json'); @@ -67,9 +66,6 @@ public function testParseSimpleResourceWithDifferentParser(callable $parser): vo $this->assertInstanceOf('Art4\JsonApiClient\V1\RelationshipCollection', $resource->get('relationships')); } - /** - * @test - */ public function testParseSimpleResourceIdentifier(): void { $string = $this->getJsonString('02_simple_resource_identifier.json'); @@ -91,9 +87,6 @@ public function testParseSimpleResourceIdentifier(): void $this->assertSame($resource->get('id'), '1'); } - /** - * @test - */ public function testParseResourceObject(): void { $string = $this->getJsonString('03_resource_object.json'); @@ -159,9 +152,6 @@ public function testParseResourceObject(): void $this->assertSame($data->get('id'), '9'); } - /** - * @test - */ public function testParseCompleteResourceObjectWithMultipleRelationships(): void { $string = $this->getJsonString('04_complete_document_with_multiple_relationships.json'); @@ -355,9 +345,6 @@ public function testParseCompleteResourceObjectWithMultipleRelationships(): void $this->assertSame($links->get('self'), 'http://example.com/comments/12'); } - /** - * @test - */ public function testParsePaginationExample(): void { $string = $this->getJsonString('06_pagination_example.json'); @@ -409,9 +396,6 @@ public function testParsePaginationExample(): void $this->assertSame($links->get('last'), 'http://example.com/articles?page[number]=13&page[size]=1'); } - /** - * @test - */ public function testParseRelationshipExample(): void { $string = $this->getJsonString('07_relationship_example_without_data.json'); @@ -475,9 +459,6 @@ public function testParseRelationshipExample(): void $this->assertSame($document->get('data.0.relationships.comments.links.related.meta.count'), 10); } - /** - * @test - */ public function testParseObjectLinksExample(): void { $string = $this->getJsonString('08_object_links.json'); @@ -518,9 +499,6 @@ public function testParseObjectLinksExample(): void $this->assertSame('bar', $document->get('jsonapi.meta.foo')); } - /** - * @test - */ public function testParseResourceIdentifierWithMeta(): void { $string = $this->getJsonString('11_resource_identifier_with_meta.json'); @@ -544,9 +522,6 @@ public function testParseResourceIdentifierWithMeta(): void $this->assertSame($resource->get('id'), '2'); } - /** - * @test - */ public function testParseNullResource(): void { $string = $this->getJsonString('12_null_resource.json'); @@ -565,9 +540,6 @@ public function testParseNullResource(): void $this->assertInstanceOf('Art4\JsonApiClient\V1\ResourceNull', $resource); } - /** - * @test - */ public function testParseResourceIdentifierCollectionWithMeta(): void { $string = $this->getJsonString('13_collection_with_resource_identifier_with_meta.json'); @@ -602,9 +574,6 @@ public function testParseResourceIdentifierCollectionWithMeta(): void $this->assertSame($resource1->get('id'), '2'); } - /** - * @test - */ public function testParseCreateResourceWithoutId(): void { $string = $this->getJsonString('14_create_resource_without_id.json'); @@ -614,9 +583,6 @@ public function testParseCreateResourceWithoutId(): void $this->assertSame(['data'], $document->getKeys()); } - /** - * @test - */ public function testParseCreateShortResourceWithoutId(): void { $string = $this->getJsonString('15_create_resource_without_id.json'); @@ -626,9 +592,6 @@ public function testParseCreateShortResourceWithoutId(): void $this->assertSame(['data'], $document->getKeys()); } - /** - * @test - */ public function testExceptionIfIdIsNotString(): void { $this->expectException(\Art4\JsonApiClient\Exception\ValidationException::class); @@ -636,9 +599,6 @@ public function testExceptionIfIdIsNotString(): void $document = Parser::parseResponseString($string); } - /** - * @test - */ public function testParseLinksInRelationshipsCorrectly(): void { $string = $this->getJsonString('17_relationship_links.json'); diff --git a/tests/Functional/SerializerTest.php b/tests/Functional/SerializerTest.php index 1838e87..71d9fa7 100644 --- a/tests/Functional/SerializerTest.php +++ b/tests/Functional/SerializerTest.php @@ -15,6 +15,7 @@ use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\Factory; use Exception; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class SerializerTest extends TestCase @@ -61,9 +62,7 @@ public static function jsonapiDataProvider(): array return $files; } - /** - * @dataProvider jsonapiDataProvider - */ + #[DataProvider('jsonapiDataProvider')] public function testParseJsonapiDataWithErrorAbortManager(string $filename, bool $isRequest): void { $manager = new ErrorAbortManager(new Factory()); diff --git a/tests/Unit/Helper/AccessableTraitTest.php b/tests/Unit/Helper/AccessableTraitTest.php index 583f436..eca0494 100644 --- a/tests/Unit/Helper/AccessableTraitTest.php +++ b/tests/Unit/Helper/AccessableTraitTest.php @@ -11,15 +11,14 @@ use Art4\JsonApiClient\Exception\AccessException; use Art4\JsonApiClient\Tests\Fixtures\AccessableTraitMock; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class AccessableTraitTest extends TestCase { use HelperTrait; - /** - * @dataProvider jsonValuesProviderWithoutStringAndInt - */ + #[DataProvider('jsonValuesProviderWithoutStringAndInt')] public function testHasWithInvalidKeyTypeTriggersDeprecationError(mixed $key): void { $resource = new AccessableTraitMock(); @@ -41,9 +40,7 @@ function ($errno, $errstr) use ($key): bool { $resource->has($key); } - /** - * @dataProvider jsonValuesProviderWithoutStringAndInt - */ + #[DataProvider('jsonValuesProviderWithoutStringAndInt')] public function testGetWithInvalidKeyTypeTriggersDeprecationError(mixed $key): void { $resource = new AccessableTraitMock(); diff --git a/tests/Unit/Input/RequestStringInputTest.php b/tests/Unit/Input/RequestStringInputTest.php index 665d562..bfa259b 100644 --- a/tests/Unit/Input/RequestStringInputTest.php +++ b/tests/Unit/Input/RequestStringInputTest.php @@ -11,6 +11,7 @@ use Art4\JsonApiClient\Exception\InputException; use Art4\JsonApiClient\Input\RequestStringInput; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class RequestStringInputTest extends TestCase @@ -24,9 +25,7 @@ public function testGetAsObjectFromStringReturnsObject(): void $this->assertInstanceOf(\stdClass::class, $input->getAsObject()); } - /** - * @dataProvider jsonValuesProviderWithoutString - */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testCreateWithoutStringThrowsException(mixed $input): void { $this->expectException(InputException::class); @@ -36,9 +35,7 @@ public function testCreateWithoutStringThrowsException(mixed $input): void new RequestStringInput($input); } - /** - * @dataProvider jsonValuesAsStringProviderWithoutObject - */ + #[DataProvider('jsonValuesAsStringProviderWithoutObject')] public function testGetAsObjectWithInvalidStringsThrowsException(string $input): void { $input = new RequestStringInput($input); diff --git a/tests/Unit/Input/ResponseStringInputTest.php b/tests/Unit/Input/ResponseStringInputTest.php index d7e0755..7d1f6aa 100644 --- a/tests/Unit/Input/ResponseStringInputTest.php +++ b/tests/Unit/Input/ResponseStringInputTest.php @@ -11,6 +11,7 @@ use Art4\JsonApiClient\Exception\InputException; use Art4\JsonApiClient\Input\ResponseStringInput; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ResponseStringInputTest extends TestCase @@ -24,9 +25,7 @@ public function testGetAsObjectFromStringReturnsObject(): void $this->assertInstanceOf(\stdClass::class, $input->getAsObject()); } - /** - * @dataProvider jsonValuesProviderWithoutString - */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testCreateWithoutStringThrowsException(mixed $input): void { $this->expectException(InputException::class); @@ -36,9 +35,7 @@ public function testCreateWithoutStringThrowsException(mixed $input): void new ResponseStringInput($input); } - /** - * @dataProvider jsonValuesAsStringProviderWithoutObject - */ + #[DataProvider('jsonValuesAsStringProviderWithoutObject')] public function testGetAsObjectWithInvalidStringsThrowsException(string $input): void { $input = new ResponseStringInput($input); diff --git a/tests/Unit/Manager/ErrorAbortManagerTest.php b/tests/Unit/Manager/ErrorAbortManagerTest.php index 9cae683..653bfc6 100644 --- a/tests/Unit/Manager/ErrorAbortManagerTest.php +++ b/tests/Unit/Manager/ErrorAbortManagerTest.php @@ -14,9 +14,6 @@ class ErrorAbortManagerTest extends TestCase { - /** - * @test - */ public function testCreateWithConstructorReturnsSelf(): void { $factory = $this->createMock(Factory::class); @@ -25,9 +22,6 @@ public function testCreateWithConstructorReturnsSelf(): void $this->assertSame($factory, $manager->getFactory()); } - /** - * @test - */ public function testGetParamReturnsDefault(): void { $factory = $this->createMock(Factory::class); diff --git a/tests/Unit/V1/AttributesTest.php b/tests/Unit/V1/AttributesTest.php index c451bbe..e19a201 100644 --- a/tests/Unit/V1/AttributesTest.php +++ b/tests/Unit/V1/AttributesTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\Attributes; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class AttributesTest extends TestCase @@ -80,9 +81,7 @@ public function testCreateWithObject(): void ], $attributes->getKeys()); } - /** - * @dataProvider jsonValuesProviderWithoutObject - */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithDataProvider(mixed $input): void { $this->expectException(ValidationException::class); @@ -186,9 +185,6 @@ public function testCreateWithLinksPropertyThrowsException(): void ); } - /** - * @test - */ public function testGetOnANonExistingKeyThrowsException(): void { $object = new \stdClass(); diff --git a/tests/Unit/V1/DocumentLinkTest.php b/tests/Unit/V1/DocumentLinkTest.php index 90bd2d0..da58837 100644 --- a/tests/Unit/V1/DocumentLinkTest.php +++ b/tests/Unit/V1/DocumentLinkTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\DocumentLink; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class DocumentLinkTest extends TestCase @@ -89,10 +90,9 @@ public function testOnlySelfRelatedPaginationPropertiesExists(): void } /** - * @dataProvider jsonValuesProviderWithoutObject - * * links: a links object related to the primary data. */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); @@ -104,10 +104,9 @@ public function testCreateWithoutObjectThrowsException(mixed $input): void } /** - * @dataProvider jsonValuesProviderWithoutObjectAndString - * * test create without object or string attribute throws exception */ + #[DataProvider('jsonValuesProviderWithoutObjectAndString')] public function testCreateWithoutObjectOrStringAttributeThrowsException(mixed $input): void { $object = new \stdClass(); @@ -123,10 +122,9 @@ public function testCreateWithoutObjectOrStringAttributeThrowsException(mixed $i } /** - * @dataProvider jsonValuesProviderWithoutObjectAndString - * * self: the link that generated the current response document. */ + #[DataProvider('jsonValuesProviderWithoutObjectAndString')] public function testSelfMustBeAStringOrObject(mixed $input): void { $object = new \stdClass(); @@ -141,8 +139,6 @@ public function testSelfMustBeAStringOrObject(mixed $input): void } /** - * @dataProvider jsonValuesProviderWithoutObjectAndString - * * related: a related resource link when the primary data represents a resource relationship. * If present, a related resource link MUST reference a valid URL * @@ -157,6 +153,7 @@ public function testSelfMustBeAStringOrObject(mixed $input): void * } * } */ + #[DataProvider('jsonValuesProviderWithoutObjectAndString')] public function testRelatedMustBeAStringOrObject(mixed $input): void { $object = new \stdClass(); @@ -171,10 +168,9 @@ public function testRelatedMustBeAStringOrObject(mixed $input): void } /** - * @dataProvider jsonValuesProvider - * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. */ + #[DataProvider('jsonValuesProvider')] public function testFirstCanBeAnObjectOrStringOrNull(mixed $input): void { $object = new \stdClass(); @@ -219,10 +215,9 @@ public function testFirstCanBeAnObjectOrStringOrNull(mixed $input): void } /** - * @dataProvider jsonValuesProvider - * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. */ + #[DataProvider('jsonValuesProvider')] public function testLastCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); @@ -267,10 +262,9 @@ public function testLastCanBeAStringOrNull(mixed $input): void } /** - * @dataProvider jsonValuesProvider - * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. */ + #[DataProvider('jsonValuesProvider')] public function testPrevCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); @@ -315,10 +309,9 @@ public function testPrevCanBeAStringOrNull(mixed $input): void } /** - * @dataProvider jsonValuesProvider - * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. */ + #[DataProvider('jsonValuesProvider')] public function testNextCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); diff --git a/tests/Unit/V1/DocumentTest.php b/tests/Unit/V1/DocumentTest.php index bbc7799..d62ef94 100644 --- a/tests/Unit/V1/DocumentTest.php +++ b/tests/Unit/V1/DocumentTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\Document; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class DocumentTest extends TestCase @@ -85,10 +86,9 @@ public function testCreateWithAllPossibleValues(): void } /** - * @dataProvider jsonValuesProviderWithoutObject - * * A JSON object MUST be at the root of every JSON API request and response containing data. */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithDataproviderThrowsException(mixed $input): void { $this->expectException(ValidationException::class); @@ -227,10 +227,9 @@ public function testCreateDataWithResourceCollectionResources(): void } /** - * @dataProvider jsonValuesProviderWithoutObject - * * Test create with any value in data */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithDataproviderInValue(mixed $input): void { @@ -409,9 +408,6 @@ public function testCreateIncludedWithoutDataThrowsException(): void $document = new Document($object, $this->manager, $this->parent); } - /** - * @test - */ public function testGetOnANonExistingKeyThrowsException(): void { $object = new \stdClass(); diff --git a/tests/Unit/V1/ErrorCollectionTest.php b/tests/Unit/V1/ErrorCollectionTest.php index 7e15764..00db6b0 100644 --- a/tests/Unit/V1/ErrorCollectionTest.php +++ b/tests/Unit/V1/ErrorCollectionTest.php @@ -14,6 +14,7 @@ use Art4\JsonApiClient\Helper\AccessKey; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\ErrorCollection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ErrorCollectionTest extends TestCase @@ -63,9 +64,7 @@ public function testCreate(): void $this->assertInstanceOf(Accessable::class, $error); } - /** - * @dataProvider jsonValuesProvider - */ + #[DataProvider('jsonValuesProvider')] public function testCreateWithoutArrayThrowsException(mixed $input): void { // Input must be an array with at least one object diff --git a/tests/Unit/V1/ErrorLinkTest.php b/tests/Unit/V1/ErrorLinkTest.php index 49d2da1..3a4dfe0 100644 --- a/tests/Unit/V1/ErrorLinkTest.php +++ b/tests/Unit/V1/ErrorLinkTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\ErrorLink; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ErrorLinkTest extends TestCase @@ -100,10 +101,9 @@ public function testAboutCanBeAnObject(): void } /** - * @dataProvider jsonValuesProviderWithoutObject - * * The value of each links member MUST be an object (a "links object"). */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithDataprovider(mixed $input): void { $this->expectException(ValidationException::class); @@ -115,10 +115,9 @@ public function testCreateWithDataprovider(mixed $input): void } /** - * @dataProvider jsonValuesProviderWithoutObjectAndString - * * test create without object or string attribute throws exception */ + #[DataProvider('jsonValuesProviderWithoutObjectAndString')] public function testCreateWithoutObjectOrStringAttributeThrowsException(mixed $input): void { $object = new \stdClass(); @@ -134,10 +133,9 @@ public function testCreateWithoutObjectOrStringAttributeThrowsException(mixed $i } /** - * @dataProvider jsonValuesProviderWithoutObjectAndString - * * The value of the about member MUST be an object (a "links object") or a string. */ + #[DataProvider('jsonValuesProviderWithoutObjectAndString')] public function testAboutWithDataproviderThrowsException(mixed $input): void { $object = new \stdClass(); @@ -151,9 +149,6 @@ public function testAboutWithDataproviderThrowsException(mixed $input): void $link = new ErrorLink($object, $this->manager, $this->parent); } - /** - * @test - */ public function testGetOnANonExistingKeyThrowsException(): void { $object = new \stdClass(); diff --git a/tests/Unit/V1/ErrorSourceTest.php b/tests/Unit/V1/ErrorSourceTest.php index a17aa88..f6cab45 100644 --- a/tests/Unit/V1/ErrorSourceTest.php +++ b/tests/Unit/V1/ErrorSourceTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\ErrorSource; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ErrorSourceTest extends TestCase @@ -68,10 +69,9 @@ public function testOnlyPointerParameterPropertiesExists(): void } /** - * @dataProvider jsonValuesProviderWithoutObject - * * source: an object containing references to ... */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); @@ -83,10 +83,9 @@ public function testCreateWithoutObjectThrowsException(mixed $input): void } /** - * @dataProvider jsonValuesProviderWithoutString - * * pointer: a JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute]. */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testPointerMustBeAString(mixed $input): void { $object = new \stdClass(); @@ -101,10 +100,9 @@ public function testPointerMustBeAString(mixed $input): void } /** - * @dataProvider jsonValuesProviderWithoutString - * * parameter: a string indicating which query parameter caused the error. */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testParameterMustBeAString(mixed $input): void { $object = new \stdClass(); diff --git a/tests/Unit/V1/ErrorTest.php b/tests/Unit/V1/ErrorTest.php index 0030f5b..c3c9b22 100644 --- a/tests/Unit/V1/ErrorTest.php +++ b/tests/Unit/V1/ErrorTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\Error; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ErrorTest extends TestCase @@ -80,9 +81,7 @@ public function testCreateWithObjectReturnsSelf(): void $error->get('something'); } - /** - * @dataProvider jsonValuesProviderWithoutObject - */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); @@ -93,9 +92,7 @@ public function testCreateWithoutObjectThrowsException(mixed $input): void $error = new Error($input, $this->manager, $this->parent); } - /** - * @dataProvider jsonValuesProviderWithoutString - */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testCreateIdWithoutStringThrowsException(mixed $input): void { $object = new \stdClass(); @@ -109,9 +106,7 @@ public function testCreateIdWithoutStringThrowsException(mixed $input): void $error = new Error($object, $this->manager, $this->parent); } - /** - * @dataProvider jsonValuesProviderWithoutString - */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testCreateStatusWithoutStringThrowsException(mixed $input): void { $object = new \stdClass(); @@ -125,9 +120,7 @@ public function testCreateStatusWithoutStringThrowsException(mixed $input): void $error = new Error($object, $this->manager, $this->parent); } - /** - * @dataProvider jsonValuesProviderWithoutString - */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testCreateCodeWithoutStringThrowsException(mixed $input): void { $object = new \stdClass(); @@ -141,9 +134,7 @@ public function testCreateCodeWithoutStringThrowsException(mixed $input): void $error = new Error($object, $this->manager, $this->parent); } - /** - * @dataProvider jsonValuesProviderWithoutString - */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testCreateTitleWithoutStringThrowsException(mixed $input): void { $object = new \stdClass(); @@ -157,9 +148,7 @@ public function testCreateTitleWithoutStringThrowsException(mixed $input): void $error = new Error($object, $this->manager, $this->parent); } - /** - * @dataProvider jsonValuesProviderWithoutString - */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testCreateDetailWithoutStringThrowsException(mixed $input): void { $object = new \stdClass(); diff --git a/tests/Unit/V1/FactoryTest.php b/tests/Unit/V1/FactoryTest.php index ea2b356..1294809 100644 --- a/tests/Unit/V1/FactoryTest.php +++ b/tests/Unit/V1/FactoryTest.php @@ -19,9 +19,6 @@ class FactoryTest extends TestCase { - /** - * @test - */ public function testInjectACustomClass(): void { $factory = new Factory([ diff --git a/tests/Unit/V1/JsonapiTest.php b/tests/Unit/V1/JsonapiTest.php index b0be61a..6e26e38 100644 --- a/tests/Unit/V1/JsonapiTest.php +++ b/tests/Unit/V1/JsonapiTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\Jsonapi; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class JsonapiTest extends TestCase @@ -70,10 +71,9 @@ public function testCreateWithObject(): void } /** - * @dataProvider jsonValuesProviderWithoutObject - * * If present, the value of the jsonapi member MUST be an object (a "jsonapi object"). */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithDataprovider(mixed $input): void { $this->expectException(ValidationException::class); @@ -85,10 +85,9 @@ public function testCreateWithDataprovider(mixed $input): void } /** - * @dataProvider jsonValuesProvider - * * The jsonapi object MAY contain a version member whose value is a string */ + #[DataProvider('jsonValuesProvider')] public function testVersionCannotBeAnObjectOrArray(mixed $input): void { $object = new \stdClass(); diff --git a/tests/Unit/V1/LinkTest.php b/tests/Unit/V1/LinkTest.php index 677bb37..39442ac 100644 --- a/tests/Unit/V1/LinkTest.php +++ b/tests/Unit/V1/LinkTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\Link; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class LinkTest extends TestCase @@ -63,11 +64,10 @@ public function testCreateWithObject(): void } /** - * @dataProvider jsonValuesProvider - * * - an object ("link object") which can contain the following members: * - href: a string containing the link's URL. */ + #[DataProvider('jsonValuesProvider')] public function testHrefHasToBeAString(mixed $input): void { $object = new \stdClass(); @@ -125,10 +125,9 @@ public function testMetaIsParsedAsObject(): void } /** - * @dataProvider jsonValuesProviderWithoutObject - * * The value of each links member MUST be an object (a "links object"). */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithDataprovider(mixed $input): void { $this->expectException(ValidationException::class); diff --git a/tests/Unit/V1/MetaTest.php b/tests/Unit/V1/MetaTest.php index 3bc87d7..defdb04 100644 --- a/tests/Unit/V1/MetaTest.php +++ b/tests/Unit/V1/MetaTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\Meta; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class MetaTest extends TestCase @@ -76,10 +77,9 @@ public function testCreateWithObject(): void } /** - * @dataProvider jsonValuesProviderWithoutObject - * * The value of each meta member MUST be an object (a "meta object"). */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); diff --git a/tests/Unit/V1/RelationshipCollectionTest.php b/tests/Unit/V1/RelationshipCollectionTest.php index fe44aea..9982184 100644 --- a/tests/Unit/V1/RelationshipCollectionTest.php +++ b/tests/Unit/V1/RelationshipCollectionTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\RelationshipCollection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class RelationshipCollectionTest extends TestCase @@ -158,9 +159,7 @@ public function testCreateWithAuthorInRelationshipsAndAttributesThrowsException( $collection = new RelationshipCollection($object, $this->manager, $item); } - /** - * @dataProvider jsonValuesProviderWithoutObject - */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); diff --git a/tests/Unit/V1/RelationshipLinkTest.php b/tests/Unit/V1/RelationshipLinkTest.php index aaea75a..2962623 100644 --- a/tests/Unit/V1/RelationshipLinkTest.php +++ b/tests/Unit/V1/RelationshipLinkTest.php @@ -14,6 +14,7 @@ use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\ResourceIdentifierCollection; use Art4\JsonApiClient\V1\RelationshipLink; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class RelationshipLinkTest extends TestCase @@ -200,10 +201,9 @@ public function testPaginationNotParsedIfRelationshipIdentifierCollectionNotExis } /** - * @dataProvider jsonValuesProviderWithoutObject - * * links: a links object containing at least one of the following: */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); @@ -215,10 +215,9 @@ public function testCreateWithoutObjectThrowsException(mixed $input): void } /** - * @dataProvider jsonValuesProviderWithoutObjectAndString - * * test create without object or string attribute throws exception */ + #[DataProvider('jsonValuesProviderWithoutObjectAndString')] public function testCreateWithoutObjectOrStringAttributeThrowsException(mixed $input): void { $object = new \stdClass(); @@ -251,10 +250,9 @@ public function testCreateWithoutSelfAndRelatedPropertiesThrowsException(): void } /** - * @dataProvider jsonValuesProviderWithoutObjectAndString - * * self: a link for the relationship itself (a "relationship link"). */ + #[DataProvider('jsonValuesProviderWithoutObjectAndString')] public function testSelfMustBeAStringOrObject(mixed $input): void { $object = new \stdClass(); @@ -269,11 +267,10 @@ public function testSelfMustBeAStringOrObject(mixed $input): void } /** - * @dataProvider jsonValuesProviderWithoutObjectAndString - * * related: a related resource link when the primary data represents a resource relationship. * If present, a related resource link MUST reference a valid URL */ + #[DataProvider('jsonValuesProviderWithoutObjectAndString')] public function testRelatedMustBeAStringOrObject(mixed $input): void { $object = new \stdClass(); @@ -288,10 +285,9 @@ public function testRelatedMustBeAStringOrObject(mixed $input): void } /** - * @dataProvider jsonValuesProvider - * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. */ + #[DataProvider('jsonValuesProvider')] public function testFirstCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); @@ -327,10 +323,9 @@ public function testFirstCanBeAStringOrNull(mixed $input): void } /** - * @dataProvider jsonValuesProvider - * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. */ + #[DataProvider('jsonValuesProvider')] public function testLastCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); @@ -366,10 +361,9 @@ public function testLastCanBeAStringOrNull(mixed $input): void } /** - * @dataProvider jsonValuesProvider - * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. */ + #[DataProvider('jsonValuesProvider')] public function testPrevCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); @@ -405,10 +399,9 @@ public function testPrevCanBeAStringOrNull(mixed $input): void } /** - * @dataProvider jsonValuesProvider - * * Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. */ + #[DataProvider('jsonValuesProvider')] public function testNextCanBeAStringOrNull(mixed $input): void { $object = new \stdClass(); @@ -443,9 +436,6 @@ public function testNextCanBeAStringOrNull(mixed $input): void $link = new RelationshipLink($object, $this->manager, $this->relationship); } - /** - * @test - */ public function testGetOnANonExistingKeyThrowsException(): void { $object = new \stdClass(); diff --git a/tests/Unit/V1/RelationshipTest.php b/tests/Unit/V1/RelationshipTest.php index f31cac1..3a28544 100644 --- a/tests/Unit/V1/RelationshipTest.php +++ b/tests/Unit/V1/RelationshipTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\Relationship; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class RelationshipTest extends TestCase @@ -59,10 +60,9 @@ public function testCreateWithObjectReturnsSelf(): void } /** - * @dataProvider jsonValuesProviderWithoutObject - * * The value of the relationships key MUST be an object (a "relationships object"). */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); diff --git a/tests/Unit/V1/ResourceCollectionTest.php b/tests/Unit/V1/ResourceCollectionTest.php index 3a6d0a1..30cd6f8 100644 --- a/tests/Unit/V1/ResourceCollectionTest.php +++ b/tests/Unit/V1/ResourceCollectionTest.php @@ -14,6 +14,7 @@ use Art4\JsonApiClient\Helper\AccessKey; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\ResourceCollection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ResourceCollectionTest extends TestCase @@ -133,9 +134,7 @@ public function testCreateWithItem(): void $this->assertInstanceOf(Accessable::class, $resource); } - /** - * @dataProvider jsonValuesProviderWithoutArray - */ + #[DataProvider('jsonValuesProviderWithoutArray')] public function testCreateWithoutArrayThrowsException(mixed $input): void { $this->expectException(ValidationException::class); @@ -146,9 +145,7 @@ public function testCreateWithoutArrayThrowsException(mixed $input): void $collection = new ResourceCollection($input, $this->manager, $this->parent); } - /** - * @dataProvider jsonValuesProviderWithoutObject - */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithoutObjectInArrayThrowsException(mixed $input): void { $this->expectException(ValidationException::class); diff --git a/tests/Unit/V1/ResourceIdentifierCollectionTest.php b/tests/Unit/V1/ResourceIdentifierCollectionTest.php index 2684a72..805537a 100644 --- a/tests/Unit/V1/ResourceIdentifierCollectionTest.php +++ b/tests/Unit/V1/ResourceIdentifierCollectionTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\ResourceIdentifierCollection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ResourceIdentifierCollectionTest extends TestCase @@ -95,9 +96,7 @@ public function testCreateWithItem(): void $this->assertInstanceOf(Accessable::class, $resource); } - /** - * @dataProvider jsonValuesProviderWithoutArray - */ + #[DataProvider('jsonValuesProviderWithoutArray')] public function testCreateWithoutArrayThrowsException(mixed $input): void { $this->expectException(ValidationException::class); diff --git a/tests/Unit/V1/ResourceIdentifierTest.php b/tests/Unit/V1/ResourceIdentifierTest.php index f8e0a50..c0867f7 100644 --- a/tests/Unit/V1/ResourceIdentifierTest.php +++ b/tests/Unit/V1/ResourceIdentifierTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\ResourceIdentifier; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ResourceIdentifierTest extends TestCase @@ -72,10 +73,9 @@ public function testCreateWithObjectAndMeta(): void } /** - * @dataProvider jsonValuesProviderWithoutString - * * The values of the id and type members MUST be strings. */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testTypeMustBeAString(mixed $input): void { $object = new \stdClass(); @@ -93,10 +93,9 @@ public function testTypeMustBeAString(mixed $input): void } /** - * @dataProvider jsonValuesProviderWithoutString - * * The values of the id and type members MUST be strings. */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testIdMustBeAString(mixed $input): void { $object = new \stdClass(); @@ -112,11 +111,10 @@ public function testIdMustBeAString(mixed $input): void } /** - * @dataProvider jsonValuesProviderWithoutObject - * * A "resource identifier object" is an object that identifies an individual resource. * A "resource identifier object" MUST contain type and id members. */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithDataproviderThrowsException(mixed $input): void { $this->expectException(ValidationException::class); diff --git a/tests/Unit/V1/ResourceItemLinkTest.php b/tests/Unit/V1/ResourceItemLinkTest.php index baa5246..c45b83c 100644 --- a/tests/Unit/V1/ResourceItemLinkTest.php +++ b/tests/Unit/V1/ResourceItemLinkTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\ResourceItemLink; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ResourceItemLinkTest extends TestCase @@ -55,10 +56,9 @@ public function testParsingPropertiesExists(): void } /** - * @dataProvider jsonValuesProviderWithoutObject - * * links: a links object related to the primary data. */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithoutObjectThrowsException(mixed $input): void { $this->expectException(ValidationException::class); @@ -70,10 +70,9 @@ public function testCreateWithoutObjectThrowsException(mixed $input): void } /** - * @dataProvider jsonValuesProviderWithoutObjectAndString - * * test create without object or string attribute throws exception */ + #[DataProvider('jsonValuesProviderWithoutObjectAndString')] public function testCreateWithoutObjectOrStringAttributeThrowsException(mixed $input): void { $object = new \stdClass(); @@ -87,9 +86,6 @@ public function testCreateWithoutObjectOrStringAttributeThrowsException(mixed $i $link = new ResourceItemLink($object, $this->manager, $this->parent); } - /** - * @test - */ public function testGetOnANonExistingKeyThrowsException(): void { $object = new \stdClass(); diff --git a/tests/Unit/V1/ResourceItemTest.php b/tests/Unit/V1/ResourceItemTest.php index a4c7bbe..44030be 100644 --- a/tests/Unit/V1/ResourceItemTest.php +++ b/tests/Unit/V1/ResourceItemTest.php @@ -13,6 +13,7 @@ use Art4\JsonApiClient\Exception\ValidationException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\ResourceItem; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ResourceItemTest extends TestCase @@ -96,10 +97,9 @@ public function testCreateWithFullObject(): void } /** - * @dataProvider jsonValuesProviderWithoutString - * * The values of the id and type members MUST be strings. */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testTypeMustBeAString(mixed $input): void { $object = new \stdClass(); @@ -115,10 +115,9 @@ public function testTypeMustBeAString(mixed $input): void } /** - * @dataProvider jsonValuesProviderWithoutString - * * The values of the id and type members MUST be strings. */ + #[DataProvider('jsonValuesProviderWithoutString')] public function testIdMustBeAString(mixed $input): void { $object = new \stdClass(); @@ -134,11 +133,10 @@ public function testIdMustBeAString(mixed $input): void } /** - * @dataProvider jsonValuesProviderWithoutObject - * * A "resource object" is an object that identifies an individual resource. * A "resource object" MUST contain type and id members. */ + #[DataProvider('jsonValuesProviderWithoutObject')] public function testCreateWithDataproviderThrowsException(mixed $input): void { $this->expectException(ValidationException::class); diff --git a/tests/Unit/V1/ResourceNullTest.php b/tests/Unit/V1/ResourceNullTest.php index fa80032..e350356 100644 --- a/tests/Unit/V1/ResourceNullTest.php +++ b/tests/Unit/V1/ResourceNullTest.php @@ -12,6 +12,7 @@ use Art4\JsonApiClient\Exception\AccessException; use Art4\JsonApiClient\Tests\Fixtures\HelperTrait; use Art4\JsonApiClient\V1\ResourceNull; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ResourceNullTest extends TestCase @@ -29,9 +30,7 @@ public function setUp(): void $this->parent = $this->createMock(Accessable::class); } - /** - * @dataProvider jsonValuesProvider - */ + #[DataProvider('jsonValuesProvider')] public function testCreateWithDataProvider(mixed $input): void { $resource = new ResourceNull(