Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Compiler/RemoveUnusedDefinitionsPass.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
43 continue; | 43 continue; |
44 } | 44 } |
45 | 45 |
46 if ($graph->hasNode($id)) { | 46 if ($graph->hasNode($id)) { |
47 $edges = $graph->getNode($id)->getInEdges(); | 47 $edges = $graph->getNode($id)->getInEdges(); |
48 $referencingAliases = array(); | 48 $referencingAliases = []; |
49 $sourceIds = array(); | 49 $sourceIds = []; |
50 foreach ($edges as $edge) { | 50 foreach ($edges as $edge) { |
51 if ($edge->isWeak()) { | 51 if ($edge->isWeak()) { |
52 continue; | 52 continue; |
53 } | 53 } |
54 $node = $edge->getSourceNode(); | 54 $node = $edge->getSourceNode(); |
56 | 56 |
57 if ($node->isAlias()) { | 57 if ($node->isAlias()) { |
58 $referencingAliases[] = $node->getValue(); | 58 $referencingAliases[] = $node->getValue(); |
59 } | 59 } |
60 } | 60 } |
61 $isReferenced = (count(array_unique($sourceIds)) - count($referencingAliases)) > 0; | 61 $isReferenced = (\count(array_unique($sourceIds)) - \count($referencingAliases)) > 0; |
62 } else { | 62 } else { |
63 $referencingAliases = array(); | 63 $referencingAliases = []; |
64 $isReferenced = false; | 64 $isReferenced = false; |
65 } | 65 } |
66 | 66 |
67 if (1 === count($referencingAliases) && false === $isReferenced) { | 67 if (1 === \count($referencingAliases) && false === $isReferenced) { |
68 $container->setDefinition((string) reset($referencingAliases), $definition); | 68 $container->setDefinition((string) reset($referencingAliases), $definition); |
69 $definition->setPublic(!$definition->isPrivate()); | 69 $definition->setPublic(!$definition->isPrivate()); |
70 $definition->setPrivate(reset($referencingAliases)->isPrivate()); | 70 $definition->setPrivate(reset($referencingAliases)->isPrivate()); |
71 $container->removeDefinition($id); | 71 $container->removeDefinition($id); |
72 $container->log($this, sprintf('Removed service "%s"; reason: replaces alias %s.', $id, reset($referencingAliases))); | 72 $container->log($this, sprintf('Removed service "%s"; reason: replaces alias %s.', $id, reset($referencingAliases))); |
73 } elseif (0 === count($referencingAliases) && false === $isReferenced) { | 73 } elseif (0 === \count($referencingAliases) && false === $isReferenced) { |
74 $container->removeDefinition($id); | 74 $container->removeDefinition($id); |
75 $container->resolveEnvPlaceholders(serialize($definition)); | 75 $container->resolveEnvPlaceholders(serialize($definition)); |
76 $container->log($this, sprintf('Removed service "%s"; reason: unused.', $id)); | 76 $container->log($this, sprintf('Removed service "%s"; reason: unused.', $id)); |
77 $hasChanged = true; | 77 $hasChanged = true; |
78 } | 78 } |