diff --git a/.phpstan.neon b/.phpstan.neon index 5199950..5f624d8 100644 --- a/.phpstan.neon +++ b/.phpstan.neon @@ -17,42 +17,6 @@ parameters: treatPhpDocTypesAsCertain: false ignoreErrors: - - - message: "#^Constructor of class Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull has an unused parameter \\$data\\.$#" - count: 1 - path: src/V1/ResourceNull.php - # parameter is required by Art4\JsonApiClient\Element - - - - message: "#^Constructor of class Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull has an unused parameter \\$manager\\.$#" - count: 1 - path: src/V1/ResourceNull.php - # parameter is required by Art4\JsonApiClient\Element - - - - message: "#^Constructor of class Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull has an unused parameter \\$parent\\.$#" - count: 1 - path: src/V1/ResourceNull.php - # parameter is required by Art4\JsonApiClient\Element - - - - message: "#^Constructor of an anonymous class has an unused parameter \\$data\\.$#" - count: 1 - path: tests/BC/ElementTest.php - # parameter is required by Art4\JsonApiClient\Element - - - - message: "#^Constructor of an anonymous class has an unused parameter \\$manager\\.$#" - count: 1 - path: tests/BC/ElementTest.php - # parameter is required by Art4\JsonApiClient\Element - - - - message: "#^Constructor of an anonymous class has an unused parameter \\$parent\\.$#" - count: 1 - path: tests/BC/ElementTest.php - # parameter is required by Art4\JsonApiClient\Element - - message: "#^Parameter \\#1 \\$string of class Art4\\\\JsonApiClient\\\\Input\\\\RequestStringInput constructor expects string, mixed given\\.$#" count: 1 diff --git a/composer.json b/composer.json index 534378b..dd35875 100644 --- a/composer.json +++ b/composer.json @@ -17,9 +17,9 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.64", - "phpstan/phpstan": "^1.10", - "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^10.4" + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^10.4 || ^11.0 || ^12.0" }, "autoload": { "psr-4": { diff --git a/tests/BC/AccessableTest.php b/tests/BC/AccessableTest.php index 41d6852..2fbce0e 100644 --- a/tests/BC/AccessableTest.php +++ b/tests/BC/AccessableTest.php @@ -59,6 +59,7 @@ public function getKeys() } }; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $class); } } diff --git a/tests/BC/ElementTest.php b/tests/BC/ElementTest.php index c48e5ca..2a9e4cf 100644 --- a/tests/BC/ElementTest.php +++ b/tests/BC/ElementTest.php @@ -38,6 +38,7 @@ public function testBcForElementInterface(): void public function __construct($data, Manager $manager, Accessable $parent) {} }; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Element::class, $class); } } diff --git a/tests/BC/Exception/ExceptionTest.php b/tests/BC/Exception/ExceptionTest.php index dd25c35..ca0f176 100644 --- a/tests/BC/Exception/ExceptionTest.php +++ b/tests/BC/Exception/ExceptionTest.php @@ -25,6 +25,7 @@ public function testBcForExceptionInterface(): void */ $class = new class implements Exception {}; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Exception::class, $class); } } diff --git a/tests/BC/FactoryTest.php b/tests/BC/FactoryTest.php index 21fe291..614fb7d 100644 --- a/tests/BC/FactoryTest.php +++ b/tests/BC/FactoryTest.php @@ -38,6 +38,7 @@ public function make($name, array $args = []) } }; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Factory::class, $class); } } diff --git a/tests/BC/Input/InputTest.php b/tests/BC/Input/InputTest.php index a2645a3..6bbbe48 100644 --- a/tests/BC/Input/InputTest.php +++ b/tests/BC/Input/InputTest.php @@ -30,8 +30,6 @@ public function testBcForInputInterface(): void * This should be a native PH stdClass object, so Manager could * iterate over all public attributes * - * @throws \Art4\JsonApiClient\Exception\InputException if something went wrong with the input - * * @return \stdClass */ public function getAsObject() @@ -40,6 +38,7 @@ public function getAsObject() } }; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Input::class, $class); } } diff --git a/tests/BC/Input/RequestInputTest.php b/tests/BC/Input/RequestInputTest.php index b503c33..3956913 100644 --- a/tests/BC/Input/RequestInputTest.php +++ b/tests/BC/Input/RequestInputTest.php @@ -25,6 +25,7 @@ public function testBcForRequestInputInterface(): void */ $class = new class implements RequestInput {}; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(RequestInput::class, $class); } } diff --git a/tests/BC/ManagerTest.php b/tests/BC/ManagerTest.php index 9c993fb..32d70ff 100644 --- a/tests/BC/ManagerTest.php +++ b/tests/BC/ManagerTest.php @@ -30,9 +30,6 @@ public function testBcForManagerInterface(): void * * @param \Art4\JsonApiClient\Input\Input $input * - * @throws \Art4\JsonApiClient\Exception\InputException If $input contains invalid JSON API - * @throws \Art4\JsonApiClient\Exception\ValidationException If $input contains invalid JSON API - * * @return \Art4\JsonApiClient\Accessable */ public function parse(Input $input) @@ -64,6 +61,7 @@ public function getParam($key, $default) } }; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Manager::class, $class); } } diff --git a/tests/BC/Serializer/SerializerTest.php b/tests/BC/Serializer/SerializerTest.php index b01a45e..c19f658 100644 --- a/tests/BC/Serializer/SerializerTest.php +++ b/tests/BC/Serializer/SerializerTest.php @@ -38,6 +38,7 @@ public function serialize(Accessable $data) } }; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Serializer::class, $class); } } diff --git a/tests/Fixtures/HelperTrait.php b/tests/Fixtures/HelperTrait.php index 8da7143..20b8669 100644 --- a/tests/Fixtures/HelperTrait.php +++ b/tests/Fixtures/HelperTrait.php @@ -166,7 +166,7 @@ public function setUpManagerMock(): void $this->manager->expects($this->any()) ->method('getFactory') - ->will($this->returnValue($factory)); + ->willReturn($factory); $this->manager->expects($this->any()) ->method('getParam') @@ -177,7 +177,7 @@ public function setUpManagerMock(): void /** * returns a json string from a file */ - protected function getJsonString(mixed $filename): string + protected function getJsonString(string $filename): string { return strval(file_get_contents(__DIR__ . '/../files/' . $filename)); } diff --git a/tests/Fixtures/V1Factory.php b/tests/Fixtures/V1Factory.php index 835c047..66d93f8 100644 --- a/tests/Fixtures/V1Factory.php +++ b/tests/Fixtures/V1Factory.php @@ -9,6 +9,7 @@ namespace Art4\JsonApiClient\Tests\Fixtures; use Art4\JsonApiClient\Factory as FactoryInterface; +use PHPUnit\Framework\MockObject\MockBuilder; use PHPUnit\Framework\TestCase; final class V1Factory implements FactoryInterface @@ -33,11 +34,9 @@ public function __construct(TestCase $testcase) */ public function make($name, array $args = []) { - return $this->testcase->getMockBuilder(AccessableElement::class) + return (new MockBuilder($this->testcase, AccessableElement::class)) ->disableOriginalConstructor() ->disableOriginalClone() - ->disableArgumentCloning() - ->disallowMockingUnknownTypes() ->getMock(); } } diff --git a/tests/Unit/Input/RequestStringInputTest.php b/tests/Unit/Input/RequestStringInputTest.php index bfa259b..e529a55 100644 --- a/tests/Unit/Input/RequestStringInputTest.php +++ b/tests/Unit/Input/RequestStringInputTest.php @@ -22,6 +22,7 @@ public function testGetAsObjectFromStringReturnsObject(): void { $input = new RequestStringInput('{}'); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(\stdClass::class, $input->getAsObject()); } diff --git a/tests/Unit/Input/ResponseStringInputTest.php b/tests/Unit/Input/ResponseStringInputTest.php index 7d1f6aa..e8ae607 100644 --- a/tests/Unit/Input/ResponseStringInputTest.php +++ b/tests/Unit/Input/ResponseStringInputTest.php @@ -22,6 +22,7 @@ public function testGetAsObjectFromStringReturnsObject(): void { $input = new ResponseStringInput('{}'); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(\stdClass::class, $input->getAsObject()); } diff --git a/tests/Unit/Serializer/ArraySerializerTest.php b/tests/Unit/Serializer/ArraySerializerTest.php index e4b165c..d7e3b88 100644 --- a/tests/Unit/Serializer/ArraySerializerTest.php +++ b/tests/Unit/Serializer/ArraySerializerTest.php @@ -23,7 +23,7 @@ public function testSerialize(): void $object2 = new \stdClass(); $data = $this->createMock(Accessable::class); - $data->method('get')->will($this->returnValueMap([ + $data->method('get')->willReturnMap([ ['AccessObject', $object1], ['object', $object2], ['array', []], @@ -31,7 +31,7 @@ public function testSerialize(): void ['integer', 1], ['boolean', true], ['null', null], - ])); + ]); $data->method('getKeys')->willReturn([ 'AccessObject', 'object', @@ -64,14 +64,14 @@ public function testRecursiveSerialize(): void $stdObject->key = 'value'; $object1 = $this->createMock(Accessable::class); - $object1->method('get')->will($this->returnValueMap([ + $object1->method('get')->willReturnMap([ ['object', $stdObject], ['array', []], ['string', 'string'], ['integer', 1], ['boolean', true], ['null', null], - ])); + ]); $object1->method('getKeys')->willReturn([ 'object', 'array', @@ -82,9 +82,9 @@ public function testRecursiveSerialize(): void ]); $data = $this->createMock(Accessable::class); - $data->method('get')->will($this->returnValueMap([ + $data->method('get')->willReturnMap([ ['AccessObject', $object1], - ])); + ]); $data->method('getKeys')->willReturn([ 'AccessObject', ]); diff --git a/tests/Unit/V1/AttributesTest.php b/tests/Unit/V1/AttributesTest.php index e19a201..7edf94f 100644 --- a/tests/Unit/V1/AttributesTest.php +++ b/tests/Unit/V1/AttributesTest.php @@ -52,6 +52,7 @@ public function testCreateWithObject(): void $this->parent ); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $attributes); $this->assertTrue($attributes->has('object')); $this->assertIsObject($attributes->get('object')); diff --git a/tests/Unit/V1/DocumentLinkTest.php b/tests/Unit/V1/DocumentLinkTest.php index da58837..5c599a6 100644 --- a/tests/Unit/V1/DocumentLinkTest.php +++ b/tests/Unit/V1/DocumentLinkTest.php @@ -33,7 +33,7 @@ public function setUp(): void $this->parent->expects($this->any()) ->method('has') ->with('data') - ->will($this->returnValue(true)); + ->willReturn(true); } /** @@ -59,6 +59,7 @@ public function testOnlySelfRelatedPaginationPropertiesExists(): void $link = new DocumentLink($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $link); $this->assertSame([ 'self', diff --git a/tests/Unit/V1/DocumentTest.php b/tests/Unit/V1/DocumentTest.php index d62ef94..73a187d 100644 --- a/tests/Unit/V1/DocumentTest.php +++ b/tests/Unit/V1/DocumentTest.php @@ -42,7 +42,9 @@ public function testCreateWithObjectReturnsSelf(): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $document); $this->assertSame($document->getKeys(), ['meta']); $this->assertTrue($document->has('meta')); @@ -74,6 +76,7 @@ public function testCreateWithAllPossibleValues(): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertSame($document->getKeys(), ['data', 'meta', 'included', 'jsonapi', 'links']); $this->assertTrue($document->has('data')); @@ -135,6 +138,7 @@ public function testCreateDataWithResourceIdentifier(): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertTrue($document->has('data')); @@ -156,6 +160,7 @@ public function testCreateDataWithResourceIdentifierAndMeta(): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertTrue($document->has('data')); @@ -178,6 +183,7 @@ public function testCreateDataWithResourceItem(): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertTrue($document->has('data')); @@ -198,6 +204,7 @@ public function testCreateDataWithResourceCollectionIdentifiers(): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertTrue($document->has('data')); @@ -220,6 +227,7 @@ public function testCreateDataWithResourceCollectionResources(): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertTrue($document->has('data')); @@ -240,6 +248,7 @@ public function testCreateWithDataproviderInValue(mixed $input): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertTrue($document->has('data')); @@ -257,6 +266,7 @@ public function testCreateWithDataproviderInValue(mixed $input): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertTrue($document->has('data')); @@ -289,6 +299,7 @@ public function testCreateWithErrorsArray(): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertSame($document->getKeys(), ['errors']); $this->assertTrue($document->has('errors')); @@ -323,6 +334,7 @@ public function testCreateWithMetaObject(): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertTrue($document->has('meta')); @@ -341,6 +353,7 @@ public function testCreateWithJsonapiObject(): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertTrue($document->has('jsonapi')); @@ -359,6 +372,7 @@ public function testCreateWithLinkObject(): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertTrue($document->has('links')); @@ -383,6 +397,7 @@ public function testCreateWithIncludedObjects(): void $document = new Document($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Document::class, $document); $this->assertTrue($document->has('included')); diff --git a/tests/Unit/V1/ErrorCollectionTest.php b/tests/Unit/V1/ErrorCollectionTest.php index 00db6b0..8245fef 100644 --- a/tests/Unit/V1/ErrorCollectionTest.php +++ b/tests/Unit/V1/ErrorCollectionTest.php @@ -44,7 +44,9 @@ public function testCreate(): void $collection = new ErrorCollection($errors, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ErrorCollection::class, $collection); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $collection); $this->assertSame($collection->getKeys(), [0, 1]); @@ -94,6 +96,7 @@ public function testGetErrorWithEmptyCollectionThrowsException(): void $collection = new ErrorCollection($errors, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ErrorCollection::class, $collection); $this->assertFalse($collection->has(1)); diff --git a/tests/Unit/V1/ErrorLinkTest.php b/tests/Unit/V1/ErrorLinkTest.php index 3a4dfe0..cd5e551 100644 --- a/tests/Unit/V1/ErrorLinkTest.php +++ b/tests/Unit/V1/ErrorLinkTest.php @@ -47,7 +47,9 @@ public function testAllPropertiesExists(): void $link = new ErrorLink($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ErrorLink::class, $link); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $link); $this->assertSame($link->getKeys(), ['about', 'meta', 'href']); @@ -93,6 +95,7 @@ public function testAboutCanBeAnObject(): void $link = new ErrorLink($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ErrorLink::class, $link); $this->assertSame($link->getKeys(), ['about']); diff --git a/tests/Unit/V1/ErrorSourceTest.php b/tests/Unit/V1/ErrorSourceTest.php index f6cab45..99f150e 100644 --- a/tests/Unit/V1/ErrorSourceTest.php +++ b/tests/Unit/V1/ErrorSourceTest.php @@ -47,7 +47,9 @@ public function testOnlyPointerParameterPropertiesExists(): void $source = new ErrorSource($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ErrorSource::class, $source); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $source); $this->assertSame($source->getKeys(), ['pointer', 'parameter']); diff --git a/tests/Unit/V1/ErrorTest.php b/tests/Unit/V1/ErrorTest.php index c3c9b22..1afeaa0 100644 --- a/tests/Unit/V1/ErrorTest.php +++ b/tests/Unit/V1/ErrorTest.php @@ -49,7 +49,9 @@ public function testCreateWithObjectReturnsSelf(): void $error = new Error($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf('Art4\JsonApiClient\V1\Error', $error); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $error); $this->assertSame($error->getKeys(), ['id', 'links', 'status', 'code', 'title', 'detail', 'source', 'meta']); diff --git a/tests/Unit/V1/FactoryTest.php b/tests/Unit/V1/FactoryTest.php index 1294809..3acfded 100644 --- a/tests/Unit/V1/FactoryTest.php +++ b/tests/Unit/V1/FactoryTest.php @@ -31,6 +31,7 @@ public function testInjectACustomClass(): void $this->createMock(Accessable::class), ]); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(FactoryInterface::class, $factory); $this->assertInstanceOf(ResourceNull::class, $resource); } diff --git a/tests/Unit/V1/JsonapiTest.php b/tests/Unit/V1/JsonapiTest.php index 6e26e38..7f8db3d 100644 --- a/tests/Unit/V1/JsonapiTest.php +++ b/tests/Unit/V1/JsonapiTest.php @@ -48,7 +48,9 @@ public function testCreateWithObject(): void $jsonapi = new Jsonapi($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Jsonapi::class, $jsonapi); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $jsonapi); $this->assertSame($jsonapi->getKeys(), ['version', 'meta']); @@ -106,6 +108,7 @@ public function testVersionCannotBeAnObjectOrArray(mixed $input): void $jsonapi = new Jsonapi($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Jsonapi::class, $jsonapi); $this->assertSame($jsonapi->getKeys(), ['version']); diff --git a/tests/Unit/V1/LinkTest.php b/tests/Unit/V1/LinkTest.php index 39442ac..a6a3428 100644 --- a/tests/Unit/V1/LinkTest.php +++ b/tests/Unit/V1/LinkTest.php @@ -43,6 +43,7 @@ public function testCreateWithObject(): void $link = new Link($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $link); $this->assertTrue($link->has('href')); diff --git a/tests/Unit/V1/MetaTest.php b/tests/Unit/V1/MetaTest.php index defdb04..4d8ab94 100644 --- a/tests/Unit/V1/MetaTest.php +++ b/tests/Unit/V1/MetaTest.php @@ -52,6 +52,7 @@ public function testCreateWithObject(): void $this->parent ); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $meta); $this->assertTrue($meta->has('object')); $this->assertIsObject($meta->get('object')); diff --git a/tests/Unit/V1/RelationshipCollectionTest.php b/tests/Unit/V1/RelationshipCollectionTest.php index 9982184..35a64c1 100644 --- a/tests/Unit/V1/RelationshipCollectionTest.php +++ b/tests/Unit/V1/RelationshipCollectionTest.php @@ -48,7 +48,9 @@ public function testCreateWithObject(): void $collection = new RelationshipCollection($object, $this->manager, $item); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(RelationshipCollection::class, $collection); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $collection); $this->assertSame($collection->getKeys(), ['author']); @@ -81,6 +83,7 @@ public function testCreateWithEmptyObject(): void $collection = new RelationshipCollection($object, $this->manager, $item); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(RelationshipCollection::class, $collection); } @@ -121,7 +124,7 @@ public function testCreateWithIdPropertyThrowsException(): void $item->expects($this->any()) ->method('has') ->with($this->equalTo('attributes')) - ->will($this->returnValue(false)); + ->willReturn(false); $object = new \stdClass(); $object->id = '5'; diff --git a/tests/Unit/V1/RelationshipLinkTest.php b/tests/Unit/V1/RelationshipLinkTest.php index 2962623..c04f176 100644 --- a/tests/Unit/V1/RelationshipLinkTest.php +++ b/tests/Unit/V1/RelationshipLinkTest.php @@ -42,12 +42,12 @@ public function setUp(): void $this->relationship->expects($this->any()) ->method('has') ->with($this->equalTo('data')) - ->will($this->returnValue(true)); + ->willReturn(true); $this->relationship->expects($this->any()) ->method('get') ->with($this->equalTo('data')) - ->will($this->returnValue($collection)); + ->willReturn($collection); } /** @@ -76,7 +76,9 @@ public function testOnlySelfRelatedPaginationPropertiesExists(): void $link = new RelationshipLink($object, $this->manager, $this->relationship); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(RelationshipLink::class, $link); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $link); $this->assertSame($link->getKeys(), ['self', 'related', 'first', 'last', 'prev', 'next', 'custom', 'meta']); @@ -136,10 +138,11 @@ public function testPaginationNotParsedIfRelationshipDataNotExists(): void $relationship->expects($this->any()) ->method('has') ->with($this->equalTo('data')) - ->will($this->returnValue(false)); + ->willReturn(false); $link = new RelationshipLink($object, $this->manager, $relationship); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(RelationshipLink::class, $link); $this->assertSame($link->getKeys(), ['self', 'first', 'last', 'prev', 'next']); @@ -173,7 +176,7 @@ public function testPaginationNotParsedIfRelationshipIdentifierCollectionNotExis $relationship->expects($this->any()) ->method('has') ->with($this->equalTo('data')) - ->will($this->returnValue(true)); + ->willReturn(true); // Mock identifier item $data = $this->createMock(Accessable::class); @@ -181,10 +184,11 @@ public function testPaginationNotParsedIfRelationshipIdentifierCollectionNotExis $relationship->expects($this->any()) ->method('get') ->with($this->equalTo('data')) - ->will($this->returnValue($data)); + ->willReturn($data); $link = new RelationshipLink($object, $this->manager, $relationship); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(RelationshipLink::class, $link); $this->assertSame($link->getKeys(), ['self', 'first', 'last', 'prev', 'next']); diff --git a/tests/Unit/V1/RelationshipTest.php b/tests/Unit/V1/RelationshipTest.php index 3a28544..a785055 100644 --- a/tests/Unit/V1/RelationshipTest.php +++ b/tests/Unit/V1/RelationshipTest.php @@ -41,7 +41,9 @@ public function testCreateWithObjectReturnsSelf(): void $relationship = new Relationship($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Relationship::class, $relationship); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $relationship); $this->assertTrue($relationship->has('meta')); @@ -101,8 +103,8 @@ public function testCreateWithLinksObject(): void $object->links->self = 'http://example.org/self'; $relationship = $relationship = new Relationship($object, $this->manager, $this->parent); - ; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Relationship::class, $relationship); $this->assertSame($relationship->getKeys(), ['links']); $this->assertTrue($relationship->has('links')); @@ -127,8 +129,8 @@ public function testCreateWithDataObject(): void $object->data = $data; $relationship = $relationship = new Relationship($object, $this->manager, $this->parent); - ; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Relationship::class, $relationship); $this->assertSame($relationship->getKeys(), ['data']); $this->assertTrue($relationship->has('data')); @@ -145,8 +147,8 @@ public function testCreateWithDataNull(): void $object->data = null; $relationship = $relationship = new Relationship($object, $this->manager, $this->parent); - ; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Relationship::class, $relationship); $this->assertSame($relationship->getKeys(), ['data']); $this->assertTrue($relationship->has('data')); @@ -167,8 +169,8 @@ public function testCreateWithDataObjectArray(): void $object->data = [$data_obj]; $relationship = $relationship = new Relationship($object, $this->manager, $this->parent); - ; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Relationship::class, $relationship); $this->assertSame($relationship->getKeys(), ['data']); $this->assertTrue($relationship->has('data')); @@ -187,8 +189,8 @@ public function testCreateWithDataEmptyArray(): void $object->data = []; $relationship = $relationship = new Relationship($object, $this->manager, $this->parent); - ; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Relationship::class, $relationship); $this->assertSame($relationship->getKeys(), ['data']); $this->assertTrue($relationship->has('data')); @@ -207,8 +209,8 @@ public function testCreateWithMetaObject(): void $object->meta = new \stdClass(); $relationship = $relationship = new Relationship($object, $this->manager, $this->parent); - ; + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Relationship::class, $relationship); $this->assertSame($relationship->getKeys(), ['meta']); $this->assertTrue($relationship->has('meta')); diff --git a/tests/Unit/V1/ResourceCollectionTest.php b/tests/Unit/V1/ResourceCollectionTest.php index 30cd6f8..4c3882a 100644 --- a/tests/Unit/V1/ResourceCollectionTest.php +++ b/tests/Unit/V1/ResourceCollectionTest.php @@ -39,7 +39,9 @@ public function testCreateWithEmptyArray(): void { $collection = new ResourceCollection([], $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceCollection::class, $collection); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $collection); $this->assertSame($collection->getKeys(), []); @@ -61,6 +63,7 @@ public function testCreateWithIdentifier(): void $collection = new ResourceCollection([$object], $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceCollection::class, $collection); $this->assertSame($collection->getKeys(), [0]); @@ -87,6 +90,7 @@ public function testCreateWithIdentifierAndMeta(): void $this->parent ); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceCollection::class, $collection); $this->assertSame($collection->getKeys(), [0, 1, 2]); @@ -124,6 +128,7 @@ public function testCreateWithItem(): void $collection = new ResourceCollection([$object], $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceCollection::class, $collection); $this->assertSame($collection->getKeys(), [0]); @@ -163,6 +168,7 @@ public function testGetResourcesWithEmptyCollectionThrowsException(): void { $collection = new ResourceCollection([], $this->manager, $this->createMock(Accessable::class)); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceCollection::class, $collection); $this->assertFalse($collection->has(0)); diff --git a/tests/Unit/V1/ResourceIdentifierCollectionTest.php b/tests/Unit/V1/ResourceIdentifierCollectionTest.php index 805537a..76b6b6f 100644 --- a/tests/Unit/V1/ResourceIdentifierCollectionTest.php +++ b/tests/Unit/V1/ResourceIdentifierCollectionTest.php @@ -38,7 +38,9 @@ public function testCreateWithEmptyArray(): void { $collection = new ResourceIdentifierCollection([], $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceIdentifierCollection::class, $collection); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $collection); $this->assertSame($collection->getKeys(), []); @@ -61,7 +63,9 @@ public function testCreateWithIdentifier(): void $this->parent ); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceIdentifierCollection::class, $collection); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $collection); $this->assertSame($collection->getKeys(), [0, 1, 2]); @@ -85,7 +89,9 @@ public function testCreateWithItem(): void $collection = new ResourceIdentifierCollection([$object], $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceIdentifierCollection::class, $collection); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $collection); $this->assertSame($collection->getKeys(), [0]); @@ -114,6 +120,7 @@ public function testGetResourcesWithEmptyCollectionThrowsException(): void { $collection = new ResourceIdentifierCollection([], $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceIdentifierCollection::class, $collection); $this->assertFalse($collection->has(0)); diff --git a/tests/Unit/V1/ResourceIdentifierTest.php b/tests/Unit/V1/ResourceIdentifierTest.php index c0867f7..1a2b0a7 100644 --- a/tests/Unit/V1/ResourceIdentifierTest.php +++ b/tests/Unit/V1/ResourceIdentifierTest.php @@ -42,7 +42,9 @@ public function testCreateWithObject(): void $identifier = new ResourceIdentifier($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceIdentifier::class, $identifier); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $identifier); $this->assertSame($identifier->getKeys(), ['type', 'id']); @@ -63,6 +65,7 @@ public function testCreateWithObjectAndMeta(): void $identifier = new ResourceIdentifier($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceIdentifier::class, $identifier); $this->assertSame($identifier->get('type'), 'types'); diff --git a/tests/Unit/V1/ResourceItemLinkTest.php b/tests/Unit/V1/ResourceItemLinkTest.php index c45b83c..9c42bd5 100644 --- a/tests/Unit/V1/ResourceItemLinkTest.php +++ b/tests/Unit/V1/ResourceItemLinkTest.php @@ -43,7 +43,9 @@ public function testParsingPropertiesExists(): void $link = new ResourceItemLink($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceItemLink::class, $link); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $link); $this->assertSame($link->getKeys(), ['self', 'custom', 'related']); diff --git a/tests/Unit/V1/ResourceItemTest.php b/tests/Unit/V1/ResourceItemTest.php index 44030be..bbf4530 100644 --- a/tests/Unit/V1/ResourceItemTest.php +++ b/tests/Unit/V1/ResourceItemTest.php @@ -44,7 +44,9 @@ public function testCreateWithObject(): void $item = new ResourceItem($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceItem::class, $item); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $item); $this->assertSame($item->getKeys(), ['type', 'id']); @@ -81,6 +83,7 @@ public function testCreateWithFullObject(): void $item = new ResourceItem($object, $this->manager, $this->parent); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(ResourceItem::class, $item); $this->assertSame($item->get('type'), 'type'); diff --git a/tests/Unit/V1/ResourceNullTest.php b/tests/Unit/V1/ResourceNullTest.php index e350356..9d33340 100644 --- a/tests/Unit/V1/ResourceNullTest.php +++ b/tests/Unit/V1/ResourceNullTest.php @@ -39,6 +39,7 @@ public function testCreateWithDataProvider(mixed $input): void $this->parent ); + /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Accessable::class, $resource); $this->assertFalse($resource->has('something'));