diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml new file mode 100644 index 0000000..728fa56 --- /dev/null +++ b/.github/workflows/code-style.yml @@ -0,0 +1,37 @@ +name: Code style + +on: + push: + pull_request: + +jobs: + + check-code-style: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: ['8.2'] + + name: "Check code style | PHP ${{ matrix.php }}" + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install PHP with latest composer + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + ini-values: error_reporting=-1, display_errors=On, log_errors_max_len=0 + coverage: none + tools: none + + # Install dependencies and handle caching in one go. + # @link https://github.com/marketplace/actions/install-composer-dependencies + - name: "Install Composer dependencies" + uses: "ramsey/composer-install@v2" + + - name: "Check code style" + run: composer run codestyle -- --dry-run diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index e159e9f..6de33d4 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -11,7 +11,13 @@ return (new PhpCsFixer\Config()) ->setRules([ - '@PSR12' => true, + '@PER-CS2.0' => true, + '@PER-CS2.0:risky' => true, + '@PHP74Migration' => true, + '@PHP74Migration:risky' => true, + '@PHPUnit84Migration:risky' => true, + 'no_alias_functions' => true, ]) ->setFinder($finder) + ->setRiskyAllowed(true) ; diff --git a/README.md b/README.md index 1325e1a..8954472 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recen ## :wrench: Contributing -Please feel free to fork and sending Pull Requests. This project follows [Semantic Versioning 2](http://semver.org) and [PSR-2](http://www.php-fig.org/psr/psr-2/). +Please feel free to fork and sending Pull Requests. This project follows [Semantic Versioning 2](http://semver.org) and [PER-CS2.0](https://www.php-fig.org/per/coding-style/). This projects comes with a `docker-compose.yml` where all tools for development are available. diff --git a/composer.json b/composer.json index 99c926e..82738e1 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.2", + "friendsofphp/php-cs-fixer": "^3.35", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9 || ^10" }, @@ -31,6 +31,7 @@ } }, "scripts": { + "codestyle": "php-cs-fixer fix --verbose --diff", "coverage": "phpunit --coverage-html=\".phpunit.cache/code-coverage\"", "phpstan": "phpstan analyze --memory-limit 512M --configuration .phpstan.neon", "phpunit": "phpunit", diff --git a/src/Accessable.php b/src/Accessable.php index 7fe7b13..ec46ab1 100644 --- a/src/Accessable.php +++ b/src/Accessable.php @@ -1,5 +1,7 @@ 'JSON_ERROR_STATE_MISMATCH - Underflow or the modes mismatch', \JSON_ERROR_CTRL_CHAR => 'JSON_ERROR_CTRL_CHAR - Unexpected control character found', \JSON_ERROR_SYNTAX => 'JSON_ERROR_SYNTAX - Syntax error, malformed JSON', - \JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded' + \JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded', ]; // use JSON_BIGINT_AS_STRING diff --git a/src/Manager.php b/src/Manager.php index 92de711..b22dde4 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -1,5 +1,7 @@ createMock(Manager::class); @@ -30,9 +32,7 @@ public function testBcForElementInterface() * * @param mixed $data The data for this Element */ - public function __construct($data, Manager $manager, Accessable $parent) - { - } + public function __construct($data, Manager $manager, Accessable $parent) {} }; $this->assertInstanceOf(Element::class, $class); diff --git a/tests/BC/Exception/ExceptionTest.php b/tests/BC/Exception/ExceptionTest.php index 4ee7f01..c84d828 100644 --- a/tests/BC/Exception/ExceptionTest.php +++ b/tests/BC/Exception/ExceptionTest.php @@ -1,5 +1,7 @@ assertInstanceOf(Exception::class, $class); } diff --git a/tests/BC/FactoryTest.php b/tests/BC/FactoryTest.php index c6fe5a6..beb1ecd 100644 --- a/tests/BC/FactoryTest.php +++ b/tests/BC/FactoryTest.php @@ -1,5 +1,7 @@ assertInstanceOf(RequestInput::class, $class); } diff --git a/tests/BC/ManagerTest.php b/tests/BC/ManagerTest.php index 8af9586..34005a8 100644 --- a/tests/BC/ManagerTest.php +++ b/tests/BC/ManagerTest.php @@ -1,5 +1,7 @@ getJsonString('09_errors.json'); $document = Parser::parseResponseString($string); @@ -90,7 +92,7 @@ public function testParseErrors() /** * @test */ - public function testParseErrorWithLinks() + public function testParseErrorWithLinks(): void { $string = $this->getJsonString('10_error_with_links.json'); $document = Parser::parseResponseString($string); diff --git a/tests/Functional/ParsingTest.php b/tests/Functional/ParsingTest.php index 43b9aad..40565e1 100644 --- a/tests/Functional/ParsingTest.php +++ b/tests/Functional/ParsingTest.php @@ -1,5 +1,7 @@ getJsonString('01_simple_resource.json'); $document = $parser($string); @@ -69,7 +71,7 @@ public function testParseSimpleResourceWithDifferentParser($parser) /** * @test */ - public function testParseSimpleResourceIdentifier() + public function testParseSimpleResourceIdentifier(): void { $string = $this->getJsonString('02_simple_resource_identifier.json'); $document = Parser::parseResponseString($string); @@ -93,7 +95,7 @@ public function testParseSimpleResourceIdentifier() /** * @test */ - public function testParseResourceObject() + public function testParseResourceObject(): void { $string = $this->getJsonString('03_resource_object.json'); $document = Parser::parseResponseString($string); @@ -161,7 +163,7 @@ public function testParseResourceObject() /** * @test */ - public function testParseCompleteResourceObjectWithMultipleRelationships() + public function testParseCompleteResourceObjectWithMultipleRelationships(): void { $string = $this->getJsonString('04_complete_document_with_multiple_relationships.json'); $document = Parser::parseResponseString($string); @@ -336,7 +338,7 @@ public function testParseCompleteResourceObjectWithMultipleRelationships() /** * @test */ - public function testParsePaginationExample() + public function testParsePaginationExample(): void { $string = $this->getJsonString('06_pagination_example.json'); $document = Parser::parseResponseString($string); @@ -390,7 +392,7 @@ public function testParsePaginationExample() /** * @test */ - public function testParseRelationshipExample() + public function testParseRelationshipExample(): void { $string = $this->getJsonString('07_relationship_example_without_data.json'); $document = Parser::parseResponseString($string); @@ -456,7 +458,7 @@ public function testParseRelationshipExample() /** * @test */ - public function testParseObjectLinksExample() + public function testParseObjectLinksExample(): void { $string = $this->getJsonString('08_object_links.json'); $document = Parser::parseResponseString($string); @@ -499,7 +501,7 @@ public function testParseObjectLinksExample() /** * @test */ - public function testParseResourceIdentifierWithMeta() + public function testParseResourceIdentifierWithMeta(): void { $string = $this->getJsonString('11_resource_identifier_with_meta.json'); $document = Parser::parseResponseString($string); @@ -525,7 +527,7 @@ public function testParseResourceIdentifierWithMeta() /** * @test */ - public function testParseNullResource() + public function testParseNullResource(): void { $string = $this->getJsonString('12_null_resource.json'); $document = Parser::parseResponseString($string); @@ -546,7 +548,7 @@ public function testParseNullResource() /** * @test */ - public function testParseResourceIdentifierCollectionWithMeta() + public function testParseResourceIdentifierCollectionWithMeta(): void { $string = $this->getJsonString('13_collection_with_resource_identifier_with_meta.json'); $document = Parser::parseResponseString($string); @@ -583,7 +585,7 @@ public function testParseResourceIdentifierCollectionWithMeta() /** * @test */ - public function testParseCreateResourceWithoutId() + public function testParseCreateResourceWithoutId(): void { $string = $this->getJsonString('14_create_resource_without_id.json'); $document = Parser::parseRequestString($string); @@ -595,7 +597,7 @@ public function testParseCreateResourceWithoutId() /** * @test */ - public function testParseCreateShortResourceWithoutId() + public function testParseCreateShortResourceWithoutId(): void { $string = $this->getJsonString('15_create_resource_without_id.json'); $document = Parser::parseRequestString($string); @@ -607,7 +609,7 @@ public function testParseCreateShortResourceWithoutId() /** * @test */ - public function testExceptionIfIdIsNotString() + public function testExceptionIfIdIsNotString(): void { $this->expectException(\Art4\JsonApiClient\Exception\ValidationException::class); $string = $this->getJsonString('16_type_and_id_as_integer.json'); @@ -617,7 +619,7 @@ public function testExceptionIfIdIsNotString() /** * @test */ - public function testParseLinksInRelationshipsCorrectly() + public function testParseLinksInRelationshipsCorrectly(): void { $string = $this->getJsonString('17_relationship_links.json'); $document = Parser::parseResponseString($string); diff --git a/tests/Functional/SerializerTest.php b/tests/Functional/SerializerTest.php index f4ddb2d..f96c043 100644 --- a/tests/Functional/SerializerTest.php +++ b/tests/Functional/SerializerTest.php @@ -1,5 +1,7 @@ in_array($filename, $requestFiles) + 'is_request' => in_array($filename, $requestFiles), ], ]; } @@ -58,7 +60,7 @@ public static function jsonapiDataProvider(): array * * @param mixed $filename */ - public function parseJsonapiDataWithErrorAbortManager($filename, array $meta) + public function parseJsonapiDataWithErrorAbortManager($filename, array $meta): void { $manager = new ErrorAbortManager(new Factory()); diff --git a/tests/Unit/Helper/ParserTest.php b/tests/Unit/Helper/ParserTest.php index 084bbff..4642729 100644 --- a/tests/Unit/Helper/ParserTest.php +++ b/tests/Unit/Helper/ParserTest.php @@ -1,5 +1,7 @@ expectException(InputException::class); $this->expectExceptionMessage( @@ -46,7 +48,7 @@ public function testCreateWithoutStringThrowsException($input) * * @param string $input */ - public function testGetAsObjectWithInvalidStringsThrowsException(string $input) + 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 4087c4a..c554f1b 100644 --- a/tests/Unit/Input/ResponseStringInputTest.php +++ b/tests/Unit/Input/ResponseStringInputTest.php @@ -1,5 +1,7 @@ expectException(InputException::class); $this->expectExceptionMessage( @@ -46,7 +48,7 @@ public function testCreateWithoutStringThrowsException($input) * * @param string $input */ - public function testGetAsObjectWithInvalidStringsThrowsException(string $input) + 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 b3e8ee3..9cae683 100644 --- a/tests/Unit/Manager/ErrorAbortManagerTest.php +++ b/tests/Unit/Manager/ErrorAbortManagerTest.php @@ -1,5 +1,7 @@ createMock(Factory::class); $manager = new ErrorAbortManager($factory); @@ -26,7 +28,7 @@ public function testCreateWithConstructorReturnsSelf() /** * @test */ - public function testGetParamReturnsDefault() + public function testGetParamReturnsDefault(): void { $factory = $this->createMock(Factory::class); $manager = new ErrorAbortManager($factory); diff --git a/tests/Unit/Serializer/ArraySerializerTest.php b/tests/Unit/Serializer/ArraySerializerTest.php index 85ee62a..e4b165c 100644 --- a/tests/Unit/Serializer/ArraySerializerTest.php +++ b/tests/Unit/Serializer/ArraySerializerTest.php @@ -1,5 +1,7 @@ createMock(Accessable::class); $object2 = new \stdClass(); @@ -56,7 +58,7 @@ public function testSerialize() /** * @test recursive serialize() */ - public function testRecursiveSerialize() + public function testRecursiveSerialize(): void { $stdObject = new \stdClass(); $stdObject->key = 'value'; diff --git a/tests/Unit/V1/AttributesTest.php b/tests/Unit/V1/AttributesTest.php index 1d03205..865197c 100644 --- a/tests/Unit/V1/AttributesTest.php +++ b/tests/Unit/V1/AttributesTest.php @@ -1,5 +1,7 @@ object = new \stdClass(); @@ -51,15 +53,15 @@ public function testCreateWithObject() $this->assertInstanceOf(Accessable::class, $attributes); $this->assertTrue($attributes->has('object')); - $this->assertTrue(is_object($attributes->get('object'))); + $this->assertIsObject($attributes->get('object')); $this->assertTrue($attributes->has('array')); - $this->assertTrue(is_array($attributes->get('array'))); + $this->assertIsArray($attributes->get('array')); $this->assertTrue($attributes->has('string')); - $this->assertTrue(is_string($attributes->get('string'))); + $this->assertIsString($attributes->get('string')); $this->assertTrue($attributes->has('number_int')); - $this->assertTrue(is_int($attributes->get('number_int'))); + $this->assertIsInt($attributes->get('number_int')); $this->assertTrue($attributes->has('number_float')); - $this->assertTrue(is_float($attributes->get('number_float'))); + $this->assertIsFloat($attributes->get('number_float')); $this->assertTrue($attributes->has('true')); $this->assertTrue($attributes->get('true')); $this->assertTrue($attributes->has('false')); @@ -74,7 +76,7 @@ public function testCreateWithObject() 'number_float', 'true', 'false', - 'null' + 'null', ], $attributes->getKeys()); } @@ -83,7 +85,7 @@ public function testCreateWithObject() * * @param mixed $input */ - public function testCreateWithDataProvider($input) + public function testCreateWithDataProvider($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -102,7 +104,7 @@ public function testCreateWithDataProvider($input) * * These properties are not allowed in attributes: `type`, `id`, `relationships`, `links` */ - public function testCreateWithTypePropertyThrowsException() + public function testCreateWithTypePropertyThrowsException(): void { $object = new \stdClass(); $object->type = 'posts'; @@ -124,7 +126,7 @@ public function testCreateWithTypePropertyThrowsException() * * These properties are not allowed in attributes: `type`, `id`, `relationships`, `links` */ - public function testCreateWithIdPropertyThrowsException() + public function testCreateWithIdPropertyThrowsException(): void { $object = new \stdClass(); $object->id = '5'; @@ -146,7 +148,7 @@ public function testCreateWithIdPropertyThrowsException() * * These properties are not allowed in attributes: `type`, `id`, `relationships`, `links` */ - public function testCreateWithRelationshipsPropertyThrowsException() + public function testCreateWithRelationshipsPropertyThrowsException(): void { $object = new \stdClass(); $object->relationships = new \stdClass(); @@ -168,7 +170,7 @@ public function testCreateWithRelationshipsPropertyThrowsException() * * These properties are not allowed in attributes: `type`, `id`, `relationships`, `links` */ - public function testCreateWithLinksPropertyThrowsException() + public function testCreateWithLinksPropertyThrowsException(): void { $object = new \stdClass(); $object->links = new \stdClass(); @@ -189,7 +191,7 @@ public function testCreateWithLinksPropertyThrowsException() /** * @test */ - public function testGetOnANonExistingKeyThrowsException() + public function testGetOnANonExistingKeyThrowsException(): void { $object = new \stdClass(); $object->pages = '1126'; diff --git a/tests/Unit/V1/DocumentLinkTest.php b/tests/Unit/V1/DocumentLinkTest.php index 7583f9a..6227032 100644 --- a/tests/Unit/V1/DocumentLinkTest.php +++ b/tests/Unit/V1/DocumentLinkTest.php @@ -1,5 +1,7 @@ self = 'http://example.org/self'; @@ -65,7 +67,7 @@ public function testOnlySelfRelatedPaginationPropertiesExists() 'prev', 'next', 'custom', - 'meta' + 'meta', ], $link->getKeys()); $this->assertTrue($link->has('custom')); @@ -93,7 +95,7 @@ public function testOnlySelfRelatedPaginationPropertiesExists() * * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input) + public function testCreateWithoutObjectThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -110,7 +112,7 @@ public function testCreateWithoutObjectThrowsException($input) * * @param mixed $input */ - public function testCreateWithoutObjectOrStringAttributeThrowsException($input) + public function testCreateWithoutObjectOrStringAttributeThrowsException($input): void { $object = new \stdClass(); $object->self = 'http://example.org/self'; @@ -131,7 +133,7 @@ public function testCreateWithoutObjectOrStringAttributeThrowsException($input) * * @param mixed $input */ - public function testSelfMustBeAStringOrObject($input) + public function testSelfMustBeAStringOrObject($input): void { $object = new \stdClass(); $object->self = $input; @@ -163,7 +165,7 @@ public function testSelfMustBeAStringOrObject($input) * * @param mixed $input */ - public function testRelatedMustBeAStringOrObject($input) + public function testRelatedMustBeAStringOrObject($input): void { $object = new \stdClass(); $object->related = $input; @@ -183,7 +185,7 @@ public function testRelatedMustBeAStringOrObject($input) * * @param mixed $input */ - public function testFirstCanBeAnObjectOrStringOrNull($input) + public function testFirstCanBeAnObjectOrStringOrNull($input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -233,7 +235,7 @@ public function testFirstCanBeAnObjectOrStringOrNull($input) * * @param mixed $input */ - public function testLastCanBeAStringOrNull($input) + public function testLastCanBeAStringOrNull($input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -283,7 +285,7 @@ public function testLastCanBeAStringOrNull($input) * * @param mixed $input */ - public function testPrevCanBeAStringOrNull($input) + public function testPrevCanBeAStringOrNull($input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -333,7 +335,7 @@ public function testPrevCanBeAStringOrNull($input) * * @param mixed $input */ - public function testNextCanBeAStringOrNull($input) + public function testNextCanBeAStringOrNull($input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -379,7 +381,7 @@ public function testNextCanBeAStringOrNull($input) /** * @test */ - public function testGetOnANonExistingKeyThrowsException() + public function testGetOnANonExistingKeyThrowsException(): void { $object = new \stdClass(); $object->self = 'http://example.org/self'; diff --git a/tests/Unit/V1/DocumentTest.php b/tests/Unit/V1/DocumentTest.php index 57588ae..5a8e949 100644 --- a/tests/Unit/V1/DocumentTest.php +++ b/tests/Unit/V1/DocumentTest.php @@ -1,5 +1,7 @@ meta = new \stdClass(); @@ -54,7 +56,7 @@ public function testCreateWithObjectReturnsSelf() /** * @test create with all possible values */ - public function testCreateWithAllPossibleValues() + public function testCreateWithAllPossibleValues(): void { $object = new \stdClass(); $object->data = new \stdClass(); @@ -89,7 +91,7 @@ public function testCreateWithAllPossibleValues() * * @param mixed $input */ - public function testCreateWithDataproviderThrowsException($input) + public function testCreateWithDataproviderThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -104,7 +106,7 @@ public function testCreateWithDataproviderThrowsException($input) * * A document MUST contain at least one of the following top-level members: data, errors, meta */ - public function testCreateWithoutAnyToplevelMemberThrowsException() + public function testCreateWithoutAnyToplevelMemberThrowsException(): void { $object = new \stdClass(); @@ -124,7 +126,7 @@ public function testCreateWithoutAnyToplevelMemberThrowsException() * - a single resource object, a single resource identifier object, or null, for requests that target single resources * - an array of resource objects, an array of resource identifier objects, or an empty array ([]), for requests that target resource collections */ - public function testCreateDataWithResourceIdentifier() + public function testCreateDataWithResourceIdentifier(): void { $data = new \stdClass(); $data->type = 'posts'; @@ -144,7 +146,7 @@ public function testCreateDataWithResourceIdentifier() /** * @test create with data resource identifier and meta */ - public function testCreateDataWithResourceIdentifierAndMeta() + public function testCreateDataWithResourceIdentifierAndMeta(): void { $data = new \stdClass(); $data->type = 'posts'; @@ -165,7 +167,7 @@ public function testCreateDataWithResourceIdentifierAndMeta() /** * @test create with data resource item */ - public function testCreateDataWithResourceItem() + public function testCreateDataWithResourceItem(): void { $data = new \stdClass(); $data->type = 'posts'; @@ -187,7 +189,7 @@ public function testCreateDataWithResourceItem() /** * @test create with data object array */ - public function testCreateDataWithResourceCollectionIdentifiers() + public function testCreateDataWithResourceCollectionIdentifiers(): void { $data_obj = new \stdClass(); $data_obj->type = 'types'; @@ -207,7 +209,7 @@ public function testCreateDataWithResourceCollectionIdentifiers() /** * @test create with data object array advanced */ - public function testCreateDataWithResourceCollectionResources() + public function testCreateDataWithResourceCollectionResources(): void { $data_obj = new \stdClass(); $data_obj->type = 'types'; @@ -233,7 +235,7 @@ public function testCreateDataWithResourceCollectionResources() * * @param mixed $input */ - public function testCreateWithDataproviderInValue($input) + public function testCreateWithDataproviderInValue($input): void { // Test with empty array in data @@ -282,7 +284,7 @@ public function testCreateWithDataproviderInValue($input) /** * @test create with an errors array */ - public function testCreateWithErrorsArray() + public function testCreateWithErrorsArray(): void { $object = new \stdClass(); $object->errors = [ @@ -302,7 +304,7 @@ public function testCreateWithErrorsArray() /** * @test The members `data` and `errors` MUST NOT coexist in the same document. */ - public function testCreateWithDataAndErrorsThrowsException() + public function testCreateWithDataAndErrorsThrowsException(): void { $object = new \stdClass(); $object->data = new \stdClass(); @@ -319,7 +321,7 @@ public function testCreateWithDataAndErrorsThrowsException() /** * @test create with meta object */ - public function testCreateWithMetaObject() + public function testCreateWithMetaObject(): void { $object = new \stdClass(); $object->meta = new \stdClass(); @@ -335,7 +337,7 @@ public function testCreateWithMetaObject() /** * @test create with Jsonapi object */ - public function testCreateWithJsonapiObject() + public function testCreateWithJsonapiObject(): void { $object = new \stdClass(); @@ -353,7 +355,7 @@ public function testCreateWithJsonapiObject() /** * @test create with link object */ - public function testCreateWithLinkObject() + public function testCreateWithLinkObject(): void { $object = new \stdClass(); @@ -371,7 +373,7 @@ public function testCreateWithLinkObject() /** * @test create with included objects */ - public function testCreateWithIncludedObjects() + public function testCreateWithIncludedObjects(): void { $data = new \stdClass(); $data->type = 'posts'; @@ -397,7 +399,7 @@ public function testCreateWithIncludedObjects() /** * @test If a document does not contain a top-level `data` key, the `included` member MUST NOT be present either. */ - public function testCreateIncludedWithoutDataThrowsException() + public function testCreateIncludedWithoutDataThrowsException(): void { $object = new \stdClass(); $object->included = new \stdClass(); @@ -414,7 +416,7 @@ public function testCreateIncludedWithoutDataThrowsException() /** * @test */ - public function testGetOnANonExistingKeyThrowsException() + public function testGetOnANonExistingKeyThrowsException(): void { $object = new \stdClass(); $object->meta = new \stdClass(); diff --git a/tests/Unit/V1/ErrorCollectionTest.php b/tests/Unit/V1/ErrorCollectionTest.php index eb6a376..31b2731 100644 --- a/tests/Unit/V1/ErrorCollectionTest.php +++ b/tests/Unit/V1/ErrorCollectionTest.php @@ -1,5 +1,7 @@ meta = new \stdClass(); @@ -63,7 +65,7 @@ public function testAllPropertiesExists() * - links: a links object containing the following members: * - about: a link that leads to further details about this particular occurrence of the problem. */ - public function testAboutMustBeSet() + public function testAboutMustBeSet(): void { $object = new \stdClass(); $object->foobar = new \stdClass(); @@ -83,7 +85,7 @@ public function testAboutMustBeSet() * - links: a links object containing the following members: * - about: a link that leads to further details about this particular occurrence of the problem. */ - public function testAboutCanBeAnObject() + public function testAboutCanBeAnObject(): void { $object = new \stdClass(); $object->about = new \stdClass(); @@ -104,7 +106,7 @@ public function testAboutCanBeAnObject() * * @param mixed $input */ - public function testCreateWithDataprovider($input) + public function testCreateWithDataprovider($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -121,7 +123,7 @@ public function testCreateWithDataprovider($input) * * @param mixed $input */ - public function testCreateWithoutObjectOrStringAttributeThrowsException($input) + public function testCreateWithoutObjectOrStringAttributeThrowsException($input): void { $object = new \stdClass(); $object->about = 'http://example.org/about'; @@ -142,7 +144,7 @@ public function testCreateWithoutObjectOrStringAttributeThrowsException($input) * * @param mixed $input */ - public function testAboutWithDataproviderThrowsException($input) + public function testAboutWithDataproviderThrowsException($input): void { $object = new \stdClass(); $object->about = $input; @@ -158,7 +160,7 @@ public function testAboutWithDataproviderThrowsException($input) /** * @test */ - public function testGetOnANonExistingKeyThrowsException() + public function testGetOnANonExistingKeyThrowsException(): void { $object = new \stdClass(); $object->about = 'http://example.org/about'; diff --git a/tests/Unit/V1/ErrorSourceTest.php b/tests/Unit/V1/ErrorSourceTest.php index 77dbce5..553a99e 100644 --- a/tests/Unit/V1/ErrorSourceTest.php +++ b/tests/Unit/V1/ErrorSourceTest.php @@ -1,5 +1,7 @@ pointer = '/pointer'; @@ -72,7 +74,7 @@ public function testOnlyPointerParameterPropertiesExists() * * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input) + public function testCreateWithoutObjectThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -89,7 +91,7 @@ public function testCreateWithoutObjectThrowsException($input) * * @param mixed $input */ - public function testPointerMustBeAString($input) + public function testPointerMustBeAString($input): void { $object = new \stdClass(); $object->pointer = $input; @@ -109,7 +111,7 @@ public function testPointerMustBeAString($input) * * @param mixed $input */ - public function testParameterMustBeAString($input) + public function testParameterMustBeAString($input): void { $object = new \stdClass(); $object->parameter = $input; diff --git a/tests/Unit/V1/ErrorTest.php b/tests/Unit/V1/ErrorTest.php index b41443e..a777c85 100644 --- a/tests/Unit/V1/ErrorTest.php +++ b/tests/Unit/V1/ErrorTest.php @@ -1,5 +1,7 @@ id = 'id'; @@ -83,7 +85,7 @@ public function testCreateWithObjectReturnsSelf() * * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input) + public function testCreateWithoutObjectThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -98,7 +100,7 @@ public function testCreateWithoutObjectThrowsException($input) * * @param mixed $input */ - public function testCreateIdWithoutStringThrowsException($input) + public function testCreateIdWithoutStringThrowsException($input): void { $object = new \stdClass(); $object->id = $input; @@ -116,7 +118,7 @@ public function testCreateIdWithoutStringThrowsException($input) * * @param mixed $input */ - public function testCreateStatusWithoutStringThrowsException($input) + public function testCreateStatusWithoutStringThrowsException($input): void { $object = new \stdClass(); $object->status = $input; @@ -134,7 +136,7 @@ public function testCreateStatusWithoutStringThrowsException($input) * * @param mixed $input */ - public function testCreateCodeWithoutStringThrowsException($input) + public function testCreateCodeWithoutStringThrowsException($input): void { $object = new \stdClass(); $object->code = $input; @@ -152,7 +154,7 @@ public function testCreateCodeWithoutStringThrowsException($input) * * @param mixed $input */ - public function testCreateTitleWithoutStringThrowsException($input) + public function testCreateTitleWithoutStringThrowsException($input): void { $object = new \stdClass(); $object->title = $input; @@ -170,7 +172,7 @@ public function testCreateTitleWithoutStringThrowsException($input) * * @param mixed $input */ - public function testCreateDetailWithoutStringThrowsException($input) + public function testCreateDetailWithoutStringThrowsException($input): void { $object = new \stdClass(); $object->detail = $input; diff --git a/tests/Unit/V1/FactoryTest.php b/tests/Unit/V1/FactoryTest.php index 5d1b6b0..ea2b356 100644 --- a/tests/Unit/V1/FactoryTest.php +++ b/tests/Unit/V1/FactoryTest.php @@ -1,5 +1,7 @@ ResourceNull::class, @@ -39,7 +41,7 @@ public function testInjectACustomClass() /** * @test parse throw Exception if input is invalid jsonapi */ - public function testMakeAnUndefindedClassThrowsException() + public function testMakeAnUndefindedClassThrowsException(): void { $factory = new Factory(); @@ -51,7 +53,7 @@ public function testMakeAnUndefindedClassThrowsException() $class = $factory->make('NotExistent'); } - public function testMakeWithClassNotImplementingAccessableThrowsException() + public function testMakeWithClassNotImplementingAccessableThrowsException(): void { $factory = new Factory([ 'Default' => stdClass::class, diff --git a/tests/Unit/V1/JsonapiTest.php b/tests/Unit/V1/JsonapiTest.php index 853dc02..ccbeb0a 100644 --- a/tests/Unit/V1/JsonapiTest.php +++ b/tests/Unit/V1/JsonapiTest.php @@ -1,5 +1,7 @@ version = '1.0'; @@ -74,7 +76,7 @@ public function testCreateWithObject() * * @param mixed $input */ - public function testCreateWithDataprovider($input) + public function testCreateWithDataprovider($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -91,7 +93,7 @@ public function testCreateWithDataprovider($input) * * @param mixed $input */ - public function testVersionCannotBeAnObjectOrArray($input) + public function testVersionCannotBeAnObjectOrArray($input): void { $object = new \stdClass(); $object->version = $input; @@ -114,6 +116,6 @@ public function testVersionCannotBeAnObjectOrArray($input) // other input must be transformed to string $this->assertTrue($jsonapi->has('version')); - $this->assertTrue(is_string($jsonapi->get('version'))); + $this->assertIsString($jsonapi->get('version')); } } diff --git a/tests/Unit/V1/LinkTest.php b/tests/Unit/V1/LinkTest.php index f07ccfc..e62d237 100644 --- a/tests/Unit/V1/LinkTest.php +++ b/tests/Unit/V1/LinkTest.php @@ -1,5 +1,7 @@ meta = new \stdClass(); @@ -68,7 +70,7 @@ public function testCreateWithObject() * * @param mixed $input */ - public function testHrefHasToBeAString($input) + public function testHrefHasToBeAString($input): void { $object = new \stdClass(); $object->href = $input; @@ -77,7 +79,7 @@ public function testHrefHasToBeAString($input) $link = new Link($object, $this->manager, $this->parent); $this->assertTrue($link->has('href')); - $this->assertTrue(is_string($link->get('href'))); + $this->assertIsString($link->get('href')); return; } @@ -96,7 +98,7 @@ public function testHrefHasToBeAString($input) * - an object ("link object") which can contain the following members: * - href: a string containing the link's URL. */ - public function testHrefAttributeMustBeSet() + public function testHrefAttributeMustBeSet(): void { $object = new \stdClass(); $object->related = 'http://example.org/related'; @@ -112,7 +114,7 @@ public function testHrefAttributeMustBeSet() /** * @test meta attribute will be parsed as Meta object inside Link */ - public function testMetaIsParsedAsObject() + public function testMetaIsParsedAsObject(): void { $object = new \stdClass(); $object->meta = new \stdClass(); @@ -131,7 +133,7 @@ public function testMetaIsParsedAsObject() * * @param mixed $input */ - public function testCreateWithDataprovider($input) + public function testCreateWithDataprovider($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/V1/MetaTest.php b/tests/Unit/V1/MetaTest.php index e7f4f11..218ed5f 100644 --- a/tests/Unit/V1/MetaTest.php +++ b/tests/Unit/V1/MetaTest.php @@ -1,5 +1,7 @@ object = new \stdClass(); @@ -51,15 +53,15 @@ public function testCreateWithObject() $this->assertInstanceOf(Accessable::class, $meta); $this->assertTrue($meta->has('object')); - $this->assertTrue(is_object($meta->get('object'))); + $this->assertIsObject($meta->get('object')); $this->assertTrue($meta->has('array')); - $this->assertTrue(is_array($meta->get('array'))); + $this->assertIsArray($meta->get('array')); $this->assertTrue($meta->has('string')); - $this->assertTrue(is_string($meta->get('string'))); + $this->assertIsString($meta->get('string')); $this->assertTrue($meta->has('number_int')); - $this->assertTrue(is_int($meta->get('number_int'))); + $this->assertIsInt($meta->get('number_int')); $this->assertTrue($meta->has('number_float')); - $this->assertTrue(is_float($meta->get('number_float'))); + $this->assertIsFloat($meta->get('number_float')); $this->assertTrue($meta->has('true')); $this->assertTrue($meta->get('true')); $this->assertTrue($meta->has('false')); @@ -80,7 +82,7 @@ public function testCreateWithObject() * * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input) + public function testCreateWithoutObjectThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage('Meta has to be an object, "' . gettype($input) . '" given.'); @@ -91,7 +93,7 @@ public function testCreateWithoutObjectThrowsException($input) /** * @test get() with not existing key throws an exception */ - public function testGetWithNotExistingKeyThrowsException() + public function testGetWithNotExistingKeyThrowsException(): void { $object = new \stdClass(); diff --git a/tests/Unit/V1/RelationshipCollectionTest.php b/tests/Unit/V1/RelationshipCollectionTest.php index ca2981f..fa6ef95 100644 --- a/tests/Unit/V1/RelationshipCollectionTest.php +++ b/tests/Unit/V1/RelationshipCollectionTest.php @@ -1,5 +1,7 @@ author = new \stdClass(); @@ -66,7 +68,7 @@ public function testCreateWithObject() /** * @test create with empty object */ - public function testCreateWithEmptyObject() + public function testCreateWithEmptyObject(): void { $item = $this->createMock(Accessable::class); @@ -86,7 +88,7 @@ public function testCreateWithEmptyObject() * * Fields for a resource object MUST share a common namespace with each other and with `type` and `id`. */ - public function testCreateWithTypePropertyThrowsException() + public function testCreateWithTypePropertyThrowsException(): void { $item = $this->createMock(Accessable::class); @@ -111,7 +113,7 @@ public function testCreateWithTypePropertyThrowsException() * * Fields for a resource object MUST share a common namespace with each other and with `type` and `id`. */ - public function testCreateWithIdPropertyThrowsException() + public function testCreateWithIdPropertyThrowsException(): void { $item = $this->createMock(Accessable::class); @@ -136,7 +138,7 @@ public function testCreateWithIdPropertyThrowsException() * * In other words, a resource can not have an attribute and relationship with the same name, */ - public function testCreateWithAuthorInRelationshipsAndAttributesThrowsException() + public function testCreateWithAuthorInRelationshipsAndAttributesThrowsException(): void { $item = $this->createMock(Accessable::class); @@ -161,7 +163,7 @@ public function testCreateWithAuthorInRelationshipsAndAttributesThrowsException( * * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input) + public function testCreateWithoutObjectThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/V1/RelationshipLinkTest.php b/tests/Unit/V1/RelationshipLinkTest.php index 18b9090..475e080 100644 --- a/tests/Unit/V1/RelationshipLinkTest.php +++ b/tests/Unit/V1/RelationshipLinkTest.php @@ -1,5 +1,7 @@ self = 'http://example.org/self'; @@ -98,7 +100,7 @@ public function testOnlySelfRelatedPaginationPropertiesExists() /** * @test pagination links are parsed, if data in parent relationship object exists */ - public function testPaginationParsedIfRelationshipDataExists() + public function testPaginationParsedIfRelationshipDataExists(): void { $object = new \stdClass(); $object->self = 'http://example.org/self'; @@ -118,7 +120,7 @@ public function testPaginationParsedIfRelationshipDataExists() /** * @test pagination links are not parsed, if data in parent relationship object doesnt exist */ - public function testPaginationNotParsedIfRelationshipDataNotExists() + public function testPaginationNotParsedIfRelationshipDataNotExists(): void { $object = new \stdClass(); $object->self = 'http://example.org/self'; @@ -155,7 +157,7 @@ public function testPaginationNotParsedIfRelationshipDataNotExists() /** * @test pagination links are not parsed, if data in parent relationship object is not IdentifierCollection */ - public function testPaginationNotParsedIfRelationshipIdentifierCollectionNotExists() + public function testPaginationNotParsedIfRelationshipIdentifierCollectionNotExists(): void { $object = new \stdClass(); $object->self = 'http://example.org/self'; @@ -204,7 +206,7 @@ public function testPaginationNotParsedIfRelationshipIdentifierCollectionNotExis * * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input) + public function testCreateWithoutObjectThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -221,7 +223,7 @@ public function testCreateWithoutObjectThrowsException($input) * * @param mixed $input */ - public function testCreateWithoutObjectOrStringAttributeThrowsException($input) + public function testCreateWithoutObjectOrStringAttributeThrowsException($input): void { $object = new \stdClass(); $object->self = 'http://example.org/self'; @@ -238,7 +240,7 @@ public function testCreateWithoutObjectOrStringAttributeThrowsException($input) /** * @test object contains at least one of the following: self, related */ - public function testCreateWithoutSelfAndRelatedPropertiesThrowsException() + public function testCreateWithoutSelfAndRelatedPropertiesThrowsException(): void { $object = new \stdClass(); $object->first = 'http://example.org/first'; @@ -259,7 +261,7 @@ public function testCreateWithoutSelfAndRelatedPropertiesThrowsException() * * @param mixed $input */ - public function testSelfMustBeAStringOrObject($input) + public function testSelfMustBeAStringOrObject($input): void { $object = new \stdClass(); $object->self = $input; @@ -280,7 +282,7 @@ public function testSelfMustBeAStringOrObject($input) * * @param mixed $input */ - public function testRelatedMustBeAStringOrObject($input) + public function testRelatedMustBeAStringOrObject($input): void { $object = new \stdClass(); $object->related = $input; @@ -300,7 +302,7 @@ public function testRelatedMustBeAStringOrObject($input) * * @param mixed $input */ - public function testFirstCanBeAStringOrNull($input) + public function testFirstCanBeAStringOrNull($input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -341,7 +343,7 @@ public function testFirstCanBeAStringOrNull($input) * * @param mixed $input */ - public function testLastCanBeAStringOrNull($input) + public function testLastCanBeAStringOrNull($input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -382,7 +384,7 @@ public function testLastCanBeAStringOrNull($input) * * @param mixed $input */ - public function testPrevCanBeAStringOrNull($input) + public function testPrevCanBeAStringOrNull($input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -423,7 +425,7 @@ public function testPrevCanBeAStringOrNull($input) * * @param mixed $input */ - public function testNextCanBeAStringOrNull($input) + public function testNextCanBeAStringOrNull($input): void { $object = new \stdClass(); $object->self = 'https://example.org/self'; @@ -460,7 +462,7 @@ public function testNextCanBeAStringOrNull($input) /** * @test */ - public function testGetOnANonExistingKeyThrowsException() + public function testGetOnANonExistingKeyThrowsException(): void { $object = new \stdClass(); $object->self = 'http://example.org/self'; diff --git a/tests/Unit/V1/RelationshipTest.php b/tests/Unit/V1/RelationshipTest.php index 948e2bc..7574890 100644 --- a/tests/Unit/V1/RelationshipTest.php +++ b/tests/Unit/V1/RelationshipTest.php @@ -1,5 +1,7 @@ meta = new \stdClass(); @@ -63,7 +65,7 @@ public function testCreateWithObjectReturnsSelf() * * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input) + public function testCreateWithoutObjectThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -78,7 +80,7 @@ public function testCreateWithoutObjectThrowsException($input) * * A "relationship object" MUST contain at least one of the following: links, data, meta */ - public function testCreateWithoutLinksDataMetaPropertiesThrowsException() + public function testCreateWithoutLinksDataMetaPropertiesThrowsException(): void { $object = new \stdClass(); $object->foo = 'bar'; @@ -94,7 +96,7 @@ public function testCreateWithoutLinksDataMetaPropertiesThrowsException() /** * @test create with link object */ - public function testCreateWithLinksObject() + public function testCreateWithLinksObject(): void { $object = new \stdClass(); $object->links = new \stdClass(); @@ -117,7 +119,7 @@ public function testCreateWithLinksObject() * * data: resource linkage, see http://jsonapi.org/format/#document-resource-object-linkage */ - public function testCreateWithDataObject() + public function testCreateWithDataObject(): void { $data = new \stdClass(); $data->type = 'posts'; @@ -139,7 +141,7 @@ public function testCreateWithDataObject() /** * @test create with data null */ - public function testCreateWithDataNull() + public function testCreateWithDataNull(): void { $object = new \stdClass(); $object->data = null; @@ -151,13 +153,13 @@ public function testCreateWithDataNull() $this->assertSame($relationship->getKeys(), ['data']); $this->assertTrue($relationship->has('data')); - $this->assertTrue(is_null($relationship->get('data'))); + $this->assertNull($relationship->get('data')); } /** * @test create with data object array */ - public function testCreateWithDataObjectArray() + public function testCreateWithDataObjectArray(): void { $data_obj = new \stdClass(); $data_obj->type = 'types'; @@ -181,7 +183,7 @@ public function testCreateWithDataObjectArray() /** * @test create with data empty array */ - public function testCreateWithDataEmptyArray() + public function testCreateWithDataEmptyArray(): void { $object = new \stdClass(); $object->data = []; @@ -201,7 +203,7 @@ public function testCreateWithDataEmptyArray() /** * @test create with meta object */ - public function testCreateWithMetaObject() + public function testCreateWithMetaObject(): void { $object = new \stdClass(); $object->meta = new \stdClass(); diff --git a/tests/Unit/V1/ResourceCollectionTest.php b/tests/Unit/V1/ResourceCollectionTest.php index 616f3d5..67d00e1 100644 --- a/tests/Unit/V1/ResourceCollectionTest.php +++ b/tests/Unit/V1/ResourceCollectionTest.php @@ -1,5 +1,7 @@ manager, $this->parent); @@ -50,7 +52,7 @@ public function testCreateWithEmptyArray() /** * @test create with identifier object */ - public function testCreateWithIdentifier() + public function testCreateWithIdentifier(): void { $object = new \stdClass(); $object->type = 'type'; @@ -71,7 +73,7 @@ public function testCreateWithIdentifier() /** * @test create with identifier object and meta */ - public function testCreateWithIdentifierAndMeta() + public function testCreateWithIdentifierAndMeta(): void { $object = new \stdClass(); $object->type = 'type'; @@ -107,7 +109,7 @@ public function testCreateWithIdentifierAndMeta() /** * @test create with item object */ - public function testCreateWithItem() + public function testCreateWithItem(): void { $object = new \stdClass(); $object->type = 'type'; @@ -133,7 +135,7 @@ public function testCreateWithItem() * * @param mixed $input */ - public function testCreateWithoutArrayThrowsException($input) + public function testCreateWithoutArrayThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -148,7 +150,7 @@ public function testCreateWithoutArrayThrowsException($input) * * @param mixed $input */ - public function testCreateWithoutObjectInArrayThrowsException($input) + public function testCreateWithoutObjectInArrayThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -161,7 +163,7 @@ public function testCreateWithoutObjectInArrayThrowsException($input) /** * @test get('resources') on an empty collection throws an exception */ - public function testGetResourcesWithEmptyCollectionThrowsException() + public function testGetResourcesWithEmptyCollectionThrowsException(): void { $collection = new ResourceCollection([], $this->manager, $this->createMock(Accessable::class)); diff --git a/tests/Unit/V1/ResourceIdentifierCollectionTest.php b/tests/Unit/V1/ResourceIdentifierCollectionTest.php index bffe9e1..3ab6f02 100644 --- a/tests/Unit/V1/ResourceIdentifierCollectionTest.php +++ b/tests/Unit/V1/ResourceIdentifierCollectionTest.php @@ -1,5 +1,7 @@ manager, $this->parent); @@ -45,7 +47,7 @@ public function testCreateWithEmptyArray() /** * @test create with identifier object */ - public function testCreateWithIdentifier() + public function testCreateWithIdentifier(): void { $object = new \stdClass(); $object->type = 'type'; @@ -71,7 +73,7 @@ public function testCreateWithIdentifier() /** * @test create with item object */ - public function testCreateWithItem() + public function testCreateWithItem(): void { $object = new \stdClass(); $object->type = 'type'; @@ -98,7 +100,7 @@ public function testCreateWithItem() * * @param mixed $input */ - public function testCreateWithoutArrayThrowsException($input) + public function testCreateWithoutArrayThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -111,7 +113,7 @@ public function testCreateWithoutArrayThrowsException($input) /** * @test get('resources') on an empty identifier collection throws an exception */ - public function testGetResourcesWithEmptyCollectionThrowsException() + public function testGetResourcesWithEmptyCollectionThrowsException(): void { $collection = new ResourceIdentifierCollection([], $this->manager, $this->parent); diff --git a/tests/Unit/V1/ResourceIdentifierTest.php b/tests/Unit/V1/ResourceIdentifierTest.php index 58f6673..65e4ff5 100644 --- a/tests/Unit/V1/ResourceIdentifierTest.php +++ b/tests/Unit/V1/ResourceIdentifierTest.php @@ -1,5 +1,7 @@ type = 'type'; @@ -51,7 +53,7 @@ public function testCreateWithObject() /** * @test create with object and meta */ - public function testCreateWithObjectAndMeta() + public function testCreateWithObjectAndMeta(): void { $object = new \stdClass(); $object->type = 'types'; @@ -76,7 +78,7 @@ public function testCreateWithObjectAndMeta() * * @param mixed $input */ - public function testTypeMustBeAString($input) + public function testTypeMustBeAString($input): void { $object = new \stdClass(); $object->type = $input; @@ -89,7 +91,7 @@ public function testTypeMustBeAString($input) $identifier = new ResourceIdentifier($object, $this->manager, $this->parent); - $this->assertTrue(is_string($identifier->get('type'))); + $this->assertIsString($identifier->get('type')); } /** @@ -99,7 +101,7 @@ public function testTypeMustBeAString($input) * * @param mixed $input */ - public function testIdMustBeAString($input) + public function testIdMustBeAString($input): void { $object = new \stdClass(); $object->type = 'posts'; @@ -121,7 +123,7 @@ public function testIdMustBeAString($input) * * @param mixed $input */ - public function testCreateWithDataproviderThrowsException($input) + public function testCreateWithDataproviderThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -134,7 +136,7 @@ public function testCreateWithDataproviderThrowsException($input) /** * @test A "resource identifier object" MUST contain type and id members. */ - public function testCreateWithObjectWithoutTypeThrowsException() + public function testCreateWithObjectWithoutTypeThrowsException(): void { $object = new \stdClass(); $object->id = '123'; @@ -150,7 +152,7 @@ public function testCreateWithObjectWithoutTypeThrowsException() /** * @test A "resource identifier object" MUST contain type and id members. */ - public function testCreateWithObjectWithoutIdThrowsException() + public function testCreateWithObjectWithoutIdThrowsException(): void { $object = new \stdClass(); $object->type = 'type'; @@ -166,7 +168,7 @@ public function testCreateWithObjectWithoutIdThrowsException() /** * @test get() on an undefined value throws Exception */ - public function testGetWithUndefinedValueThrowsException() + public function testGetWithUndefinedValueThrowsException(): void { $object = new \stdClass(); $object->type = 'posts'; diff --git a/tests/Unit/V1/ResourceItemLinkTest.php b/tests/Unit/V1/ResourceItemLinkTest.php index b86d5ad..1d98f6f 100644 --- a/tests/Unit/V1/ResourceItemLinkTest.php +++ b/tests/Unit/V1/ResourceItemLinkTest.php @@ -1,5 +1,7 @@ self = 'http://example.org/self'; @@ -59,7 +61,7 @@ public function testParsingPropertiesExists() * * @param mixed $input */ - public function testCreateWithoutObjectThrowsException($input) + public function testCreateWithoutObjectThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -76,7 +78,7 @@ public function testCreateWithoutObjectThrowsException($input) * * @param mixed $input */ - public function testCreateWithoutObjectOrStringAttributeThrowsException($input) + public function testCreateWithoutObjectOrStringAttributeThrowsException($input): void { $object = new \stdClass(); $object->input = $input; @@ -92,7 +94,7 @@ public function testCreateWithoutObjectOrStringAttributeThrowsException($input) /** * @test */ - public function testGetOnANonExistingKeyThrowsException() + public function testGetOnANonExistingKeyThrowsException(): void { $object = new \stdClass(); $object->self = 'http://example.org/self'; diff --git a/tests/Unit/V1/ResourceItemTest.php b/tests/Unit/V1/ResourceItemTest.php index 63db0db..8641760 100644 --- a/tests/Unit/V1/ResourceItemTest.php +++ b/tests/Unit/V1/ResourceItemTest.php @@ -1,5 +1,7 @@ type = 'type'; @@ -66,7 +68,7 @@ public function testCreateWithObject() /** * @test create with full object */ - public function testCreateWithFullObject() + public function testCreateWithFullObject(): void { $object = new \stdClass(); $object->type = 'type'; @@ -100,7 +102,7 @@ public function testCreateWithFullObject() * * @param mixed $input */ - public function testTypeMustBeAString($input) + public function testTypeMustBeAString($input): void { $object = new \stdClass(); $object->type = $input; @@ -121,7 +123,7 @@ public function testTypeMustBeAString($input) * * @param mixed $input */ - public function testIdMustBeAString($input) + public function testIdMustBeAString($input): void { $object = new \stdClass(); $object->type = 'posts'; @@ -143,7 +145,7 @@ public function testIdMustBeAString($input) * * @param mixed $input */ - public function testCreateWithDataproviderThrowsException($input) + public function testCreateWithDataproviderThrowsException($input): void { $this->expectException(ValidationException::class); $this->expectExceptionMessage( @@ -156,7 +158,7 @@ public function testCreateWithDataproviderThrowsException($input) /** * @test A "resource object" MUST contain type and id members. */ - public function testCreateWithObjectWithoutTypeThrowsException() + public function testCreateWithObjectWithoutTypeThrowsException(): void { $object = new \stdClass(); $object->id = 123; @@ -172,7 +174,7 @@ public function testCreateWithObjectWithoutTypeThrowsException() /** * @test A "resource object" MUST contain type and id members. */ - public function testCreateWithObjectWithoutIdThrowsException() + public function testCreateWithObjectWithoutIdThrowsException(): void { $object = new \stdClass(); $object->type = 'type'; diff --git a/tests/Unit/V1/ResourceNullTest.php b/tests/Unit/V1/ResourceNullTest.php index e470600..cbaf377 100644 --- a/tests/Unit/V1/ResourceNullTest.php +++ b/tests/Unit/V1/ResourceNullTest.php @@ -1,5 +1,7 @@