Skip to content

Commit ded2971

Browse files
[DI] fix dumping lazy non-shared services
1 parent c45c3f2 commit ded2971

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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";

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)