[DI] fix dumping lazy non-shared services

This commit is contained in:
Nicolas Grekas 2020-08-26 10:54:29 +02:00
parent 1382001dfe
commit a4f4ca74a7
2 changed files with 2 additions and 1 deletions

View File

@ -886,6 +886,7 @@ EOF;
if ($asFile) { if ($asFile) {
$code = str_replace('$this', '$container', $code); $code = str_replace('$this', '$container', $code);
$code = str_replace('function () {', 'function () use ($container) {', $code); $code = str_replace('function () {', 'function () use ($container) {', $code);
$code = str_replace('function ($lazyLoad = true) {', 'function ($lazyLoad = true) use ($container) {', $code);
} }
$code .= " }\n"; $code .= " }\n";

View File

@ -30,7 +30,7 @@ class getNonSharedFooService extends ProjectServiceContainer
{ {
include_once $container->targetDir.''.'/Fixtures/includes/foo_lazy.php'; include_once $container->targetDir.''.'/Fixtures/includes/foo_lazy.php';
$container->factories['non_shared_foo'] = function ($lazyLoad = true) { $container->factories['non_shared_foo'] = function ($lazyLoad = true) use ($container) {
return new \Bar\FooLazyClass(); return new \Bar\FooLazyClass();
}; };