🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

References in use clauses are not processed correctly #13810

Description

@rosasurfer

Bug report

PHPStan doesn't correctly analyse use clauses with referenced variables. References are resolved at runtime, not at compile time.

Code snippet that reproduces the problem

https://phpstan.org/r/8882e8ce-b896-452e-83d0-59b2a4f41a47

The bug shows up only if the ??= operator is used. If ??= is replaced by an explicit test for NULL, then analysis works.

// this works
static $isSupported;
if (!isset($isSupported)) {
   $isSupported = function(mixed $arg) use (&$isSupported)...
}

// this doesn't
static $isSupported;
$isSupported ??= function(mixed $arg) use (&$isSupported)...

Expected output

no error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions