diff --git a/src/ReturnEntity.php b/src/ReturnEntity.php index 253e534e..21b2f355 100644 --- a/src/ReturnEntity.php +++ b/src/ReturnEntity.php @@ -16,6 +16,7 @@ use function assert; use function class_exists; +use function is_a; use function substr; final class ReturnEntity implements ReturnEntityInterface @@ -30,7 +31,7 @@ public function __invoke(ReflectionMethod $method): string|null $returnTypeClass = $this->getReturnTypeName($returnType); - if (class_exists($returnTypeClass) && $returnTypeClass !== Pages::class) { + if (class_exists($returnTypeClass) && ! is_a($returnTypeClass, PagesInterface::class, true)) { return $returnTypeClass; } diff --git a/tests/Fake/FakePages.php b/tests/Fake/FakePages.php new file mode 100644 index 00000000..6c3bdda0 --- /dev/null +++ b/tests/Fake/FakePages.php @@ -0,0 +1,33 @@ + */ diff --git a/tests/ReturnTypeTest.php b/tests/ReturnTypeTest.php index 5c1b932d..98740f5b 100644 --- a/tests/ReturnTypeTest.php +++ b/tests/ReturnTypeTest.php @@ -42,6 +42,14 @@ public function testnoPhpDoc(): void $this->assertSame(null, $entity); } + public function testNoPhpDocFakePages(): void + { + $method = new ReflectionMethod(new FakeReturn(), 'noPhpDocFakePages'); + $entity = (new ReturnEntity())($method); + + $this->assertSame(null, $entity); + } + public function testNoReturnDoc(): void { $method = new ReflectionMethod(new FakeReturn(), 'noReturnDoc'); @@ -50,6 +58,14 @@ public function testNoReturnDoc(): void $this->assertSame(null, $entity); } + public function testNoReturnDocFakePages(): void + { + $method = new ReflectionMethod(new FakeReturn(), 'noReturnDocFakePages'); + $entity = (new ReturnEntity())($method); + + $this->assertSame(null, $entity); + } + public function testNonEntityGeneric(): void { $method = new ReflectionMethod(new FakeReturn(), 'nonEntityGeneric');