- Allow extension functions to use either snake_case or lowerCamelCase naming - Implement function name candidate generation with both naming conventions - Prioritize snake_case over lowerCamelCase when both exist - Add test cases for camel case keyword extension methods - Add test cases for universal method extension with camel case names - Refactor extension method lookup to iterate through both naming patterns - Update documentation to reflect dual naming convention supportpull/17/head
parent
3e9c02a666
commit
7618d25c4e
3 changed files with 108 additions and 55 deletions
@ -0,0 +1,21 @@ |
||||
--TEST-- |
||||
Keyword extension methods support lowerCamelCase function names |
||||
--FILE-- |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
use native_types; |
||||
|
||||
function __inspectValue(mixed $value, string $prefix): void |
||||
{ |
||||
echo $prefix, ':', $value, "\n"; |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
$value = 42; |
||||
$value->inspectValue('number'); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
number:42 |
||||
@ -0,0 +1,28 @@ |
||||
--TEST-- |
||||
Universal extension methods support lowerCamelCase function names |
||||
--FILE-- |
||||
<?php |
||||
|
||||
use native_types; |
||||
|
||||
function int_toBytes(int $value): string |
||||
{ |
||||
return ($value / 1024) . 'Kb'; |
||||
} |
||||
|
||||
function array_getFirstElement(array $value): mixed |
||||
{ |
||||
return $value[0]; |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
$size = 2048; |
||||
$values = [42, 43]; |
||||
var_dump($size->toBytes()); |
||||
var_dump($values->getFirstElement()); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
string(3) "2Kb" |
||||
int(42) |
||||
Loading…
Reference in new issue