Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Compiler/InlineServiceDefinitionsPass.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | c2387f117808 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
21 * | 21 * |
22 * @author Johannes M. Schmitt <schmittjoh@gmail.com> | 22 * @author Johannes M. Schmitt <schmittjoh@gmail.com> |
23 */ | 23 */ |
24 class InlineServiceDefinitionsPass extends AbstractRecursivePass implements RepeatablePassInterface | 24 class InlineServiceDefinitionsPass extends AbstractRecursivePass implements RepeatablePassInterface |
25 { | 25 { |
26 private $cloningIds = array(); | 26 private $cloningIds = []; |
27 private $inlinedServiceIds = array(); | 27 private $inlinedServiceIds = []; |
28 | 28 |
29 /** | 29 /** |
30 * {@inheritdoc} | 30 * {@inheritdoc} |
31 */ | 31 */ |
32 public function setRepeatedPass(RepeatedPass $repeatedPass) | 32 public function setRepeatedPass(RepeatedPass $repeatedPass) |
86 | 86 |
87 if (isset($this->cloningIds[$id])) { | 87 if (isset($this->cloningIds[$id])) { |
88 $ids = array_keys($this->cloningIds); | 88 $ids = array_keys($this->cloningIds); |
89 $ids[] = $id; | 89 $ids[] = $id; |
90 | 90 |
91 throw new ServiceCircularReferenceException($id, array_slice($ids, array_search($id, $ids))); | 91 throw new ServiceCircularReferenceException($id, \array_slice($ids, array_search($id, $ids))); |
92 } | 92 } |
93 | 93 |
94 $this->cloningIds[$id] = true; | 94 $this->cloningIds[$id] = true; |
95 try { | 95 try { |
96 return $this->processValue($definition); | 96 return $this->processValue($definition); |
124 | 124 |
125 if ($this->currentId == $id) { | 125 if ($this->currentId == $id) { |
126 return false; | 126 return false; |
127 } | 127 } |
128 | 128 |
129 $ids = array(); | 129 $ids = []; |
130 $isReferencedByConstructor = false; | |
130 foreach ($graph->getNode($id)->getInEdges() as $edge) { | 131 foreach ($graph->getNode($id)->getInEdges() as $edge) { |
131 if ($edge->isWeak()) { | 132 $isReferencedByConstructor = $isReferencedByConstructor || $edge->isReferencedByConstructor(); |
133 if ($edge->isWeak() || $edge->isLazy()) { | |
132 return false; | 134 return false; |
133 } | 135 } |
134 $ids[] = $edge->getSourceNode()->getId(); | 136 $ids[] = $edge->getSourceNode()->getId(); |
135 } | 137 } |
136 | 138 |
137 if (count(array_unique($ids)) > 1) { | 139 if (!$ids) { |
140 return true; | |
141 } | |
142 | |
143 if (\count(array_unique($ids)) > 1) { | |
138 return false; | 144 return false; |
139 } | 145 } |
140 | 146 |
141 if (count($ids) > 1 && is_array($factory = $definition->getFactory()) && ($factory[0] instanceof Reference || $factory[0] instanceof Definition)) { | 147 if (\count($ids) > 1 && \is_array($factory = $definition->getFactory()) && ($factory[0] instanceof Reference || $factory[0] instanceof Definition)) { |
142 return false; | 148 return false; |
143 } | 149 } |
144 | 150 |
145 return !$ids || $this->container->getDefinition($ids[0])->isShared(); | 151 return $this->container->getDefinition($ids[0])->isShared(); |
146 } | 152 } |
147 } | 153 } |