File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,8 @@ public function getDataForPhpize(): array
169169 [1 , '1 ' ],
170170 [-1 , '-1 ' ],
171171 [0777 , '0777 ' ],
172+ [-511 , '-0777 ' ],
173+ ['0877 ' , '0877 ' ],
172174 [255 , '0xFF ' ],
173175 [100.0 , '1e2 ' ],
174176 [-120.0 , '-1.2E2 ' ],
Original file line number Diff line number Diff line change @@ -236,15 +236,11 @@ public static function phpize($value)
236236 case 'null ' === $ lowercaseValue :
237237 return null ;
238238 case ctype_digit ($ value ):
239- $ raw = $ value ;
240- $ cast = (int ) $ value ;
241-
242- return '0 ' == $ value [0 ] ? octdec ($ value ) : (($ raw === (string ) $ cast ) ? $ cast : $ raw );
243239 case isset ($ value [1 ]) && '- ' === $ value [0 ] && ctype_digit (substr ($ value , 1 )):
244240 $ raw = $ value ;
245241 $ cast = (int ) $ value ;
246242
247- return ' 0 ' == $ value[ 1 ] ? octdec ($ value ) : (($ raw === (string ) $ cast ) ? $ cast : $ raw );
243+ return self :: isOctal ( $ value) ? \intval ($ value, 8 ) : (($ raw === (string ) $ cast ) ? $ cast : $ raw );
248244 case 'true ' === $ lowercaseValue :
249245 return true ;
250246 case 'false ' === $ lowercaseValue :
@@ -281,4 +277,13 @@ protected static function getXmlErrors($internalErrors)
281277
282278 return $ errors ;
283279 }
280+
281+ private static function isOctal (string $ str ): bool
282+ {
283+ if ('- ' === $ str [0 ]) {
284+ $ str = substr ($ str , 1 );
285+ }
286+
287+ return $ str === '0 ' .decoct (\intval ($ str , 8 ));
288+ }
284289}
You can’t perform that action at this time.
0 commit comments