-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[DependencyInjection] Update ResolveClassPass
to check class existence
#61215
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
Conversation
src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckServiceClassExistsPassTest.php
Outdated
Show resolved
Hide resolved
740f29a
to
65259c9
Compare
src/Symfony/Component/DependencyInjection/Compiler/CheckServiceClassExistsPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Compiler/CheckServiceClassExistsPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Compiler/CheckServiceClassExistsPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Compiler/CheckServiceClassExistsPass.php
Outdated
Show resolved
Hide resolved
This approach is too broad IMHO. There are cases where the class is eg In #54095 (comment), I wrote:
Can't we patch the existing compiler pass that copies the id to the class when no class is set, and make it throw when id is not a class? |
But then it would not work if you define a manual id and make a typo in the class (although more of a niche case) |
So we could have something like |
65259c9
to
321ccff
Compare
There are many ways one can mess up with their DI config. Validating everything adds to the compilation time. That's something we always considered outside of the scope of the compilation step. |
ResolveClassPass
to check class existence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, test cases changes look consistent with the updated behavior.
src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/fixture_app_services.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/fixture_app_services.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/fixture_app_services.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Compiler/ResolveClassPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Compiler/ResolveClassPass.php
Outdated
Show resolved
Hide resolved
9690e1e
to
349c87c
Compare
349c87c
to
dbd5c25
Compare
Thank you @GaryPEGEOT. |
Currently doesn't check for incorrect factories, but I'm not sure what would be the best approach