You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
the object base will not have a ReflectionClass, therefore ReflectionClass<object> will never be returned
in a bound TEvent of Event, ReflectionClass<TEvent>::getParentClass() is going to be another ReflectionClass<TEvent of Event>, or perhaps just ReflectionClass<Event>.
The text was updated successfully, but these errors were encountered:
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
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...
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
object
base will not have aReflectionClass
, thereforeReflectionClass<object>
will never be returnedTEvent of Event
,ReflectionClass<TEvent>::getParentClass()
is going to be anotherReflectionClass<TEvent of Event>
, or perhaps justReflectionClass<Event>
.Code snippet that reproduces the problem
https://phpstan.org/r/5478cc7b-0267-4acd-a2e2-80a53ea8e37e
Expected output
No error should be reported.
The text was updated successfully, but these errors were encountered: