Skip to content

reset() inside count()-guarded condition shouldn't return false #1383

@Majkl578

Description

@Majkl578

Summary of a problem or a feature request

reset() shouldn't return false when used in a condition with a check for non-empty array.

Code snippet that reproduces the problem

if (count($items) > 0) {
    return reset($items);
}

https://phpstan.org/r/8faccc70fac3506d5968839569bd8c7b

Expected output

No error, reset() can only return false on empty array.

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