Skip to content

False positive for empty on non-empty-string #7199

@oliverklee

Description

@oliverklee

Bug report

empty() in PHP is evil and behaves in mysterious ways. Particularly, as it basically is a check for truthy-ness, it considers the string "0" to be empty. That means that any variable/parameter that is a non-empty-string can still lead to empty($var) to be empty as well.

Code snippet that reproduces the problem

https://phpstan.org/r/5f809ad5-cee9-423c-b7aa-9ec2d432793a

Expected output

no error

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

PHPStan still is one of my favorite gamified activities, and it helps me improve the code of my TYPO3 extensions and the TYPO3 core.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions