Skip to content

Commit 55f58e3

Browse files
[DoctrineBridge] Strengthen EM reset logic
1 parent cd1fbae commit 55f58e3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ManagerRegistry.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) {
5959
$name = $this->aliases[$name] ?? $name;
6060
$wrappedInstance = match (true) {
6161
isset($this->fileMap[$name]) => $this->load($this->fileMap[$name], false),
62-
(new \ReflectionMethod($this, $method = $this->methodMap[$name]))->isStatic() => $this->{$method}($this, false),
62+
!$method = $this->methodMap[$name] ?? null => throw new \LogicException(\sprintf('The "%s" service is synthetic and cannot be reset.', $name)),
63+
(new \ReflectionMethod($this, $method))->isStatic() => $this->{$method}($this, false),
6364
default => $this->{$method}(false),
6465
};
6566
$manager->setProxyInitializer(null);
@@ -86,7 +87,8 @@ function () use ($name) {
8687

8788
return match (true) {
8889
isset($this->fileMap[$name]) => $this->load($this->fileMap[$name], false),
89-
(new \ReflectionMethod($this, $method = $this->methodMap[$name]))->isStatic() => $this->{$method}($this, false),
90+
!$method = $this->methodMap[$name] ?? null => throw new \LogicException(\sprintf('The "%s" service is synthetic and cannot be reset.', $name)),
91+
(new \ReflectionMethod($this, $method))->isStatic() => $this->{$method}($this, false),
9092
default => $this->{$method}(false),
9193
};
9294
},

0 commit comments

Comments
 (0)