Fix pretty printing of whole-numbered floats

This time properly. Only remaining problem is that floats like 1e1000 are printed as INF. This may or may not be acceptable. The value will be the same, but the tests will signal a diff failure.
This commit is contained in:
nikic 2011-10-16 15:39:23 +02:00
parent b77d66e5bd
commit 7078252444

View File

@ -78,9 +78,10 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
}
public function pScalar_DNumber(PHPParser_Node_Scalar_DNumber $node) {
return (string) (int) $node->value == (string) $node->value
? (string) $node->value . '.0' // ensure that number is really printed as float
: (string) $node->value;
$stringValue = (string) $node->value;
// ensure that number is really printed as float
return ctype_digit($stringValue) ? $stringValue . '.0' : $stringValue;
}
// Assignments