@@ -139,7 +139,7 @@ |
||
| 139 | 139 | * @param int $max |
| 140 | 140 | * @param int $min |
| 141 | 141 | * |
| 142 | - * @return mixed |
|
| 142 | + * @return integer |
|
| 143 | 143 | */ |
| 144 | 144 | public function clamp($v, $max = 1, $min = 0) |
| 145 | 145 | { |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | |
| 444 | 444 | /** |
| 445 | 445 | * @param $block |
| 446 | - * @param $out |
|
| 446 | + * @param \stdClass $out |
|
| 447 | 447 | * |
| 448 | 448 | * @throws \LesserPhp\Exception\GeneralException |
| 449 | 449 | */ |
@@ -1724,7 +1724,7 @@ discard block |
||
| 1724 | 1724 | } |
| 1725 | 1725 | |
| 1726 | 1726 | /** |
| 1727 | - * @param $parent |
|
| 1727 | + * @param NodeEnv $parent |
|
| 1728 | 1728 | * @param null $block |
| 1729 | 1729 | * |
| 1730 | 1730 | * @return \LesserPhp\NodeEnv |
@@ -991,7 +991,7 @@ discard block |
||
| 991 | 991 | |
| 992 | 992 | $orderedArgs = []; |
| 993 | 993 | $keywordArgs = []; |
| 994 | - foreach ((array)$args as $arg) { |
|
| 994 | + foreach ((array) $args as $arg) { |
|
| 995 | 995 | switch ($arg[0]) { |
| 996 | 996 | case "arg": |
| 997 | 997 | if (!isset($arg[2])) { |
@@ -1088,8 +1088,7 @@ discard block |
||
| 1088 | 1088 | $result = $this->tryImport($importPath, $block, $out); |
| 1089 | 1089 | |
| 1090 | 1090 | $this->env->addImports($importId, $result === false ? |
| 1091 | - [false, "@import " . $this->compileValue($importPath) . ";"] : |
|
| 1092 | - $result); |
|
| 1091 | + [false, "@import " . $this->compileValue($importPath) . ";"] : $result); |
|
| 1093 | 1092 | |
| 1094 | 1093 | break; |
| 1095 | 1094 | case "import_mixin": |
@@ -1322,7 +1321,7 @@ discard block |
||
| 1322 | 1321 | $key = $this->vPrefix . $this->compileValue($this->functions->e($key)); |
| 1323 | 1322 | } |
| 1324 | 1323 | |
| 1325 | - $seen =& $this->env->seenNames; |
|
| 1324 | + $seen = & $this->env->seenNames; |
|
| 1326 | 1325 | |
| 1327 | 1326 | if (!empty($seen[$key])) { |
| 1328 | 1327 | $this->throwError("infinite loop detected: $key"); |
@@ -1111,42 +1111,42 @@ discard block |
||
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | 1113 | |
| 1114 | - /** |
|
| 1115 | - * Compiles a primitive value into a CSS property value. |
|
| 1116 | - * |
|
| 1117 | - * Values in lessphp are typed by being wrapped in arrays, their format is |
|
| 1118 | - * typically: |
|
| 1119 | - * |
|
| 1120 | - * array(type, contents [, additional_contents]*) |
|
| 1121 | - * |
|
| 1122 | - * The input is expected to be reduced. This function will not work on |
|
| 1123 | - * things like expressions and variables. |
|
| 1124 | - * |
|
| 1125 | - * @param array $value |
|
| 1126 | - * @param array $options |
|
| 1127 | - * |
|
| 1128 | - * @return string |
|
| 1129 | - * @throws GeneralException |
|
| 1130 | - */ |
|
| 1131 | - public function compileValue(array $value, array $options = []) |
|
| 1132 | - { |
|
| 1133 | - try { |
|
| 1134 | - if (!isset($value[0])) { |
|
| 1135 | - throw new GeneralException('Missing value type'); |
|
| 1136 | - } |
|
| 1137 | - |
|
| 1138 | - $options = array_replace([ |
|
| 1139 | - 'numberPrecision' => $this->numberPrecision, |
|
| 1140 | - 'compressColors' => ($this->formatter ? $this->formatter->getCompressColors() : false), |
|
| 1141 | - ], $options); |
|
| 1142 | - |
|
| 1143 | - $valueClass = \LesserPhp\Compiler\Value\AbstractValue::factory($this, $this->coerce, $options, $value); |
|
| 1144 | - |
|
| 1145 | - return $valueClass->getCompiled(); |
|
| 1146 | - } catch (\UnexpectedValueException $e) { |
|
| 1147 | - throw new GeneralException($e->getMessage()); |
|
| 1148 | - } |
|
| 1149 | - } |
|
| 1114 | + /** |
|
| 1115 | + * Compiles a primitive value into a CSS property value. |
|
| 1116 | + * |
|
| 1117 | + * Values in lessphp are typed by being wrapped in arrays, their format is |
|
| 1118 | + * typically: |
|
| 1119 | + * |
|
| 1120 | + * array(type, contents [, additional_contents]*) |
|
| 1121 | + * |
|
| 1122 | + * The input is expected to be reduced. This function will not work on |
|
| 1123 | + * things like expressions and variables. |
|
| 1124 | + * |
|
| 1125 | + * @param array $value |
|
| 1126 | + * @param array $options |
|
| 1127 | + * |
|
| 1128 | + * @return string |
|
| 1129 | + * @throws GeneralException |
|
| 1130 | + */ |
|
| 1131 | + public function compileValue(array $value, array $options = []) |
|
| 1132 | + { |
|
| 1133 | + try { |
|
| 1134 | + if (!isset($value[0])) { |
|
| 1135 | + throw new GeneralException('Missing value type'); |
|
| 1136 | + } |
|
| 1137 | + |
|
| 1138 | + $options = array_replace([ |
|
| 1139 | + 'numberPrecision' => $this->numberPrecision, |
|
| 1140 | + 'compressColors' => ($this->formatter ? $this->formatter->getCompressColors() : false), |
|
| 1141 | + ], $options); |
|
| 1142 | + |
|
| 1143 | + $valueClass = \LesserPhp\Compiler\Value\AbstractValue::factory($this, $this->coerce, $options, $value); |
|
| 1144 | + |
|
| 1145 | + return $valueClass->getCompiled(); |
|
| 1146 | + } catch (\UnexpectedValueException $e) { |
|
| 1147 | + throw new GeneralException($e->getMessage()); |
|
| 1148 | + } |
|
| 1149 | + } |
|
| 1150 | 1150 | |
| 1151 | 1151 | /** |
| 1152 | 1152 | * Helper function to get arguments for color manipulation functions. |
@@ -2055,9 +2055,9 @@ discard block |
||
| 2055 | 2055 | $this->formatterName = $name; |
| 2056 | 2056 | } |
| 2057 | 2057 | |
| 2058 | - public function setFormatterClass($formatter) |
|
| 2059 | - { |
|
| 2060 | - $this->formatter = $formatter; |
|
| 2058 | + public function setFormatterClass($formatter) |
|
| 2059 | + { |
|
| 2060 | + $this->formatter = $formatter; |
|
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | 2063 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * Parser constructor. |
| 100 | 100 | * |
| 101 | 101 | * @param \LesserPhp\Compiler $lessc |
| 102 | - * @param null $sourceName |
|
| 102 | + * @param string $sourceName |
|
| 103 | 103 | */ |
| 104 | 104 | public function __construct(Compiler $lessc, $sourceName = null) |
| 105 | 105 | { |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | - * @param $buffer |
|
| 126 | + * @param string $buffer |
|
| 127 | 127 | * |
| 128 | 128 | * @return mixed |
| 129 | 129 | * @throws \LesserPhp\Exception\GeneralException |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | * recursively parse infix equation with $lhs at precedence $minP |
| 477 | 477 | * |
| 478 | 478 | * @param $lhs |
| 479 | - * @param $minP |
|
| 479 | + * @param integer $minP |
|
| 480 | 480 | * |
| 481 | 481 | * @return array |
| 482 | 482 | */ |
@@ -810,10 +810,10 @@ discard block |
||
| 810 | 810 | /** |
| 811 | 811 | * an unbounded string stopped by $end |
| 812 | 812 | * |
| 813 | - * @param $end |
|
| 813 | + * @param string $end |
|
| 814 | 814 | * @param $out |
| 815 | 815 | * @param null $nestingOpen |
| 816 | - * @param null $rejectStrs |
|
| 816 | + * @param string[] $rejectStrs |
|
| 817 | 817 | * |
| 818 | 818 | * @return bool |
| 819 | 819 | */ |
@@ -1648,7 +1648,7 @@ discard block |
||
| 1648 | 1648 | * @param bool $until |
| 1649 | 1649 | * @param bool $allowNewline |
| 1650 | 1650 | * |
| 1651 | - * @return bool |
|
| 1651 | + * @return null|boolean |
|
| 1652 | 1652 | */ |
| 1653 | 1653 | protected function to($what, &$out, $until = false, $allowNewline = false) |
| 1654 | 1654 | { |
@@ -1821,7 +1821,7 @@ discard block |
||
| 1821 | 1821 | /** |
| 1822 | 1822 | * push a block that doesn't multiply tags |
| 1823 | 1823 | * |
| 1824 | - * @param $type |
|
| 1824 | + * @param string $type |
|
| 1825 | 1825 | * |
| 1826 | 1826 | * @return \stdClass |
| 1827 | 1827 | */ |
@@ -1834,7 +1834,7 @@ discard block |
||
| 1834 | 1834 | * append a property to the current block |
| 1835 | 1835 | * |
| 1836 | 1836 | * @param $prop |
| 1837 | - * @param $pos |
|
| 1837 | + * @param integer $pos |
|
| 1838 | 1838 | */ |
| 1839 | 1839 | protected function append($prop, $pos = null) |
| 1840 | 1840 | { |
@@ -1847,7 +1847,7 @@ discard block |
||
| 1847 | 1847 | /** |
| 1848 | 1848 | * pop something off the stack |
| 1849 | 1849 | * |
| 1850 | - * @return mixed |
|
| 1850 | + * @return null|\stdClass |
|
| 1851 | 1851 | */ |
| 1852 | 1852 | protected function pop() |
| 1853 | 1853 | { |
@@ -1945,7 +1945,7 @@ discard block |
||
| 1945 | 1945 | } |
| 1946 | 1946 | |
| 1947 | 1947 | /** |
| 1948 | - * @param $s |
|
| 1948 | + * @param integer $s |
|
| 1949 | 1949 | * |
| 1950 | 1950 | * @return bool |
| 1951 | 1951 | */ |
@@ -17,21 +17,21 @@ |
||
| 17 | 17 | |
| 18 | 18 | class KeywordValue extends AbstractValue |
| 19 | 19 | { |
| 20 | - private $keyword; |
|
| 20 | + private $keyword; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @inheritdoc |
|
| 24 | - */ |
|
| 25 | - public function getCompiled() |
|
| 26 | - { |
|
| 27 | - return $this->keyword; |
|
| 28 | - } |
|
| 22 | + /** |
|
| 23 | + * @inheritdoc |
|
| 24 | + */ |
|
| 25 | + public function getCompiled() |
|
| 26 | + { |
|
| 27 | + return $this->keyword; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @inheritdoc |
|
| 32 | - */ |
|
| 33 | - public function initializeFromOldFormat(array $value) |
|
| 34 | - { |
|
| 35 | - $this->keyword = $value[1]; |
|
| 36 | - } |
|
| 30 | + /** |
|
| 31 | + * @inheritdoc |
|
| 32 | + */ |
|
| 33 | + public function initializeFromOldFormat(array $value) |
|
| 34 | + { |
|
| 35 | + $this->keyword = $value[1]; |
|
| 36 | + } |
|
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -17,25 +17,25 @@ |
||
| 17 | 17 | |
| 18 | 18 | class RawColorValue extends AbstractValue |
| 19 | 19 | { |
| 20 | - private $value; |
|
| 20 | + private $value; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @inheritdoc |
|
| 24 | - */ |
|
| 25 | - public function getCompiled() |
|
| 26 | - { |
|
| 27 | - if ($this->options['compressColors']) { |
|
| 28 | - return $this->compiler->compileValue($this->coerce->coerceColor(['raw_color', $this->value])); |
|
| 29 | - } |
|
| 22 | + /** |
|
| 23 | + * @inheritdoc |
|
| 24 | + */ |
|
| 25 | + public function getCompiled() |
|
| 26 | + { |
|
| 27 | + if ($this->options['compressColors']) { |
|
| 28 | + return $this->compiler->compileValue($this->coerce->coerceColor(['raw_color', $this->value])); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - return $this->value; |
|
| 32 | - } |
|
| 31 | + return $this->value; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @inheritdoc |
|
| 36 | - */ |
|
| 37 | - public function initializeFromOldFormat(array $value) |
|
| 38 | - { |
|
| 39 | - $this->value = $value[1]; |
|
| 40 | - } |
|
| 34 | + /** |
|
| 35 | + * @inheritdoc |
|
| 36 | + */ |
|
| 37 | + public function initializeFromOldFormat(array $value) |
|
| 38 | + { |
|
| 39 | + $this->value = $value[1]; |
|
| 40 | + } |
|
| 41 | 41 | } |
| 42 | 42 | \ No newline at end of file |
@@ -19,70 +19,70 @@ |
||
| 19 | 19 | |
| 20 | 20 | abstract class AbstractValue |
| 21 | 21 | { |
| 22 | - /** @var Compiler */ |
|
| 23 | - protected $compiler; |
|
| 24 | - /** @var Coerce */ |
|
| 25 | - protected $coerce; |
|
| 22 | + /** @var Compiler */ |
|
| 23 | + protected $compiler; |
|
| 24 | + /** @var Coerce */ |
|
| 25 | + protected $coerce; |
|
| 26 | 26 | |
| 27 | - protected $options = [ |
|
| 28 | - 'numberPrecision' => null, |
|
| 29 | - 'compressColors' => false, |
|
| 30 | - ]; |
|
| 27 | + protected $options = [ |
|
| 28 | + 'numberPrecision' => null, |
|
| 29 | + 'compressColors' => false, |
|
| 30 | + ]; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * AbstractValue constructor. |
|
| 34 | - * |
|
| 35 | - * @param Compiler $compiler |
|
| 36 | - * @param Coerce $coerce |
|
| 37 | - * @param array $options |
|
| 38 | - */ |
|
| 39 | - public function __construct(Compiler $compiler, Coerce $coerce, array $options = []) |
|
| 40 | - { |
|
| 41 | - $this->compiler = $compiler; |
|
| 42 | - $this->coerce = $coerce; |
|
| 43 | - $this->options = array_replace($this->options, $options); |
|
| 44 | - } |
|
| 32 | + /** |
|
| 33 | + * AbstractValue constructor. |
|
| 34 | + * |
|
| 35 | + * @param Compiler $compiler |
|
| 36 | + * @param Coerce $coerce |
|
| 37 | + * @param array $options |
|
| 38 | + */ |
|
| 39 | + public function __construct(Compiler $compiler, Coerce $coerce, array $options = []) |
|
| 40 | + { |
|
| 41 | + $this->compiler = $compiler; |
|
| 42 | + $this->coerce = $coerce; |
|
| 43 | + $this->options = array_replace($this->options, $options); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @param Compiler $compiler |
|
| 48 | - * @param Coerce $coerce |
|
| 49 | - * @param array $options |
|
| 50 | - * @param array $value |
|
| 51 | - * |
|
| 52 | - * @return self |
|
| 53 | - */ |
|
| 54 | - public static function factory(Compiler $compiler, Coerce $coerce, array $options, array $value) |
|
| 55 | - { |
|
| 56 | - $nameParts = explode('_', $value[0]); |
|
| 57 | - $camelCase = array_reduce($nameParts, function($carry, $item){ |
|
| 58 | - return $carry.ucfirst($item); |
|
| 59 | - }, ''); |
|
| 60 | - $valueClassName = 'LesserPhp\Compiler\Value\\'.$camelCase.'Value'; |
|
| 46 | + /** |
|
| 47 | + * @param Compiler $compiler |
|
| 48 | + * @param Coerce $coerce |
|
| 49 | + * @param array $options |
|
| 50 | + * @param array $value |
|
| 51 | + * |
|
| 52 | + * @return self |
|
| 53 | + */ |
|
| 54 | + public static function factory(Compiler $compiler, Coerce $coerce, array $options, array $value) |
|
| 55 | + { |
|
| 56 | + $nameParts = explode('_', $value[0]); |
|
| 57 | + $camelCase = array_reduce($nameParts, function($carry, $item){ |
|
| 58 | + return $carry.ucfirst($item); |
|
| 59 | + }, ''); |
|
| 60 | + $valueClassName = 'LesserPhp\Compiler\Value\\'.$camelCase.'Value'; |
|
| 61 | 61 | |
| 62 | - if (class_exists($valueClassName)) { |
|
| 63 | - $valueClass = new $valueClassName($compiler, $coerce, $options); |
|
| 64 | - if ($valueClass instanceof self) { |
|
| 65 | - $valueClass->initializeFromOldFormat($value); |
|
| 62 | + if (class_exists($valueClassName)) { |
|
| 63 | + $valueClass = new $valueClassName($compiler, $coerce, $options); |
|
| 64 | + if ($valueClass instanceof self) { |
|
| 65 | + $valueClass->initializeFromOldFormat($value); |
|
| 66 | 66 | |
| 67 | - return $valueClass; |
|
| 68 | - } |
|
| 69 | - } |
|
| 67 | + return $valueClass; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - throw new \UnexpectedValueException('unknown value type: '.$value[0]); |
|
| 72 | - } |
|
| 71 | + throw new \UnexpectedValueException('unknown value type: '.$value[0]); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @return string |
|
| 76 | - */ |
|
| 77 | - abstract public function getCompiled(); |
|
| 74 | + /** |
|
| 75 | + * @return string |
|
| 76 | + */ |
|
| 77 | + abstract public function getCompiled(); |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Initialize value from old array format. |
|
| 81 | - * |
|
| 82 | - * @param array $value |
|
| 83 | - * |
|
| 84 | - * @return void |
|
| 85 | - * @deprecated |
|
| 86 | - */ |
|
| 87 | - abstract public function initializeFromOldFormat(array $value); |
|
| 79 | + /** |
|
| 80 | + * Initialize value from old array format. |
|
| 81 | + * |
|
| 82 | + * @param array $value |
|
| 83 | + * |
|
| 84 | + * @return void |
|
| 85 | + * @deprecated |
|
| 86 | + */ |
|
| 87 | + abstract public function initializeFromOldFormat(array $value); |
|
| 88 | 88 | } |
| 89 | 89 | \ No newline at end of file |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | public static function factory(Compiler $compiler, Coerce $coerce, array $options, array $value) |
| 55 | 55 | { |
| 56 | 56 | $nameParts = explode('_', $value[0]); |
| 57 | - $camelCase = array_reduce($nameParts, function($carry, $item){ |
|
| 58 | - return $carry.ucfirst($item); |
|
| 57 | + $camelCase = array_reduce($nameParts, function($carry, $item) { |
|
| 58 | + return $carry . ucfirst($item); |
|
| 59 | 59 | }, ''); |
| 60 | - $valueClassName = 'LesserPhp\Compiler\Value\\'.$camelCase.'Value'; |
|
| 60 | + $valueClassName = 'LesserPhp\Compiler\Value\\' . $camelCase . 'Value'; |
|
| 61 | 61 | |
| 62 | 62 | if (class_exists($valueClassName)) { |
| 63 | 63 | $valueClass = new $valueClassName($compiler, $coerce, $options); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - throw new \UnexpectedValueException('unknown value type: '.$value[0]); |
|
| 71 | + throw new \UnexpectedValueException('unknown value type: ' . $value[0]); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -17,33 +17,33 @@ |
||
| 17 | 17 | |
| 18 | 18 | class ListValue extends AbstractValue |
| 19 | 19 | { |
| 20 | - private $delimiter; |
|
| 21 | - /** @var AbstractValue[] */ |
|
| 22 | - private $items; |
|
| 20 | + private $delimiter; |
|
| 21 | + /** @var AbstractValue[] */ |
|
| 22 | + private $items; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @inheritdoc |
|
| 26 | - */ |
|
| 27 | - public function getCompiled() |
|
| 28 | - { |
|
| 29 | - $compiled = []; |
|
| 30 | - foreach ($this->items as $item) { |
|
| 31 | - $compiled[] = $item->getCompiled(); |
|
| 32 | - } |
|
| 24 | + /** |
|
| 25 | + * @inheritdoc |
|
| 26 | + */ |
|
| 27 | + public function getCompiled() |
|
| 28 | + { |
|
| 29 | + $compiled = []; |
|
| 30 | + foreach ($this->items as $item) { |
|
| 31 | + $compiled[] = $item->getCompiled(); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return implode($this->delimiter, $compiled); |
|
| 35 | - } |
|
| 34 | + return implode($this->delimiter, $compiled); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @inheritdoc |
|
| 39 | - */ |
|
| 40 | - public function initializeFromOldFormat(array $value) |
|
| 41 | - { |
|
| 42 | - $this->delimiter = $value[1]; |
|
| 43 | - $this->items = []; |
|
| 37 | + /** |
|
| 38 | + * @inheritdoc |
|
| 39 | + */ |
|
| 40 | + public function initializeFromOldFormat(array $value) |
|
| 41 | + { |
|
| 42 | + $this->delimiter = $value[1]; |
|
| 43 | + $this->items = []; |
|
| 44 | 44 | |
| 45 | - foreach ($value[2] as $item) { |
|
| 46 | - $this->items[] = self::factory($this->compiler, $this->coerce, $this->options, $item); |
|
| 47 | - } |
|
| 48 | - } |
|
| 45 | + foreach ($value[2] as $item) { |
|
| 46 | + $this->items[] = self::factory($this->compiler, $this->coerce, $this->options, $item); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -17,44 +17,44 @@ |
||
| 17 | 17 | |
| 18 | 18 | class ColorValue extends AbstractValue |
| 19 | 19 | { |
| 20 | - private $red, $green, $blue, $alpha; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @inheritdoc |
|
| 24 | - */ |
|
| 25 | - public function getCompiled() |
|
| 26 | - { |
|
| 27 | - $red = round($this->red); |
|
| 28 | - $green = round($this->green); |
|
| 29 | - $blue = round($this->blue); |
|
| 30 | - |
|
| 31 | - if ($this->alpha !== null && $this->alpha != 1) { |
|
| 32 | - return 'rgba('.$red.','.$green.','.$blue.','.$this->alpha.')'; |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - $hex = sprintf("#%02x%02x%02x", $red, $green, $blue); |
|
| 36 | - |
|
| 37 | - if ($this->options['compressColors']) { |
|
| 38 | - // Converting hex color to short notation (e.g. #003399 to #039) |
|
| 39 | - if ($hex[1] === $hex[2] && $hex[3] === $hex[4] && $hex[5] === $hex[6]) { |
|
| 40 | - $hex = '#'.$hex[1].$hex[3].$hex[5]; |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - return $hex; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @inheritdoc |
|
| 49 | - */ |
|
| 50 | - public function initializeFromOldFormat(array $value) |
|
| 51 | - { |
|
| 52 | - $this->red = $value[1]; |
|
| 53 | - $this->green = $value[2]; |
|
| 54 | - $this->blue = $value[3]; |
|
| 55 | - |
|
| 56 | - if (isset($value[4])) { |
|
| 57 | - $this->alpha = $value[4]; |
|
| 58 | - } |
|
| 59 | - } |
|
| 20 | + private $red, $green, $blue, $alpha; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @inheritdoc |
|
| 24 | + */ |
|
| 25 | + public function getCompiled() |
|
| 26 | + { |
|
| 27 | + $red = round($this->red); |
|
| 28 | + $green = round($this->green); |
|
| 29 | + $blue = round($this->blue); |
|
| 30 | + |
|
| 31 | + if ($this->alpha !== null && $this->alpha != 1) { |
|
| 32 | + return 'rgba('.$red.','.$green.','.$blue.','.$this->alpha.')'; |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + $hex = sprintf("#%02x%02x%02x", $red, $green, $blue); |
|
| 36 | + |
|
| 37 | + if ($this->options['compressColors']) { |
|
| 38 | + // Converting hex color to short notation (e.g. #003399 to #039) |
|
| 39 | + if ($hex[1] === $hex[2] && $hex[3] === $hex[4] && $hex[5] === $hex[6]) { |
|
| 40 | + $hex = '#'.$hex[1].$hex[3].$hex[5]; |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + return $hex; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @inheritdoc |
|
| 49 | + */ |
|
| 50 | + public function initializeFromOldFormat(array $value) |
|
| 51 | + { |
|
| 52 | + $this->red = $value[1]; |
|
| 53 | + $this->green = $value[2]; |
|
| 54 | + $this->blue = $value[3]; |
|
| 55 | + |
|
| 56 | + if (isset($value[4])) { |
|
| 57 | + $this->alpha = $value[4]; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | } |
| 61 | 61 | \ No newline at end of file |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $blue = round($this->blue); |
| 30 | 30 | |
| 31 | 31 | if ($this->alpha !== null && $this->alpha != 1) { |
| 32 | - return 'rgba('.$red.','.$green.','.$blue.','.$this->alpha.')'; |
|
| 32 | + return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $this->alpha . ')'; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $hex = sprintf("#%02x%02x%02x", $red, $green, $blue); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | if ($this->options['compressColors']) { |
| 38 | 38 | // Converting hex color to short notation (e.g. #003399 to #039) |
| 39 | 39 | if ($hex[1] === $hex[2] && $hex[3] === $hex[4] && $hex[5] === $hex[6]) { |
| 40 | - $hex = '#'.$hex[1].$hex[3].$hex[5]; |
|
| 40 | + $hex = '#' . $hex[1] . $hex[3] . $hex[5]; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
@@ -17,27 +17,27 @@ |
||
| 17 | 17 | |
| 18 | 18 | class NumberValue extends AbstractValue |
| 19 | 19 | { |
| 20 | - private $number, $unit; |
|
| 20 | + private $number, $unit; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @inheritdoc |
|
| 24 | - */ |
|
| 25 | - public function getCompiled() |
|
| 26 | - { |
|
| 27 | - $num = $this->number; |
|
| 28 | - if (isset($this->options['numberPrecision'])) { |
|
| 29 | - $num = round($num, $this->options['numberPrecision']); |
|
| 30 | - } |
|
| 22 | + /** |
|
| 23 | + * @inheritdoc |
|
| 24 | + */ |
|
| 25 | + public function getCompiled() |
|
| 26 | + { |
|
| 27 | + $num = $this->number; |
|
| 28 | + if (isset($this->options['numberPrecision'])) { |
|
| 29 | + $num = round($num, $this->options['numberPrecision']); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - return $num.$this->unit; |
|
| 33 | - } |
|
| 32 | + return $num.$this->unit; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @inheritdoc |
|
| 37 | - */ |
|
| 38 | - public function initializeFromOldFormat(array $value) |
|
| 39 | - { |
|
| 40 | - $this->number = $value[1]; |
|
| 41 | - $this->unit = $value[2]; |
|
| 42 | - } |
|
| 35 | + /** |
|
| 36 | + * @inheritdoc |
|
| 37 | + */ |
|
| 38 | + public function initializeFromOldFormat(array $value) |
|
| 39 | + { |
|
| 40 | + $this->number = $value[1]; |
|
| 41 | + $this->unit = $value[2]; |
|
| 42 | + } |
|
| 43 | 43 | } |
| 44 | 44 | \ No newline at end of file |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | $num = round($num, $this->options['numberPrecision']); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - return $num.$this->unit; |
|
| 32 | + return $num . $this->unit; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |