Skip to content

in_array cannot be used as null check #7153

@petermein

Description

@petermein

Bug report

When trying to check if an array contains any NULL values. The in_array function can be used with the strict flag set.
However PHPStan is not picking up that the values cannot be null inside of the array.

Code snippet that reproduces the problem

https://phpstan.org/r/69897217-fd94-497b-9e98-4baa6b2b96db

Expected output

The output should mention string is givin instead of string|null.

Did PHPStan help you today? Did it make you happy in any way?

PHPStan is the best! We've worked around this issue with the help of Webmozart assert, but it not diminished our excitement in using PHPStan. Great job!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions