Description
Symfony version(s) affected: all
Description
In the DebugClassLoader
, classes that are found by the wrapped class loader findFile()
method are required (and not included like in the composer ClassLoader
for example). That means that if the file is not found, the fatal error that is triggered is not recoverable.
So why would the wrapped class loader finds the file but the file doesn't actually exist? With Composer, it can happen if you dump your autoload files with the optimize option and if you delete a class file for example. The class will still be in the Composer class map.
What problem does it cause? When you do reflection on a class like this, it ends up with a fatal error instead of a \ReflectionException
. In Symfony, that breaks the AnnotationCacheWarmer
process that is supposed to ignore \ReflectionException
s on classes that don't exist.
Possible Solution
- Check if the file exists before requiring it in the
DebugClassLoader
: I guess it would be very bad for performance. - Create a
SafeDebugClassLoader
that wraps theDebugClassLoader
to check if the file exists, so we can enable it / disable it on demand?