[DI] Force root-namespace for function calls in the dumper container

This commit is contained in:
Nicolas Grekas 2017-12-07 18:32:09 +01:00
parent d57303faa6
commit f87380c22a
8 changed files with 14 additions and 14 deletions

View File

@ -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 .= <<<EOF
\$dir = {$dir};
for (\$i = 1; \$i <= {$this->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) {

View File

@ -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();

View File

@ -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();

View File

@ -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;
}

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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(