Closed
Description
Symfony version(s) affected: 4.3
Description
I made an update from Symfony 3.4 to 4.3. After that I had a problem with lazy services in the console.
The following error occurred:
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\UndefinedMethodException: Attempted to call an undefined method named "staticProxyConstructor" of class "EntityManager_9a5be93"
I was able to trace this error back to the file vendor/symfony/symfony/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php
If I replace the code of the file with the code from Symfony 3.4, everything works again.
Line 63:
return <<<EOF
if (\$lazyLoad) {
$instantiation \$this->createProxy('$proxyClass', function () {
return \\$proxyClass::staticProxyConstructor(function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) {
\$wrappedInstance = $factoryCode;
\$proxy->setProxyInitializer(null);
return true;
});
});
}
replaced with:
$hasStaticConstructor = $this->generateProxyClass($definition)->hasMethod('staticProxyConstructor');
$constructorCall = sprintf($hasStaticConstructor ? '%s::staticProxyConstructor' : 'new %s', '\\'.$proxyClass);
return <<<EOF
if (\$lazyLoad) {
$instantiation \$this->createProxy('$proxyClass', function () {
return $constructorCall(function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) {
\$wrappedInstance = $factoryCode;
\$proxy->setProxyInitializer(null);
return true;
});
});
}
Sorry for the bad description. This is one of my first tickets in GitHub :)