Skip to content

Strict comparison between empty array and iterable always false #3010

@julienfalque

Description

@julienfalque

Bug report

PHPStan reports strict comparison between an empty array and an iterable as always false:

Code snippet that reproduces the problem

/**
 * @param iterable<mixed> $iterable
 */
function is_empty_array(iterable $iterable): bool
{
    return [] === $iterable;
}

PHPStan reports the following error:

Strict comparison using === between array() and iterable will always evaluate to false.

See https://phpstan.org/r/ca87bf01-edaa-4d73-9a9e-e99ea6893b52

Expected output

No errors.

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