From 8b156013747f21b7769f66025670b36dbac6b882 Mon Sep 17 00:00:00 2001 From: Yann Di Serio Date: Fri, 13 Oct 2017 08:13:11 +0200 Subject: [PATCH 1/4] Custom round method to avoid PHP native round function to use locale separator. --- src/Node/Number.php | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/Node/Number.php b/src/Node/Number.php index 442d57d5..928658d7 100644 --- a/src/Node/Number.php +++ b/src/Node/Number.php @@ -32,6 +32,10 @@ class Number extends Node implements \ArrayAccess * @var integer */ static public $precision = 5; + + static public $decSeparator = '.'; + + static public $hunSeparator = ''; /** * @see http://www.w3.org/TR/2012/WD-css3-values-20120308/ @@ -265,7 +269,7 @@ public function unitStr() */ public function output(Compiler $compiler = null) { - $dimension = round($this->dimension, static::$precision); + $dimension = $this->round($this->dimension);; $units = array_filter($this->units, function ($unitSize) { return $unitSize; @@ -277,7 +281,7 @@ public function output(Compiler $compiler = null) $this->normalizeUnits($dimension, $units, 'in'); - $dimension = round($dimension, static::$precision); + $dimension = $this->round($dimension); $units = array_filter($units, function ($unitSize) { return $unitSize; }); @@ -290,10 +294,31 @@ public function output(Compiler $compiler = null) } reset($units); - $unit = key($units); + list($unit, ) = each($units); return (string) $dimension . $unit; } + + /** + * Round number with proper separators + * + * @param $dimension + * + * @return string + */ + protected function round($dimension) + { + return rtrim( + rtrim( + number_format( + round($dimension, static::$precision), + static::$precision, + static::$decSeparator, + static::$thouSeparator + ), + '0'), + '.'); + } /** * {@inheritdoc} From e112428f4946b0341565e6432af7b663cea93de4 Mon Sep 17 00:00:00 2001 From: Yann Di Serio Date: Fri, 13 Oct 2017 08:13:59 +0200 Subject: [PATCH 2/4] Remove deprecated "each" function --- src/Node/Number.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Node/Number.php b/src/Node/Number.php index 928658d7..cb4e3c47 100644 --- a/src/Node/Number.php +++ b/src/Node/Number.php @@ -294,7 +294,7 @@ public function output(Compiler $compiler = null) } reset($units); - list($unit, ) = each($units); + $unit = key($units); return (string) $dimension . $unit; } From fb8acb9ad697d23edf43d640f81b8d516970d2aa Mon Sep 17 00:00:00 2001 From: Yann Di Serio Date: Fri, 13 Oct 2017 08:31:29 +0200 Subject: [PATCH 3/4] Update composer json. --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 95118a32..ba163dc2 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { - "name": "leafo/scssphp", + "name": "arlisaha/scssphp", "type": "library", - "description": "scssphp is a compiler for SCSS written in PHP.", + "description": "Fork from Leafo SCSS PHP compiler (see homepage).", "keywords": ["css", "stylesheet", "scss", "sass", "less"], "homepage": "http://leafo.github.io/scssphp/", "license": [ From 63fe05e038b3e1b2ed4af55f48e810b60d575690 Mon Sep 17 00:00:00 2001 From: Yann Di Serio Date: Fri, 13 Oct 2017 09:45:07 +0200 Subject: [PATCH 4/4] Fix use of static property. --- src/Node/Number.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Node/Number.php b/src/Node/Number.php index cb4e3c47..bbfb3799 100644 --- a/src/Node/Number.php +++ b/src/Node/Number.php @@ -35,7 +35,7 @@ class Number extends Node implements \ArrayAccess static public $decSeparator = '.'; - static public $hunSeparator = ''; + static public $thouSeparator = ''; /** * @see http://www.w3.org/TR/2012/WD-css3-values-20120308/