Skip to content

Can't use result of is_numeric to determine ability to cast #3664

@loevgaard

Description

@loevgaard

Bug report

I would have expected no errors in the code snippet below. If a $var is numeric I should be able to cast it to int, but it doesn't seem that phpstan recognizes this.

It works with is_scalar though.

Code snippet that reproduces the problem

https://phpstan.org/r/c684ee69-d6a4-4455-8d1f-82fd8ba46ae5

Expected output

No errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions