Skip to content

Commit 8b11997

Browse files
[DI] cleanup
1 parent 643c54c commit 8b11997

File tree

4 files changed

+7
-554
lines changed

4 files changed

+7
-554
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ private function addServiceConfigurator($id, Definition $definition, $variableNa
548548
}
549549

550550
$class = $this->dumpValue($callable[0]);
551-
// If the class is a string we can optimize call_user_func away
551+
// If the class is a string we can optimize away
552552
if (0 === strpos($class, "'") && false === strpos($class, '$')) {
553553
return sprintf(" %s::%s(\$%s);\n", $this->dumpLiteralClass($class), $callable[1], $variableName);
554554
}
@@ -557,7 +557,7 @@ private function addServiceConfigurator($id, Definition $definition, $variableNa
557557
return sprintf(" (%s)->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
558558
}
559559

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

563563
return sprintf(" %s(\$%s);\n", $callable, $variableName);
@@ -731,7 +731,7 @@ private function addNewInstance(Definition $definition, $return, $instantiation,
731731
}
732732

733733
$class = $this->dumpValue($callable[0]);
734-
// If the class is a string we can optimize call_user_func away
734+
// If the class is a string we can optimize away
735735
if (0 === strpos($class, "'") && false === strpos($class, '$')) {
736736
if ("''" === $class) {
737737
throw new RuntimeException(sprintf('Cannot dump definition: The "%s" service is defined to be created by a factory but is missing the service reference, did you forget to define the factory service id or class?', $id));
@@ -744,7 +744,7 @@ private function addNewInstance(Definition $definition, $return, $instantiation,
744744
return sprintf(" $return{$instantiation}(%s)->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
745745
}
746746

747-
return sprintf(" $return{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? ', '.implode(', ', $arguments) : '');
747+
return sprintf(" $return{$instantiation}[%s, '%s'](%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
748748
}
749749

750750
return sprintf(" $return{$instantiation}%s(%s);\n", $this->dumpLiteralClass($this->dumpValue($callable)), $arguments ? implode(', ', $arguments) : '');
@@ -1411,7 +1411,7 @@ private function dumpValue($value, $interpolate = true)
14111411
}
14121412

14131413
if ($factory[0] instanceof Definition) {
1414-
return sprintf("call_user_func(array(%s, '%s')%s)", $this->dumpValue($factory[0]), $factory[1], count($arguments) > 0 ? ', '.implode(', ', $arguments) : '');
1414+
return sprintf("[%s, '%s'](%s)", $this->dumpValue($factory[0]), $factory[1], implode(', ', $arguments));
14151415
}
14161416

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

src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function testGetCircularReference()
230230
*/
231231
public function testGetSyntheticServiceThrows()
232232
{
233-
require_once __DIR__.'/Fixtures/php/services9.php';
233+
require_once __DIR__.'/Fixtures/php/services9_compiled.php';
234234

235235
$container = new \ProjectServiceContainer();
236236
$container->get('request');

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public function testFrozenContainerWithoutAliases()
272272
*/
273273
public function testOverrideServiceWhenUsingADumpedContainer()
274274
{
275-
require_once self::$fixturesPath.'/php/services9.php';
275+
require_once self::$fixturesPath.'/php/services9_compiled.php';
276276
require_once self::$fixturesPath.'/includes/foo.php';
277277

278278
$container = new \ProjectServiceContainer();

0 commit comments

Comments
 (0)