Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9c32b1e

Browse files
[DI] Fix missing "id" normalization when dumping the container
1 parent c572e6c commit 9c32b1e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,9 +1232,9 @@ private function addAliases()
12321232
$code = " \$this->aliases = array(\n";
12331233
ksort($aliases);
12341234
foreach ($aliases as $alias => $id) {
1235-
$id = (string) $id;
1235+
$id = $this->container->normalizeId($id);
12361236
while (isset($aliases[$id])) {
1237-
$id = (string) $aliases[$id];
1237+
$id = $this->container->normalizeId($aliases[$id]);
12381238
}
12391239
$code .= ' '.$this->doExport($alias).' => '.$this->doExport($id).",\n";
12401240
}
@@ -1555,7 +1555,7 @@ private function getServiceCallsFromArguments(array $arguments, array &$calls, $
15551555
if (is_array($argument)) {
15561556
$this->getServiceCallsFromArguments($argument, $calls, $isPreInstance, $callerId, $behavior, $step);
15571557
} elseif ($argument instanceof Reference) {
1558-
$id = (string) $argument;
1558+
$id = $this->container->normalizeId($argument);
15591559

15601560
if (!isset($calls[$id])) {
15611561
$calls[$id] = (int) ($isPreInstance && isset($this->circularReferences[$callerId][$id]));
@@ -1625,7 +1625,7 @@ private function hasReference($id, array $arguments, $deep = false, array &$visi
16251625

16261626
continue;
16271627
} elseif ($argument instanceof Reference) {
1628-
$argumentId = (string) $argument;
1628+
$argumentId = $this->container->normalizeId($argument);
16291629
if ($id === $argumentId) {
16301630
return true;
16311631
}
@@ -1790,11 +1790,12 @@ private function dumpValue($value, $interpolate = true)
17901790
} elseif ($value instanceof Variable) {
17911791
return '$'.$value;
17921792
} elseif ($value instanceof Reference) {
1793-
if (null !== $this->referenceVariables && isset($this->referenceVariables[$id = (string) $value])) {
1793+
$id = $this->container->normalizeId($value);
1794+
if (null !== $this->referenceVariables && isset($this->referenceVariables[$id])) {
17941795
return $this->dumpValue($this->referenceVariables[$id], $interpolate);
17951796
}
17961797

1797-
return $this->getServiceCall((string) $value, $value);
1798+
return $this->getServiceCall($id, $value);
17981799
} elseif ($value instanceof Expression) {
17991800
return $this->getExpressionLanguage()->compile((string) $value, array('this' => 'container'));
18001801
} elseif ($value instanceof Parameter) {
@@ -1881,6 +1882,7 @@ private function getServiceCall($id, Reference $reference = null)
18811882
while ($this->container->hasAlias($id)) {
18821883
$id = (string) $this->container->getAlias($id);
18831884
}
1885+
$id = $this->container->normalizeId($id);
18841886

18851887
if ('service_container' === $id) {
18861888
return '$this';

0 commit comments

Comments
 (0)