From eb05bb9e0d1dcdf50b1e9925f6e87622655cf547 Mon Sep 17 00:00:00 2001 From: Lisachenko Alexander Date: Sun, 21 Feb 2016 17:46:34 +0300 Subject: [PATCH] Fix incorrect behavior for empty return types, related to #5 --- src/Traits/ReflectionFunctionLikeTrait.php | 2 ++ tests/ReflectionFunctionTest.php | 5 +++++ 2 files changed, 7 insertions(+) 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() + ); } } }