|
15 | 15 | use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
16 | 16 | use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
|
17 | 17 | use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass;
|
| 18 | +use Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass; |
18 | 19 | use Symfony\Component\DependencyInjection\Container;
|
19 | 20 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
20 | 21 | use Symfony\Component\DependencyInjection\ContainerInterface;
|
@@ -139,29 +140,19 @@ public function dump(array $options = array())
|
139 | 140 | $this->initializeMethodNamesMap('Container' === $baseClass ? Container::class : $baseClass);
|
140 | 141 |
|
141 | 142 | if ($this->getProxyDumper() instanceof NullDumper) {
|
142 |
| - (new AnalyzeServiceReferencesPass(true))->process($this->container); |
143 |
| - $this->circularReferences = array(); |
144 |
| - $checkedNodes = array(); |
145 |
| - foreach ($this->container->getCompiler()->getServiceReferenceGraph()->getNodes() as $id => $node) { |
146 |
| - $currentPath = array($id => $id); |
147 |
| - $this->analyzeCircularReferences($node->getOutEdges(), $checkedNodes, $currentPath); |
148 |
| - } |
149 |
| - foreach ($this->circularReferences as $parent => $ids) { |
150 |
| - $path = array($parent); |
151 |
| - while (!isset($ids[$parent])) { |
152 |
| - foreach ($ids as $id) { |
153 |
| - $path[] = $id; |
154 |
| - $ids = $this->circularReferences[$id]; |
155 |
| - break; |
156 |
| - } |
157 |
| - } |
158 |
| - $path[] = $parent.'". Try running "composer require symfony/proxy-manager-bridge'; |
| 143 | + (new AnalyzeServiceReferencesPass(true, false))->process($this->container); |
| 144 | + try { |
| 145 | + (new CheckCircularReferencesPass())->process($this->container); |
| 146 | + } catch (ServiceCircularReferenceException $e) { |
| 147 | + $path = $e->getPath(); |
| 148 | + end($path); |
| 149 | + $path[key($path)] .= '". Try running "composer require symfony/proxy-manager-bridge'; |
159 | 150 |
|
160 |
| - throw new ServiceCircularReferenceException($parent, $path); |
| 151 | + throw new ServiceCircularReferenceException($e->getServiceId(), $path); |
161 | 152 | }
|
162 | 153 | }
|
163 | 154 |
|
164 |
| - (new AnalyzeServiceReferencesPass())->process($this->container); |
| 155 | + (new AnalyzeServiceReferencesPass(false, !$this->getProxyDumper() instanceof NullDumper))->process($this->container); |
165 | 156 | $this->circularReferences = array();
|
166 | 157 | $checkedNodes = array();
|
167 | 158 | foreach ($this->container->getCompiler()->getServiceReferenceGraph()->getNodes() as $id => $node) {
|
@@ -367,7 +358,7 @@ private function analyzeCircularReferences(array $edges, &$checkedNodes, &$curre
|
367 | 358 | $node = $edge->getDestNode();
|
368 | 359 | $id = $node->getId();
|
369 | 360 |
|
370 |
| - if ($node->getValue() && (($edge->isLazy() && !$this->getProxyDumper() instanceof NullDumper) || $edge->isWeak())) { |
| 361 | + if ($node->getValue() && ($edge->isLazy() || $edge->isWeak())) { |
371 | 362 | // no-op
|
372 | 363 | } elseif (isset($currentPath[$id])) {
|
373 | 364 | foreach (array_reverse($currentPath) as $parentId) {
|
|
0 commit comments