Skip to content
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

phpstan doesn't understand ReflectionClass<SomeClass>::getParent() should return ReflectionClass<parent of SomeClass> #4533

Closed
dktapps opened this issue Feb 12, 2021 · 2 comments

Comments

@dktapps
Copy link
Contributor

dktapps commented Feb 12, 2021

Bug report

This is a problem I encountered with generics in PocketMine-MP, and ties in with my prior request for contravariance in generics as described in #3960 (it's the same events system which is affected).

In the below test sample, we know 2 things

  1. the object base will not have a ReflectionClass, therefore ReflectionClass<object> will never be returned
  2. in a bound TEvent of Event, ReflectionClass<TEvent>::getParentClass() is going to be another ReflectionClass<TEvent of Event>, or perhaps just ReflectionClass<Event>.

Code snippet that reproduces the problem

https://phpstan.org/r/5478cc7b-0267-4acd-a2e2-80a53ea8e37e

Expected output

No error should be reported.

@dktapps dktapps changed the title phpstan doesn't ReflectionClass<SomeClass>::getParent() should return ReflectionClass<parent of SomeClass> phpstan doesn't understand ReflectionClass<SomeClass>::getParent() should return ReflectionClass<parent of SomeClass> Feb 12, 2021
@ondrejmirtes
Copy link
Member

Hi, I don't think this is worth supporting. We cannot make any assumptions of what the reflected parent class is. It can be a child of Event, Event itself, or parent class of Event. I don't know how we'd express that by covering all the cases...

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants