@@ -38,7 +38,7 @@ public static function toLine(mixed $var): string
3838 return "$ var " ;
3939
4040 } elseif (is_float ($ var )) {
41- return var_export ($ var , true );
41+ return var_export ($ var , return: true );
4242
4343 } elseif (is_string ($ var )) {
4444 if (preg_match ('#^(.{ ' . self ::$ maxLength . '}).#su ' , $ var , $ m )) {
@@ -138,7 +138,7 @@ private static function _toPhp(mixed &$var, array &$list = [], int $level = 0, i
138138
139139 static $ marker ;
140140 if ($ marker === null ) {
141- $ marker = uniqid ("\x00" , true );
141+ $ marker = uniqid ("\x00" , more_entropy: true );
142142 }
143143
144144 if (empty ($ var )) {
@@ -221,7 +221,7 @@ private static function _toPhp(mixed &$var, array &$list = [], int $level = 0, i
221221 return '/* resource ' . get_resource_type ($ var ) . ' */ ' ;
222222
223223 } else {
224- return var_export ($ var , true );
224+ return var_export ($ var , return: true );
225225 }
226226 }
227227
@@ -238,12 +238,10 @@ private static function encodeStringPhp(string $s): string
238238 $ utf8 = preg_match ('##u ' , $ s );
239239 $ escaped = preg_replace_callback (
240240 $ utf8 ? '#[\p{C} \\\\]#u ' : '#[\x00-\x1F\x7F-\xFF \\\\]# ' ,
241- function ($ m ) use ($ special ) {
242- return $ special [$ m [0 ]] ?? (strlen ($ m [0 ]) === 1
243- ? '\x ' . str_pad (strtoupper (dechex (ord ($ m [0 ]))), 2 , '0 ' , STR_PAD_LEFT ) . ''
244- : '\u{ ' . strtoupper (ltrim (dechex (self ::utf8Ord ($ m [0 ])), '0 ' )) . '} ' );
245- },
246- $ s
241+ fn ($ m ) => $ special [$ m [0 ]] ?? (strlen ($ m [0 ]) === 1
242+ ? '\x ' . str_pad (strtoupper (dechex (ord ($ m [0 ]))), 2 , '0 ' , STR_PAD_LEFT ) . ''
243+ : '\u{ ' . strtoupper (ltrim (dechex (self ::utf8Ord ($ m [0 ])), '0 ' )) . '} ' ),
244+ $ s ,
247245 );
248246 return $ s === str_replace ('\\\\' , '\\' , $ escaped )
249247 ? "' " . preg_replace ('# \'| \\\\(?=[ \'\\\\]|$)#D ' , '\\\\$0 ' , $ s ) . "' "
@@ -263,14 +261,12 @@ private static function encodeStringLine(string $s): string
263261 $ utf8 = preg_match ('##u ' , $ s );
264262 $ escaped = preg_replace_callback (
265263 $ utf8 ? '#[\p{C} \']#u ' : '#[\x00-\x1F\x7F-\xFF \']# ' ,
266- function ($ m ) use ($ special ) {
267- return "\e[22m "
268- . ($ special [$ m [0 ]] ?? (strlen ($ m [0 ]) === 1
269- ? '\x ' . str_pad (strtoupper (dechex (ord ($ m [0 ]))), 2 , '0 ' , STR_PAD_LEFT )
270- : '\u{ ' . strtoupper (ltrim (dechex (self ::utf8Ord ($ m [0 ])), '0 ' )) . '} ' ))
271- . "\e[1m " ;
272- },
273- $ s
264+ fn ($ m ) => "\e[22m "
265+ . ($ special [$ m [0 ]] ?? (strlen ($ m [0 ]) === 1
266+ ? '\x ' . str_pad (strtoupper (dechex (ord ($ m [0 ]))), 2 , '0 ' , STR_PAD_LEFT )
267+ : '\u{ ' . strtoupper (ltrim (dechex (self ::utf8Ord ($ m [0 ])), '0 ' )) . '} ' ))
268+ . "\e[1m " ,
269+ $ s ,
274270 );
275271 return "' " . $ escaped . "' " ;
276272 }
@@ -326,7 +322,7 @@ public static function dumpException(\Throwable $e): string
326322 for (; $ i && $ i < strlen ($ actual ) && $ actual [$ i - 1 ] >= "\x80" && $ actual [$ i ] >= "\x80" && $ actual [$ i ] < "\xC0" ; $ i --);
327323 $ i = max (0 , min (
328324 $ i - (int ) (self ::$ maxLength / 3 ), // try to display 1/3 of shorter string
329- max (strlen ($ actual ), strlen ($ expected )) - self ::$ maxLength + 3 // 3 = length of ...
325+ max (strlen ($ actual ), strlen ($ expected )) - self ::$ maxLength + 3 , // 3 = length of ...
330326 ));
331327 if ($ i ) {
332328 $ expected = substr_replace ($ expected , '... ' , 0 , $ i );
@@ -370,7 +366,7 @@ public static function dumpException(\Throwable $e): string
370366 ($ item ['file ' ] === $ testFile ? self ::color ('white ' ) : '' )
371367 . implode (
372368 self ::$ pathSeparator ?? DIRECTORY_SEPARATOR ,
373- array_slice (explode (DIRECTORY_SEPARATOR , $ item ['file ' ]), -self ::$ maxPathSegments )
369+ array_slice (explode (DIRECTORY_SEPARATOR , $ item ['file ' ]), -self ::$ maxPathSegments ),
374370 )
375371 . "( $ item [line]) " . self ::color ('gray ' ) . ' '
376372 )
0 commit comments