- Removed camelCase to snake_case conversion in extension function lookups
- Changed object extension methods to require exact name matches without case conversion
- Updated universal method extensions to use exact spelling instead of case variants
- Modified keyword extension methods to use exact __{method} naming
- Simplified function candidate search to single exact match instead of multiple variants
- Updated test cases to reflect exact naming requirements for all extension methods
- Maintained case-insensitive lookup behavior according to PHP function semantics
pull/17/head
parent
995e223915
commit
30ebc309da
6 changed files with 161 additions and 105 deletions
@ -0,0 +1,65 @@ |
|||||||
|
--TEST-- |
||||||
|
Object extension methods require consistent names and ignore letter case |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
namespace App { |
||||||
|
use native_types; |
||||||
|
|
||||||
|
class UserService |
||||||
|
{ |
||||||
|
public function __construct(public string $name) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public function __call(string $method, array $args): string |
||||||
|
{ |
||||||
|
return 'magic:' . $method; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function UserService_displayName(UserService $service): string |
||||||
|
{ |
||||||
|
return 'camel:' . $service->name; |
||||||
|
} |
||||||
|
|
||||||
|
function UserService_profile_label(UserService $service): string |
||||||
|
{ |
||||||
|
return 'snake:' . $service->name; |
||||||
|
} |
||||||
|
|
||||||
|
function user_service_wrongName(UserService $service): string |
||||||
|
{ |
||||||
|
return 'wrong class prefix'; |
||||||
|
} |
||||||
|
|
||||||
|
function UserService_other_name(UserService $service): string |
||||||
|
{ |
||||||
|
return 'wrong method suffix'; |
||||||
|
} |
||||||
|
|
||||||
|
function UserService_CASECheck(UserService $service): string |
||||||
|
{ |
||||||
|
return 'case-insensitive:' . $service->name; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
namespace { |
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
$service = new \App\UserService('alice'); |
||||||
|
|
||||||
|
var_dump($service->displayName()); |
||||||
|
var_dump($service->profile_label()); |
||||||
|
var_dump($service->wrongName()); |
||||||
|
var_dump($service->otherName()); |
||||||
|
var_dump($service->casecheck()); |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
string(11) "camel:alice" |
||||||
|
string(11) "snake:alice" |
||||||
|
string(15) "magic:wrongName" |
||||||
|
string(15) "magic:otherName" |
||||||
|
string(22) "case-insensitive:alice" |
||||||
Loading…
Reference in new issue