- Changed defaultValue check to default property comparison in CallArgumentGenerator - Added genDefaultArgumentExpr call for proper default value resolution - Updated findNativeClassConst signature to accept accessing class parameter - Modified checkAccessibleByClassName to use accessing class context - Updated getClassConstValue calls to pass current class context - Added comprehensive test case for private class constant parameter defaultspull/44/head
parent
25e5b47482
commit
df43b2a1fd
5 changed files with 100 additions and 12 deletions
@ -0,0 +1,54 @@ |
||||
--TEST-- |
||||
Private and protected class constants are valid method parameter defaults in declaration scope |
||||
--FILE-- |
||||
<?php |
||||
|
||||
class PrivateConstDefaults |
||||
{ |
||||
private const VALUE = 42; |
||||
private const LABEL = 'private'; |
||||
|
||||
public function show( |
||||
int $value = self::VALUE, |
||||
string $label = PrivateConstDefaults::LABEL, |
||||
string $suffix = 'default', |
||||
): void { |
||||
var_dump($value, $label, $suffix); |
||||
} |
||||
} |
||||
|
||||
class ProtectedConstParent |
||||
{ |
||||
protected const VALUE = 7; |
||||
} |
||||
|
||||
class ProtectedConstChild extends ProtectedConstParent |
||||
{ |
||||
public function show(int $value = parent::VALUE, string $suffix = 'default'): void |
||||
{ |
||||
var_dump($value, $suffix); |
||||
} |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
$private = new PrivateConstDefaults(); |
||||
$private->show(); |
||||
$private->show(suffix: 'named'); |
||||
|
||||
$protected = new ProtectedConstChild(); |
||||
$protected->show(); |
||||
$protected->show(suffix: 'named'); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
int(42) |
||||
string(7) "private" |
||||
string(7) "default" |
||||
int(42) |
||||
string(7) "private" |
||||
string(5) "named" |
||||
int(7) |
||||
string(7) "default" |
||||
int(7) |
||||
string(5) "named" |
||||
Loading…
Reference in new issue