-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Dependency Injection - Profiler] Wrong exception throwed when a service class doesn't exist #15297
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
@Alsatian67 can you post some code that can be used to reproduce the bad exception? |
Sorry, the problem occurs when the namespace is wrong in the class ! example :
With that services.yml :
Not a big bug since my class was wrong, but the exception made me search for an eventual double ... |
You must respected PSR-4:
So your namespace should be |
@Alsatian67 the issue will happen because the class loader will load the file, and then try again the next time it is asked to load the class, as the first load will not have defined the class. And this case is not one which is detected by the DebugClassLoader /cc @nicolas-grekas |
Ok it would be nice if the autoloader throws an exception : The autoloader expected class "AppBundle\Security\AdminMembersVoter" to be defined in file AppBundle\Security\AdminMembersVoter.php". The file was found but ... When it load the file for the first time. |
Well, actually, it should. which Symfony version are you using ? |
and do you have the debug class loader enabled ? (i.e. to you have the |
I'm using Sf 2.7.2 and the debug is enabled. I just have seen that this wrong file produce the same invalid exception (here the class name is not like the file name [missing s]) :
|
I can confirm this issue is real as I experienced it myself, sadly don't remember which version nor the code that triggered it. |
I can confirm a FatalErrorException
Reproduced here. Status: Reviewed |
See #16651 |
…colas-grekas) This PR was merged into the 2.7 branch. Discussion ---------- [Debug] Ensure class declarations are loaded only once | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15297 | License | MIT | Doc PR | - Commits ------- 01c08fc [Debug] Ensure class declarations are loaded only once
I had an error in a yaml service container.
The class was wrong.
But the error that occurs is "cannot redeclare class ..." instead of a not found exception.
The text was updated successfully, but these errors were encountered: