From 5a3a1ec25cd3aec24b5366d1948adfa3c1279ef8 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 19 Jul 2017 17:10:55 +0200 Subject: [PATCH 1/2] Handle LC_NUMERIC with comma decimal separator Closes #399. --- lib/PhpParser/PrettyPrinter/Standard.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/PhpParser/PrettyPrinter/Standard.php b/lib/PhpParser/PrettyPrinter/Standard.php index 056e014..9a4bce0 100644 --- a/lib/PhpParser/PrettyPrinter/Standard.php +++ b/lib/PhpParser/PrettyPrinter/Standard.php @@ -182,6 +182,11 @@ class Standard extends PrettyPrinterAbstract $stringValue = sprintf('%.17G', $node->value); } + // %G is locale dependent and there exists no locale-independent alternative. We don't want + // mess with switching locales here, so let's assume that a comma is the only non-standard + // decimal separator we may encounter... + $stringValue = str_replace(',', '.', $stringValue); + // ensure that number is really printed as float return preg_match('/^-?[0-9]+$/', $stringValue) ? $stringValue . '.0' : $stringValue; } From 6fa073879e10264fdee306b05e4a61eef08f4429 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 19 Jul 2017 17:13:10 +0200 Subject: [PATCH 2/2] Remove deprecation of Name::$parts It doesn't look like this is going away for now, and we currently don't have the APIs to cover all existing usages elegantly. --- lib/PhpParser/Node/Name.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/PhpParser/Node/Name.php b/lib/PhpParser/Node/Name.php index d3d33ea..7b8c8e2 100644 --- a/lib/PhpParser/Node/Name.php +++ b/lib/PhpParser/Node/Name.php @@ -8,7 +8,6 @@ class Name extends NodeAbstract { /** * @var string[] Parts of the name - * @deprecated Avoid directly accessing $parts, use methods instead. */ public $parts;