Skip to content

Commit d3623c7

Browse files
committed
Service locator methods should rather return mixed than the documented object
1 parent 688dff7 commit d3623c7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Type/Nette/ServiceLocatorDynamicReturnTypeExtension.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,27 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
3030

3131
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
3232
{
33+
$mixedType = new MixedType();
3334
if ($methodReflection->getName() === 'getService') {
34-
return new MixedType();
35+
return $mixedType;
3536
}
3637
if (count($methodCall->args) === 0) {
37-
return $methodReflection->getReturnType();
38+
return $mixedType;
3839
}
3940
$arg = $methodCall->args[0]->value;
4041
if (!($arg instanceof \PhpParser\Node\Expr\ClassConstFetch)) {
41-
return $methodReflection->getReturnType();
42+
return $mixedType;
4243
}
4344

4445
$class = $arg->class;
4546
if (!($class instanceof \PhpParser\Node\Name)) {
46-
return $methodReflection->getReturnType();
47+
return $mixedType;
4748
}
4849

4950
$class = (string) $class;
5051

5152
if ($class === 'static') {
52-
return $methodReflection->getReturnType();
53+
return $mixedType;
5354
}
5455

5556
if ($class === 'self') {

0 commit comments

Comments
 (0)