Skip to content

False positive on multiple type argument like "string|array" followed by type testing function like "is_string" #2070

@tigitz

Description

@tigitz

Bug report

In recent version new errors popped up for what it seems valid code logic.

When needing to handle multiple type for an argument, putting type1|type2 in phpdoc and testing is_type1 followed by is_type2 will throw ... will always evaluate to true errors.

Code snippet that reproduces the problem

https://phpstan.org/r/b50a08c3-1761-41ac-a7cb-8a284d8d1b7e

Expected output

No errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions