-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Create a IsA expression #396
base: main
Are you sure you want to change the base?
Conversation
src/Expression/ForClasses/IsA.php
Outdated
\is_a($theClass->getFQCN(), $allowedFqcn, true) | ||
|| \is_subclass_of($theClass->getFQCN(), $allowedFqcn) |
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.
Do we really need to check both? Both do the same, except that is_a()
also returns true
for the class itself (like is_a(A::class, A::class)
), AFAIK, so is_subclass_of()
should never be called.
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.
unfortunately, is_a
doesnt check for interface implementation, and is_subclass_of
doesnt check for same class. :(
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.
unfortunately,
is_a
doesn't check for interface implementation
I think it does: https://3v4l.org/91Yt8
AFAIK, is_a
does the same as instanceof
(and it is even more powerful, since it can check string class names and not only instances, if the third parameter is 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.
HAH! u r correct, I will fix this
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.
fixed and force pushed
7b00915
to
5143cff
Compare
This will allow for testing if a class extends or implements another code unit, anywhere in the inheritance tree.
5143cff
to
cafad1a
Compare
This will allow for testing if a class extends or
implements another code unit, anywhere in the inheritance tree.