- Add constant initialization code separation with before/after statement handling - Implement constant finalization logic to prevent metadata replacement during re-parsing - Create scoped initialization blocks using do-while constructs for temporary variables - Add codegenFinalized flag to track constant processing state - Introduce new test case for global nested array constants initialization - Add incremental declaration test for constant initializer preservation - Move constant value parsing to dedicated finalizeGlobalConstantValue method - Update translator to handle scoped constant initialization code generationmaster
parent
d059cefea6
commit
30b6f43bb7
5 changed files with 95 additions and 7 deletions
@ -0,0 +1,31 @@ |
||||
--TEST-- |
||||
Global nested array constants keep initialization temporaries in separate scopes |
||||
--FILE-- |
||||
<?php |
||||
namespace GlobalArrayConstants { |
||||
|
||||
const LIMIT = 42; |
||||
const FIRST = [[[LIMIT, 1]], [[2, 3]]]; |
||||
const SECOND = [0 => ['left' => LIMIT], 'tail' => [2, [3]]]; |
||||
const THIRD = [FIRST, SECOND]; |
||||
} |
||||
|
||||
namespace { |
||||
function main(): void |
||||
{ |
||||
var_dump(GlobalArrayConstants\FIRST[0][0][0]); |
||||
var_dump(GlobalArrayConstants\FIRST[1][0][1]); |
||||
var_dump(GlobalArrayConstants\SECOND[0]['left']); |
||||
var_dump(GlobalArrayConstants\SECOND['tail'][1][0]); |
||||
var_dump(GlobalArrayConstants\THIRD[0] === GlobalArrayConstants\FIRST); |
||||
var_dump(GlobalArrayConstants\THIRD[1] === GlobalArrayConstants\SECOND); |
||||
} |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
int(42) |
||||
int(3) |
||||
int(42) |
||||
int(3) |
||||
bool(true) |
||||
bool(true) |
||||
Loading…
Reference in new issue