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
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 forNULL, then analysis works.Expected output
no error