From f87380c22a6371103440cff77da5cd83b7a07212 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 7 Dec 2017 18:32:09 +0100 Subject: [PATCH] [DI] Force root-namespace for function calls in the dumper container --- .../Component/DependencyInjection/Dumper/PhpDumper.php | 10 +++++----- .../Tests/Fixtures/php/services12.php | 2 +- .../Tests/Fixtures/php/services26.php | 2 +- .../Tests/Fixtures/php/services9.php | 4 ++-- .../Tests/Fixtures/php/services9_as_files.txt | 4 ++-- .../Tests/Fixtures/php/services_array_params.php | 2 +- .../Tests/Fixtures/php/services_inline_requires.php | 2 +- .../Tests/Fixtures/php/services_legacy_privates.php | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 0f5e33afb6..e0e6be7613 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -695,7 +695,7 @@ EOTXT; return sprintf(" (%s)->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName); } - return sprintf(" call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName); + return sprintf(" \\call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName); } return sprintf(" %s(\$%s);\n", $callable, $variableName); @@ -895,7 +895,7 @@ EOF; return $return.sprintf("(%s)->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : ''); } - return $return.sprintf("call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? ', '.implode(', ', $arguments) : ''); + return $return.sprintf("\\call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? ', '.implode(', ', $arguments) : ''); } return $return.sprintf("%s(%s);\n", $this->dumpLiteralClass($this->dumpValue($callable)), $arguments ? implode(', ', $arguments) : ''); @@ -948,11 +948,11 @@ class $class extends $baseClass EOF; if (null !== $this->targetDirRegex) { - $dir = $this->asFiles ? '$this->targetDirs[0] = dirname(__DIR__)' : '__DIR__'; + $dir = $this->asFiles ? '$this->targetDirs[0] = \\dirname(__DIR__)' : '__DIR__'; $code .= <<targetDirMaxMatches}; ++\$i) { - \$this->targetDirs[\$i] = \$dir = dirname(\$dir); + \$this->targetDirs[\$i] = \$dir = \\dirname(\$dir); } EOF; @@ -1722,7 +1722,7 @@ EOF; } if ($factory[0] instanceof Definition) { - return sprintf("call_user_func(array(%s, '%s')%s)", $this->dumpValue($factory[0]), $factory[1], count($arguments) > 0 ? ', '.implode(', ', $arguments) : ''); + return sprintf("\\call_user_func(array(%s, '%s')%s)", $this->dumpValue($factory[0]), $factory[1], count($arguments) > 0 ? ', '.implode(', ', $arguments) : ''); } if ($factory[0] instanceof Reference) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index c5c434ec7d..48750c480f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -23,7 +23,7 @@ class ProjectServiceContainer extends Container { $dir = __DIR__; for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = dirname($dir); + $this->targetDirs[$i] = $dir = \dirname($dir); } $this->parameters = $this->getDefaultParameters(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php index 257a145c6f..5c8773c380 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php @@ -23,7 +23,7 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container { $dir = __DIR__; for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = dirname($dir); + $this->targetDirs[$i] = $dir = \dirname($dir); } $this->parameters = $this->getDefaultParameters(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php index 467733f467..4220c146aa 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php @@ -223,9 +223,9 @@ class ProjectServiceContainer extends Container */ protected function getFoo_BazService() { - $this->services['foo.baz'] = $instance = call_user_func(array($this->getParameter('baz_class'), 'getInstance')); + $this->services['foo.baz'] = $instance = \call_user_func(array($this->getParameter('baz_class'), 'getInstance')); - call_user_func(array($this->getParameter('baz_class'), 'configureStatic1'), $instance); + \call_user_func(array($this->getParameter('baz_class'), 'configureStatic1'), $instance); return $instance; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt index 59ace1ddf3..0ee660df4d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt @@ -281,9 +281,9 @@ class ProjectServiceContainer extends Container public function __construct() { - $dir = $this->targetDirs[0] = dirname(__DIR__); + $dir = $this->targetDirs[0] = \dirname(__DIR__); for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = dirname($dir); + $this->targetDirs[$i] = $dir = \dirname($dir); } $this->parameters = $this->getDefaultParameters(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php index 65e6b61e34..659aef172f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php @@ -23,7 +23,7 @@ class ProjectServiceContainer extends Container { $dir = __DIR__; for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = dirname($dir); + $this->targetDirs[$i] = $dir = \dirname($dir); } $this->parameters = $this->getDefaultParameters(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php index 3b45218bd9..2012c952c9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php @@ -23,7 +23,7 @@ class ProjectServiceContainer extends Container { $dir = __DIR__; for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = dirname($dir); + $this->targetDirs[$i] = $dir = \dirname($dir); } $this->parameters = $this->getDefaultParameters(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php index 03947c425d..1a9c87286d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php @@ -23,7 +23,7 @@ class Symfony_DI_PhpDumper_Test_Legacy_Privates extends Container { $dir = __DIR__; for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = dirname($dir); + $this->targetDirs[$i] = $dir = \dirname($dir); } $this->services = array(); $this->methodMap = array(