Skip to content

array_reverse creates fake positive with current #4398

@einenlum

Description

@einenlum

Bug report

Hi! First, thank you for making our lives easier as developers ❤️.
I found what appears to be a bug concerning current, array_reverse and early terminations.

Code snippet that reproduces the problem

https://phpstan.org/r/ec522ffe-804c-496f-9738-96a45a8c3a59

Error: Function test() should return string but returns string|false.

Expected output

No error should be thrown, because the empty check before and the thrown exception ensure that $meters is not empty.
array_reverse only reverses the array, so we can be sure that $reversedMeters is not empty either.

Same code without the array_reverse part works:
https://phpstan.org/r/572d01d4-b0e9-4411-bb36-30ce38197657

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