Replies: 3 comments
-
I had a related thing literally minutes ago. Turned out that I was using |
Beta Was this translation helpful? Give feedback.
-
If your problem still isn't solved, please post an example with a link to phpstan.org playground. |
Beta Was this translation helpful? Give feedback.
-
Maybe this could help, I had the problem with an iterable that have a well defined type of elements (T) but a non well defined type of keys (TKey) : Iterable<type1,type2> ==> OK ; phpstan accepts a callable of type2 as the first argument of array_map |
Beta Was this translation helpful? Give feedback.
-
Hey!
So I am new to PHPStan and I came accross a problem using array_map:
Parameter #1 $callback of function array_map expects (callable(object): mixed)|null, Closure(App\Entity\EntityObject): ArrayObject<int, mixed>|string|false given.
I do not know what the exact problem is. Is it that I use
Closure
instead ofcallable
or that the parameter and return type of my Closure is mismatched?If the case is the latter, why is it a problem that I pass and return a narrower type? (because object and mixed are a broader type if I understand correctly)
Thanks for the help!
Beta Was this translation helpful? Give feedback.
All reactions