Skip to content

Commit 5c33752

Browse files
[DI] fix lazy factory code generation
1 parent 75b0bbb commit 5c33752

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Dumper/PhpDumper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,8 @@ protected function {$methodName}($lazyInitialization)
851851

852852
if ($this->getProxyDumper()->isProxyCandidate($definition)) {
853853
$factoryCode = $asFile ? "\$this->load('%s', false)" : '$this->%s(false)';
854-
$code .= $this->getProxyDumper()->getProxyFactoryCode($definition, $id, sprintf($factoryCode, $methodName));
854+
$factoryCode = $this->getProxyDumper()->getProxyFactoryCode($definition, $id, sprintf($factoryCode, $methodName));
855+
$code .= $asFile ? preg_replace('/function \(([^)]*+)\) {/', 'function (\1) use ($container) {', $factoryCode) : $factoryCode;
855856
}
856857

857858
$code .= $this->addServiceInclude($id, $definition);

0 commit comments

Comments
 (0)