diff --git a/src/Traits/ReflectionFunctionLikeTrait.php b/src/Traits/ReflectionFunctionLikeTrait.php index b3c35677..c455cb23 100644 --- a/src/Traits/ReflectionFunctionLikeTrait.php +++ b/src/Traits/ReflectionFunctionLikeTrait.php @@ -186,6 +186,8 @@ public function getReturnType() $returnType = $returnType->toString(); } elseif (is_string($returnType)) { $isBuiltin = true; + } else { + return null; } return new ReflectionType($returnType, false, $isBuiltin); diff --git a/tests/ReflectionFunctionTest.php b/tests/ReflectionFunctionTest.php index 1815fb01..2a07c2f6 100644 --- a/tests/ReflectionFunctionTest.php +++ b/tests/ReflectionFunctionTest.php @@ -126,6 +126,11 @@ public function testGetReturnTypeMethod() $this->assertSame($originalReturnType->allowsNull(), $parsedReturnType->allowsNull()); $this->assertSame($originalReturnType->isBuiltin(), $parsedReturnType->isBuiltin()); $this->assertSame($originalReturnType->__toString(), $parsedReturnType->__toString()); + } else { + $this->assertSame( + $originalRefFunction->getReturnType(), + $refFunction->getReturnType() + ); } } }