Skip to content

Commit

Permalink
minor #36748 [DI] reduce recursivity of ResolveHotPathPass (nicolas-g…
Browse files Browse the repository at this point in the history
…rekas)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[DI] reduce recursivity of ResolveHotPathPass

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This provides the same end result but doesn't use recursion when possible.

Commits
-------

9d13d88 [DI] reduce recursivity of ResolveHotPathPass
  • Loading branch information
fabpot committed May 8, 2020
2 parents 75e71e3 + 9d13d88 commit 4eb32cf
Showing 1 changed file with 22 additions and 7 deletions.
Expand Up @@ -52,14 +52,29 @@ protected function processValue($value, bool $isRoot = false)
if ($value instanceof ArgumentInterface) {
return $value;
}
if ($value instanceof Definition && $isRoot && (isset($this->resolvedIds[$this->currentId]) || !$value->hasTag($this->tagName) || $value->isDeprecated())) {
return $value->isDeprecated() ? $value->clearTag($this->tagName) : $value;

if ($value instanceof Definition && $isRoot) {
if ($value->isDeprecated()) {
return $value->clearTag($this->tagName);
}

$this->resolvedIds[$this->currentId] = true;

if (!$value->hasTag($this->tagName)) {
return $value;
}
}
if ($value instanceof Reference && ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->has($id = (string) $value)) {
$definition = $this->container->findDefinition($id);
if (!$definition->hasTag($this->tagName) && !$definition->isDeprecated()) {
$this->resolvedIds[$id] = true;
$definition->addTag($this->tagName);

if ($value instanceof Reference && ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->hasDefinition($id = (string) $value)) {
$definition = $this->container->getDefinition($id);

if ($definition->isDeprecated() || $definition->hasTag($this->tagName)) {
return $value;
}

$definition->addTag($this->tagName);

if (isset($this->resolvedIds[$id])) {
parent::processValue($definition, false);
}

Expand Down

0 comments on commit 4eb32cf

Please sign in to comment.