Thanks to visit codestin.com
Credit goes to github.com

Skip to content

In_array always true error may be more precise #11799

@VincentLanglet

Description

@VincentLanglet

Bug report

In the following snippet https://phpstan.org/r/0c778db2-c6b4-4323-89ee-6eafea9bae53, the error is

Call to function in_array() with arguments string, array{'publishDate', 'approvedAt', 'allowedValues'} and true will always evaluate to false.

This is not clear why the evaluation is always false, it should precise lowercase-string.

There is maybe more rule which need such precision.

This was already fixed on StrictComparisonOfDifferentTypesRule, this is the commit for inspiration
phpstan/phpstan-src@7b1ade2

Code snippet that reproduces the problem

https://phpstan.org/r/0c778db2-c6b4-4323-89ee-6eafea9bae53

Expected output

Call to function in_array() with arguments lowercase-string, array{'publishDate', 'approvedAt', 'allowedValues'} and true will always evaluate to false.

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

It comes from https://x.com/can__vural/status/1841740920443523201, so seems like it helps a lot.

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