Skip to content

Commit 1eab515

Browse files
committed
merged branch fabpot/container-dumper-fix (PR symfony#6959)
This PR was submitted for the 2.2 branch but it was merged into the 2.0 branch instead (closes symfony#6959). Commits ------- ad889c9 [DependencyInjection] fixed a circular call (closes symfony#6864) Discussion ---------- [DependencyInjection] fixed a circular call (closes symfony#6864) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#6864 | License | MIT | Doc PR | n/a
2 parents 115114b + 74f2fcf commit 1eab515

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -952,23 +952,25 @@ private function getDefinitionsFromArguments(array $arguments)
952952
*
953953
* @return Boolean
954954
*/
955-
private function hasReference($id, array $arguments, $deep = false)
955+
private function hasReference($id, array $arguments, $deep = false, $visited = array())
956956
{
957957
foreach ($arguments as $argument) {
958958
if (is_array($argument)) {
959-
if ($this->hasReference($id, $argument, $deep)) {
959+
if ($this->hasReference($id, $argument, $deep, $visited)) {
960960
return true;
961961
}
962962
} elseif ($argument instanceof Reference) {
963963
if ($id === (string) $argument) {
964964
return true;
965965
}
966966

967-
if ($deep) {
967+
if ($deep && !isset($visited[(string) $argument])) {
968+
$visited[(string) $argument] = true;
969+
968970
$service = $this->container->getDefinition((string) $argument);
969971
$arguments = array_merge($service->getMethodCalls(), $service->getArguments(), $service->getProperties());
970972

971-
if ($this->hasReference($id, $arguments, $deep)) {
973+
if ($this->hasReference($id, $arguments, $deep, $visited)) {
972974
return true;
973975
}
974976
}

0 commit comments

Comments
 (0)