Skip to content

Loose comparison of substr result with empty string is always true #13098

@reima

Description

@reima

Bug report

When doing a loose comparison of the result of a call to substr with the empty string, PHPStan emits an equal.alwaysTrue error.

This only happens with PHP 7.4, not with PHP 8.0+.

Code snippet that reproduces the problem

https://phpstan.org/r/e5ceca4e-87c4-4881-9e0f-a5aff0bad6b2

Expected output

No errors.

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

PHPStan is a godsend for modernizing legacy PHP apps. I'm slowly working my way through the levels and have already fixed thousands of issues. I'm really impressed with the deductions PHPStan makes. Thank you for your hard work!

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