- Added check for staticVars when processing closure use references - Prevented redeclaration of static variables as local variables in closures - Updated variable resolution logic to include static variable scope - Added comprehensive test case for static variable closure reference behavior - Fixed variable name collision in preprocessor class constant handling - Updated version number to 0.4.1pull/34/head v0.4.1
parent
a142cb8949
commit
89799b9b8c
4 changed files with 32 additions and 5 deletions
@ -0,0 +1,26 @@ |
|||||||
|
--TEST-- |
||||||
|
static variable captured by reference is not redeclared as a local variable |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
function getValue(): int |
||||||
|
{ |
||||||
|
static $value = null; |
||||||
|
if ($value === null) { |
||||||
|
$value = 0; |
||||||
|
$increment = static function () use (&$value): void { |
||||||
|
$value++; |
||||||
|
}; |
||||||
|
$increment(); |
||||||
|
} |
||||||
|
return $value; |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
var_dump(getValue()); |
||||||
|
var_dump(getValue()); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
int(1) |
||||||
|
int(1) |
||||||
Loading…
Reference in new issue