-
Notifications
You must be signed in to change notification settings - Fork 133
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
Implement ReflectionClass->getParentClassName()
#1359
Conversation
@@ -452,6 +452,14 @@ public function newInstanceArgs(array|null $args = null): object | |||
throw new Exception\NotImplemented('Not implemented'); | |||
} | |||
|
|||
/** |
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.
Is it good idea to add method to adapter?
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.
Oh, true, this should only be on the BetterReflection API, not on the adapter
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.
ok, I wasn't able to differentiate which is what and thought I need to reflect the change there. even easier if this is not required :)
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.
I want to call this new method from PHPStan ClassReflection. I guess this means we need it on the adapter then?
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.
From an architectural PoV, it does not fit here: the adapter is only for mirroring the API of ext-reflection.
Anything beyond that already couples the consumer to BetterReflection, rather than ext-reflection, and should not be here.
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.
@clxmstaab PHPStan uses BR fork /~https://github.com/ondrejmirtes/BetterReflection/, so it can be implemented there.
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.
even then, remember that the dependency is to ext-reflection, and the adapters are not supposed to deviate from that API.
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.
I think this should be good to go
(sorry for mixing commits from my personal and my corporate account..)
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.
Thanks @staabm!
A class can declare a parent which we cannot locate via autoloading mechanics.
For some static analysis cases its still useful to know, whether a parent class is defined - even if we can't reflect on it for some reason.
I was not able to find a API which allows me to dermine whether a class has a parent declared but only BetterReflection cannot find its definition from whether there is no parent class declared at all.
Before this PR we had to use reflection hacks to get the private property out of the class, see rectorphp/rector#8093 (comment)