mirror of
https://github.com/danog/PHP-Parser.git
synced 2025-01-22 13:51:12 +01:00
Avoid notices in php 7.4 with hexdec/base_convert (#619)
This is made to avoid notices caused by https://wiki.php.net/rfc/base_convert_improvements (seen with `php -d error_reporting=E_ALL vendor/bin/phpunit`)
This commit is contained in:
parent
3f718ee2c3
commit
2e2954ccdf
@ -100,7 +100,7 @@ class String_ extends Scalar
|
||||
if (isset(self::$replacements[$str])) {
|
||||
return self::$replacements[$str];
|
||||
} elseif ('x' === $str[0] || 'X' === $str[0]) {
|
||||
return chr(hexdec($str));
|
||||
return chr(hexdec(substr($str, 1)));
|
||||
} elseif ('u' === $str[0]) {
|
||||
return self::codePointToUtf8(hexdec($matches[2]));
|
||||
} else {
|
||||
|
@ -159,8 +159,13 @@ class Standard extends PrettyPrinterAbstract
|
||||
return (string) $node->value;
|
||||
}
|
||||
|
||||
$sign = $node->value < 0 ? '-' : '';
|
||||
if ($node->value < 0) {
|
||||
$sign = '-';
|
||||
$str = (string) -$node->value;
|
||||
} else {
|
||||
$sign = '';
|
||||
$str = (string) $node->value;
|
||||
}
|
||||
switch ($kind) {
|
||||
case Scalar\LNumber::KIND_BIN:
|
||||
return $sign . '0b' . base_convert($str, 10, 2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user