mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-01-17 07:08:14 +01:00
Correctly pretty print negative floats
This commit is contained in:
parent
8c59f41d02
commit
c8c233f900
@ -98,7 +98,7 @@ class Standard extends PrettyPrinterAbstract
|
||||
$stringValue = (string) $node->value;
|
||||
|
||||
// ensure that number is really printed as float
|
||||
return ctype_digit($stringValue) ? $stringValue . '.0' : $stringValue;
|
||||
return preg_match('/^-?[0-9]+$/', $stringValue) ? $stringValue . '.0' : $stringValue;
|
||||
}
|
||||
|
||||
// Assignments
|
||||
@ -735,4 +735,4 @@ class Standard extends PrettyPrinterAbstract
|
||||
return $this->p($node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
35
test/code/prettyPrinter/numbers.test
Normal file
35
test/code/prettyPrinter/numbers.test
Normal file
@ -0,0 +1,35 @@
|
||||
Number literals
|
||||
-----
|
||||
<?php
|
||||
|
||||
0;
|
||||
+0;
|
||||
-0;
|
||||
0.0;
|
||||
-0.0;
|
||||
42;
|
||||
-42;
|
||||
42.0;
|
||||
-42.0;
|
||||
42.5;
|
||||
-42.5;
|
||||
1e42;
|
||||
-1e42;
|
||||
1e1000;
|
||||
-1e1000;
|
||||
-----
|
||||
0;
|
||||
+0;
|
||||
-0;
|
||||
0.0;
|
||||
-0.0;
|
||||
42;
|
||||
-42;
|
||||
42.0;
|
||||
-42.0;
|
||||
42.5;
|
||||
-42.5;
|
||||
1.0E+42;
|
||||
-1.0E+42;
|
||||
INF;
|
||||
-INF;
|
Loading…
x
Reference in New Issue
Block a user