1919use function explode ;
2020use function gettype ;
2121use function implode ;
22- use function in_array ;
2322use function is_bool ;
2423use function is_float ;
2524use function is_int ;
5453final class NamePrettifier
5554{
5655 /**
57- * @psalm-var list <string>
56+ * @psalm-var array <string, int >
5857 */
5958 private static array $ strings = [];
6059
@@ -117,10 +116,10 @@ public function prettifyTestMethodName(string $name): string
117116
118117 $ string = (string ) preg_replace ('#\d+$# ' , '' , $ name , -1 , $ count );
119118
120- if (in_array ($ string , self ::$ strings, true )) {
119+ if (array_key_exists ($ string , self ::$ strings )) {
121120 $ name = $ string ;
122121 } elseif ($ count === 0 ) {
123- self ::$ strings [] = $ string ;
122+ self ::$ strings [$ string ] = 1 ;
124123 }
125124
126125 if (str_starts_with ($ name , 'test_ ' )) {
@@ -136,13 +135,15 @@ public function prettifyTestMethodName(string $name): string
136135 $ name [0 ] = strtoupper ($ name [0 ]);
137136
138137 $ noUnderscore = str_replace ('_ ' , ' ' , $ name );
138+
139139 if ($ noUnderscore !== $ name ) {
140140 return trim ($ noUnderscore );
141141 }
142142
143143 $ wasNumeric = false ;
144144
145145 $ buffer = '' ;
146+
146147 foreach (range (0 , strlen ($ name ) - 1 ) as $ i ) {
147148 if ($ i > 0 && $ name [$ i ] >= 'A ' && $ name [$ i ] <= 'Z ' ) {
148149 $ buffer .= ' ' . strtolower ($ name [$ i ]);
0 commit comments