Skip to content

Commit bdd8b83

Browse files
committed
Fix problem with not loaded return type
1 parent ae19b1b commit bdd8b83

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

spec/Proget/Tests/PHPStan/PhpSpec/FooSpec.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public function it_is_initializable(): void
2121
$this->shouldHaveType(Foo::class);
2222
}
2323

24+
public function it_should_return_empty_string(): void
25+
{
26+
$this->foo()->shouldBe('');
27+
}
28+
2429
public function it_should_make_baz(Baz $baz): void
2530
{
2631
$baz->make()->willReturn(123);

src/Reflection/ObjectBehaviorMethodsClassReflectionExtension.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ public function getMethod(ClassReflection $classReflection, string $methodName):
7878

7979
private function replaceReturnType(MethodReflection $method): void
8080
{
81+
$method->getVariants();
8182
$methodReflection = new \ReflectionClass($method);
82-
$returnType = $methodReflection->getProperty('nativeReturnType');
83+
$returnType = $methodReflection->getProperty('returnType');
8384
$returnType->setAccessible(true);
8485
$returnType->setValue($method, new SubjectType($returnType->getValue($method)));
8586

86-
$nativeReturnType = $methodReflection->getProperty('returnType');
87+
$nativeReturnType = $methodReflection->getProperty('nativeReturnType');
8788
$nativeReturnType->setAccessible(true);
8889
$nativeReturnType->setValue($method, new SubjectType($nativeReturnType->getValue($method)));
8990

0 commit comments

Comments
 (0)