- Add parameterOffset parameter to parseNativeCallArgs with validation logic - Implement named argument offset validation to prevent targeting extension receiver - Update variadic argument handling with offset calculations - Skip parameter validation for indices below offset threshold - Adjust function definition checks to account for parameter offset - Add object extension method lookup in findObjectExtensionMethod - Implement extension function resolution within specific namespaces only - Create genObjectExtensionFn to generate proper extension function calls - Add comprehensive test coverage for namespaced object extension methods - Support both snake_case and camelCase method naming conventions - Ensure extension methods receive correct parameter positioning with offset 1pull/17/head
parent
7618d25c4e
commit
7977893bbe
3 changed files with 158 additions and 11 deletions
@ -0,0 +1,65 @@ |
|||||||
|
--TEST-- |
||||||
|
Namespaced object extension methods use Class_method naming |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
namespace App { |
||||||
|
use native_types; |
||||||
|
|
||||||
|
class User |
||||||
|
{ |
||||||
|
public function __construct(public string $name) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public function existing(): string |
||||||
|
{ |
||||||
|
return 'real method'; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function User_test_method(User $user, string $suffix): string |
||||||
|
{ |
||||||
|
return $user->name . $suffix . ':snake'; |
||||||
|
} |
||||||
|
|
||||||
|
function User_displayName(User $user): string |
||||||
|
{ |
||||||
|
return strtoupper($user->name) . ':camel'; |
||||||
|
} |
||||||
|
|
||||||
|
function User_format_name(int $invalid): string |
||||||
|
{ |
||||||
|
return 'invalid'; |
||||||
|
} |
||||||
|
|
||||||
|
function User_formatName(User $user): string |
||||||
|
{ |
||||||
|
return '[' . $user->name . ']'; |
||||||
|
} |
||||||
|
|
||||||
|
function User_existing(User $user): string |
||||||
|
{ |
||||||
|
return 'extension'; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
namespace { |
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
$user = new \App\User('alice'); |
||||||
|
var_dump($user->testMethod('!')); |
||||||
|
var_dump($user->displayName()); |
||||||
|
var_dump($user->formatName()); |
||||||
|
var_dump($user->existing()); |
||||||
|
var_dump((new \App\User('bob'))->displayName()); |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
string(12) "alice!:snake" |
||||||
|
string(11) "ALICE:camel" |
||||||
|
string(7) "[alice]" |
||||||
|
string(11) "real method" |
||||||
|
string(9) "BOB:camel" |
||||||
Loading…
Reference in new issue