Skip to content

is_non_empty_string('0') returns false #23

@AlwinGarside

Description

@AlwinGarside

The is_non_empty_string() function currently follows PHP's default non-strict comparison logic. This means the string '0' evaluates as "empty".

This is not the intended behavior of is_non_empty_string(). It is intended to function as a type guard for PHPStan's non-empty-string type, which doesn't consider the string '0' to be empty.

The functions should be updated accordingly:

function is_non_empty_string(mixed $value): bool
{
    return is_string($value) && $value !== '';
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions