Closed
Description
Symfony version(s) affected
6.0
Description
This code is generated by DI and cause ClassNotFoundException for me:
<?php
namespace ContainerSF7xQsW;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
/**
* @internal This class has been auto-generated by the Symfony Dependency Injection Component.
*/
class getMailer_TransportFactory_NativeService extends App_KernelDevDebugContainer
{
/**
* Gets the private 'mailer.transport_factory.native' shared service.
*
* @return \Symfony\Component\Mailer\Transport\NativeTransportFactory
*/
public static function do($container, $lazyLoad = true)
{
include_once \dirname(__DIR__, 4).'/vendor/symfony/mailer/Transport/TransportFactoryInterface.php';
include_once \dirname(__DIR__, 4).'/vendor/symfony/mailer/Transport/AbstractTransportFactory.php';
include_once \dirname(__DIR__, 4).'/vendor/symfony/mailer/Transport/NativeTransportFactory.php';
$a = ($container->services['event_dispatcher'] ?? self::getEventDispatcherService($container));
if (isset($container->privates['mailer.transport_factory.native'])) {
return $container->privates['mailer.transport_factory.native'];
}
return $container->privates['mailer.transport_factory.native'] = new \Symfony\Component\Mailer\Transport\NativeTransportFactory($a, ($container->privates['.debug.http_client'] ?? self::get_Debug_HttpClientService($container)), ($container->services['monolog.logger.mailer'] ?? $container->get('monolog.logger.mailer', ContainerInterface::NULL_ON_INVALID_REFERENCE)));
}
}
And the exception is:
Attempted to load class "ContainerInterface" from namespace "ContainerSF7xQsW". Did you forget a "use" statement for e.g. "Symfony\Component\DependencyInjection\ContainerInterface" or "Psr\Container\ContainerInterface"?
The PhpDumper does generates wrong code:
This patch cause the regression: 16fcdda
How to reproduce
To be honest, I don't know how to reproduce this. I also don't fully understand why it only happened to me and not to others.
Possible Solution
Either of the two example codes will generate working code.
$code = sprintf('$container->get(%s, \\%s::NULL_ON_INVALID_REFERENCE)', $this->doExport($id), ContainerInterface::class);
or
$code = sprintf('$container->get(%s, \Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE)', $this->doExport($id));
Additional Context
No response