Skip to content

Commit 901c457

Browse files
minor #49476 [DependencyInjection] Make some functions static again (ruudk)
This PR was merged into the 6.3 branch. Discussion ---------- [DependencyInjection] Make some functions static again | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? |no | New feature? |no | Deprecations? |no | Tickets | | License | MIT | Doc PR | I removed a bit too much in 9a94e00c3a64fb9efe142db76d35aff37fb6fa51 As per comment of `@stof` symfony/symfony#49474 (comment) Commits ------- a9db56dee3 Make some functions static again
2 parents ca28a84 + 8b21dc3 commit 901c457

8 files changed

+9
-9
lines changed

Dumper/PhpDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public function dump(array $options = []): string|array
244244
if ($this->addGetService) {
245245
$code = preg_replace(
246246
"/(\r?\n\r?\n public function __construct.+?\\{\r?\n) ++([^\r\n]++)/s",
247-
"\n protected \Closure \$getService;$1 \$containerRef = $2\n \$this->getService = function () use (\$containerRef) { return \$containerRef->get()->getService(...\\func_get_args()); };",
247+
"\n protected \Closure \$getService;$1 \$containerRef = $2\n \$this->getService = static function () use (\$containerRef) { return \$containerRef->get()->getService(...\\func_get_args()); };",
248248
$code,
249249
1
250250
);
@@ -1545,7 +1545,7 @@ private function addInlineRequires(bool $hasProxyClasses): string
15451545
$code .= "\n include_once __DIR__.'/proxy-classes.php';";
15461546
}
15471547

1548-
return $code ? sprintf("\n \$this->privates['service_container'] = function (\$container) {%s\n };\n", $code) : '';
1548+
return $code ? sprintf("\n \$this->privates['service_container'] = static function (\$container) {%s\n };\n", $code) : '';
15491549
}
15501550

15511551
private function addDefaultParametersMethod(): string

Tests/Fixtures/php/services9_inlined_factories.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ProjectServiceContainer extends Container
8686
'decorated' => 'decorator_service_with_name',
8787
];
8888

89-
$this->privates['service_container'] = function ($container) {
89+
$this->privates['service_container'] = static function ($container) {
9090
include_once $container->targetDir.''.'/Fixtures/includes/foo.php';
9191
};
9292
}

Tests/Fixtures/php/services9_lazy_inlined_factories.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ProjectServiceContainer extends Container
4848

4949
$this->aliases = [];
5050

51-
$this->privates['service_container'] = function ($container) {
51+
$this->privates['service_container'] = static function ($container) {
5252
include_once __DIR__.'/proxy-classes.php';
5353
};
5454
}

Tests/Fixtures/php/services_inline_requires.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct()
2929

3030
$this->aliases = [];
3131

32-
$this->privates['service_container'] = function ($container) {
32+
$this->privates['service_container'] = static function ($container) {
3333
include_once \dirname(__DIR__, 1).'/includes/HotPath/I1.php';
3434
include_once \dirname(__DIR__, 1).'/includes/HotPath/P1.php';
3535
include_once \dirname(__DIR__, 1).'/includes/HotPath/T1.php';

Tests/Fixtures/php/services_non_shared_duplicates.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ProjectServiceContainer extends Container
2121
public function __construct()
2222
{
2323
$containerRef = $this->ref = \WeakReference::create($this);
24-
$this->getService = function () use ($containerRef) { return $containerRef->get()->getService(...\func_get_args()); };
24+
$this->getService = static function () use ($containerRef) { return $containerRef->get()->getService(...\func_get_args()); };
2525
$this->services = $this->privates = [];
2626
$this->methodMap = [
2727
'bar' => 'getBarService',

Tests/Fixtures/php/services_rot13_env.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Symfony_DI_PhpDumper_Test_Rot13Parameters extends Container
2121
public function __construct()
2222
{
2323
$containerRef = $this->ref = \WeakReference::create($this);
24-
$this->getService = function () use ($containerRef) { return $containerRef->get()->getService(...\func_get_args()); };
24+
$this->getService = static function () use ($containerRef) { return $containerRef->get()->getService(...\func_get_args()); };
2525
$this->parameters = $this->getDefaultParameters();
2626

2727
$this->services = $this->privates = [];

Tests/Fixtures/php/services_service_locator_argument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Symfony_DI_PhpDumper_Service_Locator_Argument extends Container
2121
public function __construct()
2222
{
2323
$containerRef = $this->ref = \WeakReference::create($this);
24-
$this->getService = function () use ($containerRef) { return $containerRef->get()->getService(...\func_get_args()); };
24+
$this->getService = static function () use ($containerRef) { return $containerRef->get()->getService(...\func_get_args()); };
2525
$this->services = $this->privates = [];
2626
$this->syntheticIds = [
2727
'foo5' => true,

Tests/Fixtures/php/services_subscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ProjectServiceContainer extends Container
2121
public function __construct()
2222
{
2323
$containerRef = $this->ref = \WeakReference::create($this);
24-
$this->getService = function () use ($containerRef) { return $containerRef->get()->getService(...\func_get_args()); };
24+
$this->getService = static function () use ($containerRef) { return $containerRef->get()->getService(...\func_get_args()); };
2525
$this->services = $this->privates = [];
2626
$this->methodMap = [
2727
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => 'getTestServiceSubscriberService',

0 commit comments

Comments
 (0)