On Mon, Sep 20, 2021 at 12:02 PM Eugene Sidelnyk <zsidel...@gmail.com> wrote:
> From my experience it is not that easy to locate bug like this. > Heyo, just a tip for you (and others in this thread), but if you use `vimeo/psalm` and declare a `list<T>` for a type, then `array_filter()` that are missing an `array_values()` around it will be caught :) ```php /** @return list<mixed> */ function foo(array $input): array { return array_filter($input); } ``` Will produce: ``` INFO: MixedReturnTypeCoercion - 5:12 - The type 'array<array-key, non-empty-mixed>' is more general than the declared return type 'list<mixed>' for foo ``` See https://psalm.dev/r/f9c51f72c2 Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/