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

7d55151ff4 [DI] fix lazy factory code generation
This commit is contained in:
Fabien Potencier 2020-04-24 11:16:27 +02:00
commit 69452b22c2

View File

@ -851,7 +851,8 @@ EOF;
if ($this->getProxyDumper()->isProxyCandidate($definition)) {
$factoryCode = $asFile ? "\$this->load('%s', false)" : '$this->%s(false)';
$code .= $this->getProxyDumper()->getProxyFactoryCode($definition, $id, sprintf($factoryCode, $methodName));
$factoryCode = $this->getProxyDumper()->getProxyFactoryCode($definition, $id, sprintf($factoryCode, $methodName));
$code .= $asFile ? preg_replace('/function \(([^)]*+)\) {/', 'function (\1) use ($container) {', $factoryCode) : $factoryCode;
}
$code .= $this->addServiceInclude($id, $definition);