Replies: 2 comments
-
array_filter is a know function for which we defined a special behaviour here: However, the method "filter" of a random object doesn't have this particular behaviour applied by Psalm. If it's part of a framework, you could consider creating a plugin to recycle this behaviour when you spot the desired method in an object |
Beta Was this translation helpful? Give feedback.
-
Not currently possible, but it would probably be possible if templates and closures were improved. The syntax would be a bit verbose though. See #7944 and this example (not working, but how it probably could work in the future). |
Beta Was this translation helpful? Give feedback.
-
Psalm is able to correctly determine the return type of an array after a call to
array_filter
. If we use a templated collection class that have afilter
method (with the same logic asarray_filter
) Psalm is not able to determine the correct template of the container after the call tofilter
.Example: https://psalm.dev/r/9cab8b9bdc
It would be interesting to have a way to declare this behaviour but I'm not sure how the syntax would look like.
Beta Was this translation helpful? Give feedback.
All reactions