Skip to content

DebugClassLoader fails with Symfony's BC layers #42303

@ostrolucky

Description

@ostrolucky

Symfony version(s) affected: 5.3.5

Description
These kind of "BC layers" don't work in combination with Symfony's DebugClassLoader

trigger_deprecation('symfony/messenger', '5.1', 'The "%s" class is deprecated, use "%s" instead. The Doctrine transport has been moved to package "symfony/doctrine-messenger" and will not be included by default in 6.0. Run "composer require symfony/doctrine-messenger".', DoctrineTransportFactory::class, BridgeDoctrineTransportFactory::class);

class_exists(BridgeDoctrineTransportFactory::class);

if (false) {
    /**
     * @deprecated since Symfony 5.1, to be removed in 6.0. Use symfony/doctrine-messenger instead.
     */
    class DoctrineTransportFactory
    {
    }
}

How to reproduce

<?php

use Symfony\Component\ErrorHandler\DebugClassLoader;
use Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory;

require __DIR__.'/vendor/autoload.php';

DebugClassLoader::enable();
class_exists(DoctrineTransportFactory::class);

produces

PHP Fatal error:  Uncaught RuntimeException: The autoloader expected class "Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory" to be defined in file "/Users/gabriel.ostrolucky/Documents/CraueGeoBundle/vendor/composer/../symfony/symfony/src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineTransportFactory.php". The file was found but the class was not in it, the class name or namespace probably has a typo. in /Users/gabriel.ostrolucky/Documents/CraueGeoBundle/vendor/symfony/symfony/src/Symfony/Component/ErrorHandler/DebugClassLoader.php:403
Stack trace:
#0 /Users/gabriel.ostrolucky/Documents/CraueGeoBundle/vendor/symfony/symfony/src/Symfony/Component/ErrorHandler/DebugClassLoader.php(360): Symfony\Component\ErrorHandler\DebugClassLoader->checkClass('Symfony\\Compone...', '/Users/gabriel....')
#1 [internal function]: Symfony\Component\ErrorHandler\DebugClassLoader->loadClass('Symfony\\Compone...')
#2 /Users/gabriel.ostrolucky/Documents/CraueGeoBundle/test.php(9): class_exists('Symfony\\Compone...')
#3 {main}
  thrown in /Users/gabriel.ostrolucky/Documents/CraueGeoBundle/vendor/symfony/symfony/src/Symfony/Component/ErrorHandler/DebugClassLoader.php on line 403

Fatal error: Uncaught RuntimeException: The autoloader expected class "Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory" to be defined in file "/Users/gabriel.ostrolucky/Documents/CraueGeoBundle/vendor/composer/../symfony/symfony/src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineTransportFactory.php". The file was found but the class was not in it, the class name or namespace probably has a typo. in /Users/gabriel.ostrolucky/Documents/CraueGeoBundle/vendor/symfony/symfony/src/Symfony/Component/ErrorHandler/DebugClassLoader.php:403
Stack trace:
#0 /Users/gabriel.ostrolucky/Documents/CraueGeoBundle/vendor/symfony/symfony/src/Symfony/Component/ErrorHandler/DebugClassLoader.php(360): Symfony\Component\ErrorHandler\DebugClassLoader->checkClass('Symfony\\Compone...', '/Users/gabriel....')
#1 [internal function]: Symfony\Component\ErrorHandler\DebugClassLoader->loadClass('Symfony\\Compone...')
#2 /Users/gabriel.ostrolucky/Documents/CraueGeoBundle/test.php(9): class_exists('Symfony\\Compone...')
#3 {main}
  thrown in /Users/gabriel.ostrolucky/Documents/CraueGeoBundle/vendor/symfony/symfony/src/Symfony/Component/ErrorHandler/DebugClassLoader.php on line 403

Possible Solution

Additional context
ref: doctrine/DoctrineBundle#1373

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions