Skip to content

Commit b56955f

Browse files
author
Stefan Siegl
committed
Dynamic return type for EntityManager#merge
1 parent af4cb66 commit b56955f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Type/Doctrine/EntityManagerGetRepositoryDynamicReturnTypeExtension.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public function getClass(): string
2727

2828
public function isMethodSupported(MethodReflection $methodReflection): bool
2929
{
30-
return $methodReflection->getName() === 'getRepository';
30+
return $methodReflection->getName() === 'getRepository' ||
31+
$methodReflection->getName() === 'merge';
3132
}
3233

3334
public function getTypeFromMethodCall(
@@ -39,6 +40,11 @@ public function getTypeFromMethodCall(
3940
if (count($methodCall->args) === 0) {
4041
return $methodReflection->getReturnType();
4142
}
43+
44+
if ($methodReflection->getName() === 'merge') {
45+
return $scope->getType($methodCall->args[0]->value);
46+
}
47+
4248
$arg = $methodCall->args[0]->value;
4349
if (!($arg instanceof \PhpParser\Node\Expr\ClassConstFetch)) {
4450
return $methodReflection->getReturnType();

0 commit comments

Comments
 (0)