10000 minor #23672 [DI] cleanup (nicolas-grekas) · symfony/symfony@01f05e3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 01f05e3

Browse files
minor #23672 [DI] cleanup (nicolas-grekas)
This PR was merged into the 4.0-dev branch. Discussion ---------- [DI] cleanup | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - master-only cleanups Commits ------- 8b11997 [DI] cleanup
2 parents 3ea90b4 + 8b11997 commit 01f05e3

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);
@@ -705,7 +705,7 @@ private function addNewInstance(Definition $definition, $return, $instantiation,
705705
}
706706

707707
$class = $this->dumpValue($callable[0]);
708-
// If the class is a string we can optimize call_user_func away
708+
// If the class is a string we can optimize away
709709
if (0 === strpos($class, "'") && false === strpos($class, '$')) {
710710
if ("''" === $class) {
711711
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));
@@ -718,7 +718,7 @@ private function addNewInstance(Definition $definition, $return, $instantiation,
718718
return sprintf(" $return{$instantiation}(%s)->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
719719
}
720720

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

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

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

13911391
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)
0