Description
Symfony version(s) affected: Symfony 4.4.5, PHPUnit Bridge 5.0.5
Description
For deprecations triggered by the DebugClassLoader (when extending a deprecated class for instance), the qualification of the deprecation as direct or indirect in the PHPUnit Bridge seems to be based on the place triggering the autoload call, rather than on the file containing the class definition for which the deprecation is triggered
How to reproduce
composer require xabbuh/panda-bundle 1.4.1
(which contains event classes which have not been migrated to the new base class in contracts, but any other vendor extending a deprecated class would do it)- write some code in the project using one of its event classes (in my case, it is the
getSubscribedEvents()
method of an event subscriber accessing the constant with the event name) - run tests with the PHPUnit bridge
- The deprecation
The "Xabbuh\PandaBundle\Event\EncodingCompleteEvent" class extends "Symfony\Component\EventDispatcher\Event" that is deprecated since Symfony 4.3, use "Symfony\Contracts\EventDispatcher\Event" instead.
is reported as a direct deprecation while it should be invalid.
On the other hand, my own event classes (being in the same case as I haven't migrated them yet) are reported as indirect deprecations because the autoloading is triggered by Symfony itself when loading all classes defined in src
.
Possible Solution
DebugClassLoader should have a way to force the source of the deprecation to be in the file rather than being in the autoloader IMO. But I don't know yet how to achieve it (/cc @nicolas-grekas)