From ed3bb2634dbaf4c852d1da002c59b92df00e1a87 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Tue, 21 Mar 2023 15:15:38 +0100 Subject: [PATCH] using php documentation regex --- src/Support/Str.php | 3 ++- tests/Unit/TestName.php | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Support/Str.php b/src/Support/Str.php index 896710c3..21ee5c5b 100644 --- a/src/Support/Str.php +++ b/src/Support/Str.php @@ -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); } /** diff --git a/tests/Unit/TestName.php b/tests/Unit/TestName.php index 2d5ce4aa..a7455d32 100644 --- a/tests/Unit/TestName.php +++ b/tests/Unit/TestName.php @@ -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) {