Skip to content

Type not detected correctly when using strlen + null-coalesce operator to check variable #7949

@levu42

Description

@levu42

Bug report

Using strlen($nullableString ?? '') > 0 to figure out if a string is null / non-null doesn't get parsed correctly.

Code snippet that reproduces the problem

https://phpstan.org/r/dd783d15-3723-4c3b-8b78-8c756345e92a

Expected output

I expect PHPStan to recognize in my example $price can not be null on the function call.

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

Thank you for your amazing work! Since using PHPStan I don't commit any stupid bugs anymore, only the clever ones, which makes debugging way more fun :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions