Skip to content

Scope::getType returns wrong type for a variable casted in condition itself and then reassigned #9400

@fluffycondor

Description

@fluffycondor

Bug report

Looks like Scope::getType returns wrong type for a variable casted in condition itself and then reassigned. E.g. if it's a string casted to int, it will be treated as int in a FunctionTypeSpecifyingExtension.
In the snippet below the type is specified as it was int that passed to ctype_digit, but it's actually string that was passed.

Code snippet that reproduces the problem

https://phpstan.org/r/d9589ea0-ec28-46f3-b243-a8af7524232e

Expected output

int<1, max> because numeric-string casted to int and then range is narrowed by using $foo < 1.
https://3v4l.org/ooDoo

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

🧡🧡

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions