Skip to content

Commit

Permalink
Dynamic return type for EntityManager#merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Siegl committed Dec 1, 2017
1 parent af4cb66 commit b56955f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public function getClass(): string

public function isMethodSupported(MethodReflection $methodReflection): bool
{
return $methodReflection->getName() === 'getRepository';
return $methodReflection->getName() === 'getRepository' ||
$methodReflection->getName() === 'merge';
}

public function getTypeFromMethodCall(
Expand All @@ -39,6 +40,11 @@ public function getTypeFromMethodCall(
if (count($methodCall->args) === 0) {
return $methodReflection->getReturnType();
}

if ($methodReflection->getName() === 'merge') {
return $scope->getType($methodCall->args[0]->value);
}

$arg = $methodCall->args[0]->value;
if (!($arg instanceof \PhpParser\Node\Expr\ClassConstFetch)) {
return $methodReflection->getReturnType();
Expand Down

0 comments on commit b56955f

Please sign in to comment.