Closed simPod closed 1 year ago
Any ideas how this could be improved?
It can't without making PHPStan much slower.
Your best option is to repeat the array shape in @return
as you're doing now.
You could also write a custom script (with the help of custom PHPStan collectors) that would sync the PHPDoc array shape with the actually returned array shape by your function.
Aight, thanks for input.
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.
I wonder if there's any way to infer a type for phpdoc from
shape()
.I often define a complex type using
shape()
. Then I want to put it into a method to allow it's reuse.However, there's no way to somehow make phpstan infer the method's return type so you have to redefine the shape again in your
@return
phpdoc.Any ideas how this could be improved?