Skip to content

Commit a8fd4a5

Browse files
committed
EntityManager methods should rather return mixed than the documented object
1 parent 3e24f78 commit a8fd4a5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Type/Doctrine/EntityManagerFindDynamicReturnTypeExtension.php

Lines changed: 6 additions & 4 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\Type;
1011
use PHPStan\Type\TypeCombinator;
@@ -32,23 +33,24 @@ public function getTypeFromMethodCall(
3233
Scope $scope
3334
): Type
3435
{
36+
$mixedType = new MixedType();
3537
if (count($methodCall->args) === 0) {
36-
return $methodReflection->getReturnType();
38+
return $mixedType;
3739
}
3840
$arg = $methodCall->args[0]->value;
3941
if (!($arg instanceof \PhpParser\Node\Expr\ClassConstFetch)) {
40-
return $methodReflection->getReturnType();
42+
return $mixedType;
4143
}
4244

4345
$class = $arg->class;
4446
if (!($class instanceof \PhpParser\Node\Name)) {
45-
return $methodReflection->getReturnType();
47+
return $mixedType;
4648
}
4749

4850
$class = (string) $class;
4951

5052
if ($class === 'static') {
51-
return $methodReflection->getReturnType();
53+
return $mixedType;
5254
}
5355

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

0 commit comments

Comments
 (0)