Skip to content

Commit 83d8d49

Browse files
[DI] reduce recursivity of ResolveHotPathPass
1 parent b9f508f commit 83d8d49

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

Compiler/ResolveHotPathPass.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,29 @@ protected function processValue($value, bool $isRoot = false)
5252
if ($value instanceof ArgumentInterface) {
5353
return $value;
5454
}
55-
if ($value instanceof Definition && $isRoot && (isset($this->resolvedIds[$this->currentId]) || !$value->hasTag($this->tagName) || $value->isDeprecated())) {
56-
return $value->isDeprecated() ? $value->clearTag($this->tagName) : $value;
55+
56+
if ($value instanceof Definition && $isRoot) {
57+
if ($value->isDeprecated()) {
58+
return $value->clearTag($this->tagName);
59+
}
60+
61+
$this->resolvedIds[$this->currentId] = true;
62+
63+
if (!$value->hasTag($this->tagName)) {
64+
return $value;
65+
}
5766
}
58-
if ($value instanceof Reference && ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->has($id = (string) $value)) {
59-
$definition = $this->container->findDefinition($id);
60-
if (!$definition->hasTag($this->tagName) && !$definition->isDeprecated()) {
61-
$this->resolvedIds[$id] = true;
62-
$definition->addTag($this->tagName);
67+
68+
if ($value instanceof Reference && ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->hasDefinition($id = (string) $value)) {
69+
$definition = $this->container->getDefinition($id);
70+
71+
if ($definition->isDeprecated() || $definition->hasTag($this->tagName)) {
72+
return $value;
73+
}
74+
75+
$definition->addTag($this->tagName);
76+
77+
if (isset($this->resolvedIds[$id])) {
6378
parent::processValue($definition, false);
6479
}
6580

0 commit comments

Comments
 (0)