Skip to content

Commit eb05bb9

Browse files
committed
Fix incorrect behavior for empty return types, related to #5
1 parent 872c383 commit eb05bb9

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Traits/ReflectionFunctionLikeTrait.php

+2
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ public function getReturnType()
186186
$returnType = $returnType->toString();
187187
} elseif (is_string($returnType)) {
188188
$isBuiltin = true;
189+
} else {
190+
return null;
189191
}
190192

191193
return new ReflectionType($returnType, false, $isBuiltin);

tests/ReflectionFunctionTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ public function testGetReturnTypeMethod()
126126
$this->assertSame($originalReturnType->allowsNull(), $parsedReturnType->allowsNull());
127127
$this->assertSame($originalReturnType->isBuiltin(), $parsedReturnType->isBuiltin());
128128
$this->assertSame($originalReturnType->__toString(), $parsedReturnType->__toString());
129+
} else {
130+
$this->assertSame(
131+
$originalRefFunction->getReturnType(),
132+
$refFunction->getReturnType()
133+
);
129134
}
130135
}
131136
}

0 commit comments

Comments
 (0)