Skip to content

Recursive function is analysed as null in some cases since v2.3.0 #15442

Open
phpstan/phpstan-src
#6721

Description

@mvorisek

Bug report

(repro is heavily reduced from https://github.com/atk4/ui/blob/55f26b2bf690a9d4edfa260e351393a4ec95e5be/src/GridLayout.php#L83)

It seems the anonymous functions with reference is not correctly in some cases. When I add return $fx; for example, the issue is gone 👀

Code snippet that reproduces the problem

https://phpstan.org/r/e94f62d3-6bde-45b6-99ce-37514f352ead

Expected output

no phpstan error

Activity

  1. drewmt commented on Oct 9, 2026

    @drewmt

    Fixed in phpstan/phpstan-src#6721. The recursive-call guard now follows captures through nested closures and arrow functions; the regression covers both and keeps the non-recursive scalar-flow controls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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