-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Added class existence check if is_subclass_of() fails in compiler passes #19342
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
if (!is_subclass_of($class, $interface)) { | ||
if (!class_exists($class, true)) { |
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.
true
should be false
: autoloading already happened the line before
@nicolas-grekas , i updated a code according your notes. |
👍 |
if (!is_subclass_of($class, $interface)) { | ||
if (!class_exists($class, false)) { | ||
throw new \InvalidArgumentException(sprintf('Class "%s" used for service "%s" can not be found.', $class, $id)); |
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.
"cannot" instead of "can not" (same below)
@xabbuh , updated |
👍 |
Thank you @SCIF. |
…ompiler passes (SCIF) This PR was merged into the 2.8 branch. Discussion ---------- Added class existence check if is_subclass_of() fails in compiler passes | Q | A | ------------- | --- | Branch? | 2.8-3.1 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - If you create an event subscriber and make typo in file name it will cause next error: ``` [InvalidArgumentException] Service "event.notification_subscriber" must implement interface "Symfony\Component\EventDispatcher\EventSubscriberInterface". ``` That's because of `is_subclass_of()` fails on class absentee. I made error message more clear. Commits ------- 72db6e7 Added class existence check if is_subclass_of() fails in compiler passes
Should not this be back ported on the 2.7 branch? |
@fabpot , is there any chance to merge that PR to 2.7? |
@SCIF please openq new PR |
@nicolas-grekas , will do, thanks! |
…ompiler passes (SCIF) This PR was merged into the 2.7 branch. Discussion ---------- Added class existence check if is_subclass_of() fails in compiler passes | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | comma-separated list of tickets fixed by the PR, if any | License | MIT | Doc PR | no Backport of #19342 to 2.7 branch Commits ------- 77adea7 Added class existence check if is_subclass_of() fails in compiler passes
…lass_of (chalasr) This PR was merged into the 2.7 branch. Discussion ---------- [FrameworkBundle] Check for class existence before is_subclass_of | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Same as #19342 Commits ------- 8a9e0f5 [FrameworkBundle] Check for class existence before is_subclass_of
If you create an event subscriber and make typo in file name it will cause next error:
That's because of
is_subclass_of()
fails on class absentee. I made error message more clear.