Skip to content

Commit 688dff7

Browse files
committed
Return mixed instead of object from Container::getService()
1 parent ed5a66f commit 688dff7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Type/Nette/ServiceLocatorDynamicReturnTypeExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PhpParser\Node\Expr\MethodCall;
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Reflection\MethodReflection;
8+
use PHPStan\Type\MixedType;
89
use PHPStan\Type\ObjectType;
910
use PHPStan\Type\TrueBooleanType;
1011
use PHPStan\Type\Type;
@@ -23,11 +24,15 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
2324
return in_array($methodReflection->getName(), [
2425
'getByType',
2526
'createInstance',
27+
'getService',
2628
], true);
2729
}
2830

2931
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
3032
{
33+
if ($methodReflection->getName() === 'getService') {
34+
return new MixedType();
35+
}
3136
if (count($methodCall->args) === 0) {
3237
return $methodReflection->getReturnType();
3338
}

0 commit comments

Comments
 (0)