using php documentation regex

This commit is contained in:
Fabio Ivona
2023-03-21 15:15:38 +01:00
parent 48ae4bfc18
commit ed3bb2634d
2 changed files with 11 additions and 9 deletions

View File

@ -61,7 +61,8 @@ final class Str
{
$code = self::PREFIX.str_replace(' ', '_', $code);
return (string) preg_replace('/[^\p{L}_0-9]/', '_', $code);
// sticks to PHP8.2 function naming rules https://www.php.net/manual/en/functions.user-defined.php
return (string) preg_replace('/[^a-zA-Z0-9_\x80-\xff]/', '_', $code);
}
/**

View File

@ -14,14 +14,15 @@ it('may start with P', function (string $real, string $toBePrinted) {
$names = [
'ふが' => '__pest_evaluable_ふが',
'ほげ' => 'ほげ',
'卜竹弓一十山' => '卜竹弓一十山',
'!p8VrB' => '!p8VrB',
'&xe6VeKWF#n4' => '&xe6VeKWF#n4',
'%%HurHUnw7zM!' => '%%HurHUnw7zM!',
'rundeliekend' => 'rundeliekend',
'g%%c!Jt9$fy#Kf' => 'g%%c!Jt9$fy#Kf',
'NRs*Gz2@hmB$W$BPD%%b2U%3P%z%apnwSX' => 'NRs*Gz2@hmB$W$BPD%%b2U%3P%z%apnwSX',
'ほげ' => '__pest_evaluable_ほげ',
'卜竹弓一十山' => '__pest_evaluable_卜竹弓一十山',
'!p8VrB' => '__pest_evaluable__p8VrB',
'&xe6VeKWF#n4' => '__pest_evaluable__xe6VeKWF_n4',
'%%HurHUnw7zM!' => '__pest_evaluable___HurHUnw7zM_',
'rundeliekend' => '__pest_evaluable_rundeliekend',
'g%%c!Jt9$fy#Kf' => '__pest_evaluable_g__c_Jt9_fy_Kf',
'NRs*Gz2@hmB$W$BPD%%b2U%3P%z%apnwSX' => '__pest_evaluable_NRs_Gz2_hmB_W_BPD__b2U_3P_z_apnwSX',
'ÀĤ{¼' => '__pest_evaluable_ÀĤ_¼',
];
foreach ($names as $name => $methodName) {