-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] Psr4DirectoryLoader issue with abstract classes #48168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As every loader using
Don’t really mind though, do what you think is best! |
I believe we can live with that.
Why do you think a wrong |
Because
$type could be annotation . When working on my PR this led to wrong error messages.
Nothing, just spotted while working on it. It is such a small change I included it in this issue and the associated PR. |
Functionality-wise this does not make much of a difference. Both types are equivalent.
Okay, for DX it's probably a good idea to pass the actual type then. Can you open a new PR just for that change? And please include a test that reproduces the issue with the wrong error message. |
Hm I cannot produce a failing test case so it must be linked to the changes I was making. |
All right. Thanks for having a look and thank you very much for this bug report! |
Symfony version(s) affected
6.2-beta
Description
The new
Psr4DirectoryLoader
only supportsattribute
orannotation
type so it will use theAnnotationClassLoader
which don’t want to deal with abstract classes:symfony/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php
Lines 114 to 116 in b02a689
(See 946ccb6 for rationale.)
If
AnnotationDirectoryLoader
skips them,Psr4DirectoryLoader
does not meaning it will crash on abstract classes.How to reproduce
Configure your routes to use the PSR-4 route loader, eg.
and make one of your controllers extends an abstract one (it does not need to define any method).
Refresh the cache to see the error.
Possible Solution
Psr4DirectoryLoader
should skip abstract classes. As it means it will need to create an instance ofReflectionClass
it could be useful to makeAnnotationClassLoader::load
accept these.Additional Context
Spotted from #48161
The text was updated successfully, but these errors were encountered: