8000 bug #37953 [DI] fix dumping lazy non-shared services (nicolas-grekas) · symfony/symfony@885390f · GitHub
[go: up one dir, main page]

Skip to content

Commit 885390f

Browse files
committed
bug #37953 [DI] fix dumping lazy non-shared services (nicolas-grekas)
This PR was merged into the 5.1 branch. Discussion ---------- [DI] fix dumping lazy non-shared services | Q | A | ------------- | --- | Branch? | 5.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #37665 | License | MIT | Doc PR | - Commits ------- a4f4ca7 [DI] fix dumping lazy non-shared services
2 parents 216f2fa + a4f4ca7 commit 885390f

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,7 @@ protected function {$methodName}($lazyInitialization)
886886
if ($asFile) {
887887
$code = str_replace('$this', '$container', $code);
888888
$code = str_replace('function () {', 'function () use ($container) {', $code);
889+
$code = str_replace('function ($lazyLoad = true) {', 'function ($lazyLoad = true) use ($container) {', $code);
889890
}
890891

891892
$code .= " }\n";

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class getNonSharedFooService extends ProjectServiceContainer
3030
{
3131
include_once $container->targetDir.''.'/Fixtures/includes/foo_lazy.php';
3232

33-
$container->factories['non_shared_foo'] = function ($lazyLoad = true) {
33+
$container->factories['non_shared_foo'] = function ($lazyLoad = true) use ($container) {
3434
return new \Bar\FooLazyClass();
3535
};
3636

0 commit comments

Comments
 (0)
0