Replies: 1 comment 1 reply
-
Can you share the actual code that makes this work? To me it seems kind of weird - how could be the ParentClass aware of where the method is called from, in order to return Child? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, given the following I would have expected the return type to be
ChildClass
but PHPStan is reportingParentClass
. I would have expected the@mixin
to work like atrait
and return the calling,ChildClass
via late static binding.https://phpstan.org/r/05a30038-b162-4441-9d69-11d7cc7c0d5f
Using native traits the
static
return is resolved as I would have expected with late static binding and PHPStan correctly sees theChildClass
return from->parentMethod()
.https://phpstan.org/r/31f0907e-5a54-4c79-a375-e405fc0ca532
The question is whether
@mixin
should support late static binding and resolve astatic
return to the calling class and not the defined class.Note: a workaround is to make
ParentClass
generic and specifically pass through the returning class.https://phpstan.org/r/894ecbec-6d97-441b-8aa4-a067ddc3789c
Beta Was this translation helpful? Give feedback.
All reactions