- Strip leading backslashes from constant names before processing - Add special handling for true/false language constants to prevent namespace fallback - Implement proper namespace resolution for unqualified constants - Respect use statement aliases for constant names - Return VAR type when namespaced constants may shadow globals at runtime - Move true/false checks to occur before namespace resolution - Add comprehensive test coverage for runtime constant fallback behavior - Add test case for static method calls with branch carrierspull/48/head
parent
997bbffb65
commit
6fb8187b07
4 changed files with 84 additions and 6 deletions
@ -0,0 +1,41 @@ |
||||
--TEST-- |
||||
Native static calls initialize the class carrier outside conditional branches |
||||
--FILE-- |
||||
<?php |
||||
|
||||
class StaticBranchCarrier |
||||
{ |
||||
protected static array $cache = []; |
||||
|
||||
public static function normalize(string $value): string |
||||
{ |
||||
if (isset(static::$cache[$value])) { |
||||
return static::$cache[$value]; |
||||
} |
||||
|
||||
return static::$cache[$value] = strtoupper($value); |
||||
} |
||||
} |
||||
|
||||
function selectBranch(bool $first): string |
||||
{ |
||||
if ($first) { |
||||
return StaticBranchCarrier::normalize('first'); |
||||
} else { |
||||
return StaticBranchCarrier::normalize('second'); |
||||
} |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
// The first static call in source order is deliberately not executed. |
||||
var_dump(selectBranch(false)); |
||||
var_dump(selectBranch(true)); |
||||
var_dump(selectBranch(false)); |
||||
} |
||||
|
||||
?> |
||||
--EXPECT-- |
||||
string(6) "SECOND" |
||||
string(5) "FIRST" |
||||
string(6) "SECOND" |
||||
Loading…
Reference in new issue