Skip to content

Commit 6129ae2

Browse files
committed
minor symfony#25383 [DI] Force root-namespace for function calls in the dumper container (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [DI] Force root-namespace for function calls in the dumper container | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Was not needed before 3.4, but now that the dumped container is namespaced, it is required. Commits ------- f87380c [DI] Force root-namespace for function calls in the dumper container
2 parents 05ffb6f + f87380c commit 6129ae2

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ private function addServiceConfigurator(Definition $definition, $variableName =
695695
return sprintf(" (%s)->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
696696
}
697697

698-
return sprintf(" call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
698+
return sprintf(" \\call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
699699
}
700700

701701
return sprintf(" %s(\$%s);\n", $callable, $variableName);
@@ -895,7 +895,7 @@ private function addNewInstance(Definition $definition, $return, $instantiation,
895895
return $return.sprintf("(%s)->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
896896
}
897897

898-
return $return.sprintf("call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? ', '.implode(', ', $arguments) : '');
898+
return $return.sprintf("\\call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? ', '.implode(', ', $arguments) : '');
899899
}
900900

901901
return $return.sprintf("%s(%s);\n", $this->dumpLiteralClass($this->dumpValue($callable)), $arguments ? implode(', ', $arguments) : '');
@@ -948,11 +948,11 @@ public function __construct()
948948
949949
EOF;
950950
if (null !== $this->targetDirRegex) {
951-
$dir = $this->asFiles ? '$this->targetDirs[0] = dirname(__DIR__)' : '__DIR__';
951+
$dir = $this->asFiles ? '$this->targetDirs[0] = \\dirname(__DIR__)' : '__DIR__';
952952
$code .= <<<EOF
953953
\$dir = {$dir};
954954
for (\$i = 1; \$i <= {$this->targetDirMaxMatches}; ++\$i) {
955-
\$this->targetDirs[\$i] = \$dir = dirname(\$dir);
955+
\$this->targetDirs[\$i] = \$dir = \\dirname(\$dir);
956956
}
957957
958958
EOF;
@@ -1722,7 +1722,7 @@ private function dumpValue($value, $interpolate = true)
17221722
}
17231723

17241724
if ($factory[0] instanceof Definition) {
1725-
return sprintf("call_user_func(array(%s, '%s')%s)", $this->dumpValue($factory[0]), $factory[1], count($arguments) > 0 ? ', '.implode(', ', $arguments) : '');
1725+
return sprintf("\\call_user_func(array(%s, '%s')%s)", $this->dumpValue($factory[0]), $factory[1], count($arguments) > 0 ? ', '.implode(', ', $arguments) : '');
17261726
}
17271727

17281728
if ($factory[0] instanceof Reference) {

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct()
2323
{
2424
$dir = __DIR__;
2525
for ($i = 1; $i <= 5; ++$i) {
26-
$this->targetDirs[$i] = $dir = dirname($dir);
26+
$this->targetDirs[$i] = $dir = \dirname($dir);
2727
}
2828
$this->parameters = $this->getDefaultParameters();
2929

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct()
2323
{
2424
$dir = __DIR__;
2525
for ($i = 1; $i <= 5; ++$i) {
26-
$this->targetDirs[$i] = $dir = dirname($dir);
26+
$this->targetDirs[$i] = $dir = \dirname($dir);
2727
}
2828
$this->parameters = $this->getDefaultParameters();
2929

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ protected function getFooService()
223223
*/
224224
protected function getFoo_BazService()
225225
{
226-
$this->services['foo.baz'] = $instance = call_user_func(array($this->getParameter('baz_class'), 'getInstance'));
226+
$this->services['foo.baz'] = $instance = \call_user_func(array($this->getParameter('baz_class'), 'getInstance'));
227227

228-
call_user_func(array($this->getParameter('baz_class'), 'configureStatic1'), $instance);
228+
\call_user_func(array($this->getParameter('baz_class'), 'configureStatic1'), $instance);
229229

230230
return $instance;
231231
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ class ProjectServiceContainer extends Container
281281

282282
public function __construct()
283283
{
284-
$dir = $this->targetDirs[0] = dirname(__DIR__);
284+
$dir = $this->targetDirs[0] = \dirname(__DIR__);
285285
for ($i = 1; $i <= 5; ++$i) {
286-
$this->targetDirs[$i] = $dir = dirname($dir);
286+
$this->targetDirs[$i] = $dir = \dirname($dir);
287287
}
288288
$this->parameters = $this->getDefaultParameters();
289289

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct()
2323
{
2424
$dir = __DIR__;
2525
for ($i = 1; $i <= 5; ++$i) {
26-
$this->targetDirs[$i] = $dir = dirname($dir);
26+
$this->targetDirs[$i] = $dir = \dirname($dir);
2727
}
2828
$this->parameters = $this->getDefaultParameters();
2929

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct()
2323
{
2424
$dir = __DIR__;
2525
for ($i = 1; $i <= 5; ++$i) {
26-
$this->targetDirs[$i] = $dir = dirname($dir);
26+
$this->targetDirs[$i] = $dir = \dirname($dir);
2727
}
2828
$this->parameters = $this->getDefaultParameters();
2929

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct()
2323
{
2424
$dir = __DIR__;
2525
for ($i = 1; $i <= 5; ++$i) {
26-
$this->targetDirs[$i] = $dir = dirname($dir);
26+
$this->targetDirs[$i] = $dir = \dirname($dir);
2727
}
2828
$this->services = array();
2929
$this->methodMap = array(

0 commit comments

Comments
 (0)