🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

PHPStan should report in_array(..., true) calls that are obviously always true #14873

Description

@claudepache

Bug report

If $x is known to take a finite number of values that is a subset of the values of an array $a, then in_array($x, $a, true) should be detected as always evaluating to true.

Code snippet that reproduces the problem

https://phpstan.org/r/203d39d9-cdf0-4f11-bf13-aa40dbe26dda

Expected output

On line 5: “Function in_array() with arguments string, array{'a', 'b', 'c'} and true will always evaluate to true.”

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

No response

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