8000 bug #36548 [DI] fix lazy factory code generation (nicolas-grekas) · symfony/symfony@69452b2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 69452b2

Browse files
committed
bug #36548 [DI] fix lazy factory code generation (nicolas-grekas)
This PR was merged into the 5.1-dev branch. Discussion ---------- [DI] fix lazy factory code generation | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #36547 | License | MIT | Doc PR | - Commits ------- 7d55151 [DI] fix lazy factory code generation
2 parents d6b9011 + 7d55151 commit 69452b2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Symfony/Component/DependencyInjection/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)
0