Skip to content

Commit

Permalink
EntityManager methods should rather return mixed than the documented …
Browse files Browse the repository at this point in the history
…object
  • Loading branch information
ondrejmirtes committed Oct 6, 2017
1 parent 3e24f78 commit a8fd4a5
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PhpParser\Node\Expr\MethodCall;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
Expand Down Expand Up @@ -32,23 +33,24 @@ public function getTypeFromMethodCall(
Scope $scope
): Type
{
$mixedType = new MixedType();
if (count($methodCall->args) === 0) {
return $methodReflection->getReturnType();
return $mixedType;
}
$arg = $methodCall->args[0]->value;
if (!($arg instanceof \PhpParser\Node\Expr\ClassConstFetch)) {
return $methodReflection->getReturnType();
return $mixedType;
}

$class = $arg->class;
if (!($class instanceof \PhpParser\Node\Name)) {
return $methodReflection->getReturnType();
return $mixedType;
}

$class = (string) $class;

if ($class === 'static') {
return $methodReflection->getReturnType();
return $mixedType;
}

if ($class === 'self') {
Expand Down

0 comments on commit a8fd4a5

Please # to comment.