From 653b2bd351cc7dc26e7f45606c1305549ba4e433 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Sun, 1 Oct 2017 11:24:18 +0800 Subject: [PATCH] MDL-60287 scssphp: upgraded to 0.6.7 --- lib/scssphp/Base/Range.php | 2 +- lib/scssphp/Block.php | 2 +- lib/scssphp/Colors.php | 2 +- lib/scssphp/Compiler.php | 204 ++++++++++++-------- lib/scssphp/Compiler/Environment.php | 2 +- lib/scssphp/Exception/CompilerException.php | 2 +- lib/scssphp/Exception/ParserException.php | 2 +- lib/scssphp/Exception/RangeException.php | 21 ++ lib/scssphp/Exception/ServerException.php | 2 +- lib/scssphp/Formatter.php | 2 +- lib/scssphp/Formatter/Compact.php | 2 +- lib/scssphp/Formatter/Compressed.php | 2 +- lib/scssphp/Formatter/Crunched.php | 2 +- lib/scssphp/Formatter/Debug.php | 2 +- lib/scssphp/Formatter/Expanded.php | 2 +- lib/scssphp/Formatter/Nested.php | 2 +- lib/scssphp/Formatter/OutputBlock.php | 2 +- lib/scssphp/Node.php | 2 +- lib/scssphp/Node/Number.php | 12 +- lib/scssphp/Parser.php | 40 ++-- lib/scssphp/Server.php | 4 +- lib/scssphp/Type.php | 2 +- lib/scssphp/Util.php | 7 +- lib/scssphp/Version.php | 4 +- lib/scssphp/moodle_readme.txt | 6 +- lib/thirdpartylibs.xml | 2 +- 26 files changed, 202 insertions(+), 132 deletions(-) create mode 100644 lib/scssphp/Exception/RangeException.php diff --git a/lib/scssphp/Base/Range.php b/lib/scssphp/Base/Range.php index a591d7b094f..3f3a067da23 100644 --- a/lib/scssphp/Base/Range.php +++ b/lib/scssphp/Base/Range.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2015 Leaf Corcoran + * @copyright 2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Block.php b/lib/scssphp/Block.php index 6b972a1b98d..a6b5f3f0ebc 100644 --- a/lib/scssphp/Block.php +++ b/lib/scssphp/Block.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Colors.php b/lib/scssphp/Colors.php index ff48c199ee0..61a71ab67ae 100644 --- a/lib/scssphp/Colors.php +++ b/lib/scssphp/Colors.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Compiler.php b/lib/scssphp/Compiler.php index d008a844aee..68003b90f43 100644 --- a/lib/scssphp/Compiler.php +++ b/lib/scssphp/Compiler.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * @@ -395,10 +395,11 @@ class Compiler if ($i < $from) { continue; } - if ($this->matchExtendsSingle($part, $origin)) { + if ($this->matchExtendsSingle($part, $origin)) { $after = array_slice($selector, $i + 1); $before = array_slice($selector, 0, $i); + list($before, $nonBreakableBefore) = $this->extractRelationshipFromFragment($before); foreach ($origin as $new) { @@ -413,13 +414,16 @@ class Compiler $replacement = []; $tempReplacement = $k > 0 ? array_slice($new, $k) : $new; - for ($l = count($tempReplacement) - 1; $l >= 0 ; $l--) { + + for ($l = count($tempReplacement) - 1; $l >= 0; $l--) { $slice = $tempReplacement[$l]; array_unshift($replacement, $slice); - if (!$this->isImmediateRelationshipCombinator(end($slice))) { + + if (! $this->isImmediateRelationshipCombinator(end($slice))) { break; } } + $afterBefore = $l != 0 ? array_slice($tempReplacement, 0, $l) : []; // Merge shared direct relationships. @@ -443,9 +447,9 @@ class Compiler // selector sequence merging if (! empty($before) && count($new) > 1) { - $sharedParts = $k > 0 ? array_slice($before, 0, $k) : []; $postSharedParts = $k > 0 ? array_slice($before, $k) : $before; + list($injectBetweenSharedParts, $nonBreakable2) = $this->extractRelationshipFromFragment($afterBefore); $result2 = array_merge( @@ -492,6 +496,7 @@ class Compiler } $extendingDecoratedTag = false; + if (count($single) > 1) { $matches = null; $extendingDecoratedTag = preg_match('/^[a-z0-9]+$/i', $single[0], $matches) ? $matches[0] : false; @@ -529,8 +534,9 @@ class Compiler $replacement = end($new); // Extending a decorated tag with another tag is not possible. - if ($extendingDecoratedTag && $replacement[0] != $extendingDecoratedTag - && preg_match('/^[a-z0-9]+$/i', $replacement[0])) { + if ($extendingDecoratedTag && $replacement[0] != $extendingDecoratedTag && + preg_match('/^[a-z0-9]+$/i', $replacement[0]) + ) { unset($origin[$j]); continue; } @@ -568,15 +574,17 @@ class Compiler $children = []; $j = $i = count($fragment); - do { + for (;;) { $children = $j != $i ? array_slice($fragment, $j, $i - $j) : []; $parents = array_slice($fragment, 0, $j); $slice = end($parents); - $hasImmediateRelationshipCombinator = !empty($slice) && $this->isImmediateRelationshipCombinator($slice[0]); - if ($hasImmediateRelationshipCombinator) { - $j -= 2; + + if (empty($slice) || ! $this->isImmediateRelationshipCombinator($slice[0])) { + break; } - } while ($hasImmediateRelationshipCombinator); + + $j -= 2; + } return [$parents, $children]; } @@ -721,7 +729,7 @@ class Compiler { $env = $this->pushEnv($block); $envs = $this->compactEnv($env); - $without = isset($block->with) ? $this->compileWith($block->with) : self::WITH_RULE; + $without = isset($block->with) ? $this->compileWith($block->with) : static::WITH_RULE; // wrap inline selector if ($block->selector) { @@ -846,12 +854,12 @@ class Compiler ]; // exclude selectors by default - $without = self::WITH_RULE; + $without = static::WITH_RULE; - if ($this->libMapHasKey([$with, self::$with])) { - $without = self::WITH_ALL; + if ($this->libMapHasKey([$with, static::$with])) { + $without = static::WITH_ALL; - $list = $this->coerceList($this->libMapGet([$with, self::$with])); + $list = $this->coerceList($this->libMapGet([$with, static::$with])); foreach ($list[2] as $item) { $keyword = $this->compileStringContent($this->coerceString($item)); @@ -862,10 +870,10 @@ class Compiler } } - if ($this->libMapHasKey([$with, self::$without])) { + if ($this->libMapHasKey([$with, static::$without])) { $without = 0; - $list = $this->coerceList($this->libMapGet([$with, self::$without])); + $list = $this->coerceList($this->libMapGet([$with, static::$without])); foreach ($list[2] as $item) { $keyword = $this->compileStringContent($this->coerceString($item)); @@ -912,10 +920,10 @@ class Compiler */ private function isWithout($without, Block $block) { - if ((($without & self::WITH_RULE) && isset($block->selectors)) || - (($without & self::WITH_MEDIA) && + if ((($without & static::WITH_RULE) && isset($block->selectors)) || + (($without & static::WITH_MEDIA) && isset($block->type) && $block->type === Type::T_MEDIA) || - (($without & self::WITH_SUPPORTS) && + (($without & static::WITH_SUPPORTS) && isset($block->type) && $block->type === Type::T_DIRECTIVE && isset($block->name) && $block->name === 'supports') ) { @@ -1006,13 +1014,16 @@ class Compiler $line = $block->sourceLine; switch ($this->lineNumberStyle) { - case self::LINE_COMMENTS: - $annotation->lines[] = '/* line ' . $line . ', ' . $file . ' */'; + case static::LINE_COMMENTS: + $annotation->lines[] = '/* line ' . $line + . ($file ? ', ' . $file : '') + . ' */'; break; - case self::DEBUG_INFO: - $annotation->lines[] = '@media -sass-debug-info{filename{font-family:"' . $file - . '"}line{font-family:' . $line . '}}'; + case static::DEBUG_INFO: + $annotation->lines[] = '@media -sass-debug-info{' + . ($file ? 'filename{font-family:"' . $file . '"}' : '') + . 'line{font-family:' . $line . '}}'; break; } @@ -1353,30 +1364,33 @@ class Compiler return $out; } - protected function mergeDirectRelationships($selectors1, $selectors2) { + protected function mergeDirectRelationships($selectors1, $selectors2) + { if (empty($selectors1) || empty($selectors2)) { return array_merge($selectors1, $selectors2); } $part1 = end($selectors1); $part2 = end($selectors2); - if (!$this->isImmediateRelationshipCombinator($part1[0]) || $part1 !== $part2) { + + if (! $this->isImmediateRelationshipCombinator($part1[0]) || $part1 !== $part2) { return array_merge($selectors1, $selectors2); } $merged = []; + do { $part1 = array_pop($selectors1); $part2 = array_pop($selectors2); - if ($this->isImmediateRelationshipCombinator($part1[0]) && $part1 === $part2) { - array_unshift($merged, $part1); - array_unshift($merged, [array_pop($selectors1)[0] . array_pop($selectors2)[0]]); - } else { + if ($this->isImmediateRelationshipCombinator($part1[0]) && $part1 !== $part2) { $merged = array_merge($selectors1, [$part1], $selectors2, [$part2], $merged); break; } - } while (!empty($selectors1) && !empty($selectors2)); + + array_unshift($merged, $part1); + array_unshift($merged, [array_pop($selectors1)[0] . array_pop($selectors2)[0]]); + } while (! empty($selectors1) && ! empty($selectors2)); return $merged; } @@ -1569,7 +1583,7 @@ class Compiler $shouldSet = $isDefault && (($result = $this->get($name[1], false)) === null - || $result === self::$null); + || $result === static::$null); if (! $isDefault || $shouldSet) { $this->set($name[1], $this->reduce($value)); @@ -1597,7 +1611,7 @@ class Compiler if ($value[0] !== Type::T_NULL) { $value = $this->reduce($value); - if ($value[0] === Type::T_NULL || $value === self::$nullString) { + if ($value[0] === Type::T_NULL || $value === static::$nullString) { break; } } @@ -1623,7 +1637,7 @@ class Compiler case Type::T_FUNCTION: list(, $block) = $child; - $this->set(self::$namespaces[$block->type] . $block->name, $block); + $this->set(static::$namespaces[$block->type] . $block->name, $block); break; case Type::T_EXTEND: @@ -1671,7 +1685,7 @@ class Compiler list(,, $values) = $this->coerceList($item); foreach ($each->vars as $i => $var) { - $this->set($var, isset($values[$i]) ? $values[$i] : self::$null, true); + $this->set($var, isset($values[$i]) ? $values[$i] : static::$null, true); } } @@ -1720,7 +1734,7 @@ class Compiler $end = $end[1]; $d = $start < $end ? 1 : -1; - while (true) { + for (;;) { if ((! $for->until && $start - $d == $end) || ($for->until && $start == $end) ) { @@ -1780,7 +1794,7 @@ class Compiler // including a mixin list(, $name, $argValues, $content) = $child; - $mixin = $this->get(self::$namespaces['mixin'] . $name, false); + $mixin = $this->get(static::$namespaces['mixin'] . $name, false); if (! $mixin) { $this->throwError("Undefined mixin $name"); @@ -1799,7 +1813,7 @@ class Compiler if (isset($content)) { $content->scope = $callingScope; - $this->setRaw(self::$namespaces['special'] . 'content', $content, $this->env); + $this->setRaw(static::$namespaces['special'] . 'content', $content, $this->env); } if (isset($mixin->args)) { @@ -1816,11 +1830,13 @@ class Compiler break; case Type::T_MIXIN_CONTENT: - $content = $this->get(self::$namespaces['special'] . 'content', false, $this->getStoreEnv()) - ?: $this->get(self::$namespaces['special'] . 'content', false, $this->env); + $content = $this->get(static::$namespaces['special'] . 'content', false, $this->getStoreEnv()) + ?: $this->get(static::$namespaces['special'] . 'content', false, $this->env); if (! $content) { - $this->throwError('Expected @content inside of mixin'); + $content = new \stdClass(); + $content->scope = new \stdClass(); + $content->children = $this->storeEnv->parent->block->children; break; } @@ -1902,7 +1918,7 @@ class Compiler */ protected function isTruthy($value) { - return $value !== self::$false && $value !== self::$null; + return $value !== static::$false && $value !== static::$null; } /** @@ -1957,7 +1973,7 @@ class Compiler case Type::T_EXPRESSION: list(, $op, $left, $right, $inParens) = $value; - $opName = isset(self::$operatorNames[$op]) ? self::$operatorNames[$op] : $op; + $opName = isset(static::$operatorNames[$op]) ? static::$operatorNames[$op] : $op; $inExp = $inExp || $this->shouldEval($left) || $this->shouldEval($right); $left = $this->reduce($left, true); @@ -2073,11 +2089,11 @@ class Compiler if ($op === 'not') { if ($inExp || $inParens) { - if ($exp === self::$false || $exp === self::$null) { - return self::$true; + if ($exp === static::$false || $exp === static::$null) { + return static::$true; } - return self::$false; + return static::$false; } $op = $op . ' '; @@ -2331,7 +2347,7 @@ class Compiler return; } - if ($left !== self::$false and $left !== self::$null) { + if ($left !== static::$false and $left !== static::$null) { return $this->reduce($right, true); } @@ -2353,7 +2369,7 @@ class Compiler return; } - if ($left !== self::$false and $left !== self::$null) { + if ($left !== static::$false and $left !== static::$null) { return $left; } @@ -2584,7 +2600,7 @@ class Compiler */ public function toBool($thing) { - return $thing ? self::$true : self::$false; + return $thing ? static::$true : static::$false; } /** @@ -2710,6 +2726,39 @@ class Compiler $reduced = $this->reduce($exp); switch ($reduced[0]) { + case Type::T_LIST: + $reduced = $this->extractInterpolation($reduced); + + if ($reduced[0] !== Type::T_LIST) { + break; + } + + list(, $delim, $items) = $reduced; + + if ($delim !== ' ') { + $delim .= ' '; + } + + $filtered = []; + + foreach ($items as $item) { + if ($item[0] === Type::T_NULL) { + continue; + } + + $temp = $this->compileValue([Type::T_KEYWORD, $item]); + if ($temp[0] === Type::T_STRING) { + $filtered[] = $this->compileStringContent($temp); + } elseif ($temp[0] === Type::T_KEYWORD) { + $filtered[] = $temp[1]; + } else { + $filtered[] = $this->compileValue($temp); + } + } + + $reduced = [Type::T_KEYWORD, implode("$delim", $filtered)]; + break; + case Type::T_STRING: $reduced = [Type::T_KEYWORD, $this->compileStringContent($reduced)]; break; @@ -2834,7 +2883,7 @@ class Compiler $newPart = []; foreach ($part as $p) { - if ($p === self::$selfSelector) { + if ($p === static::$selfSelector) { $setSelf = true; foreach ($parent as $i => $parentPart) { @@ -3053,7 +3102,7 @@ class Compiler public function get($name, $shouldThrow = true, Environment $env = null) { $normalizedName = $this->normalizeName($name); - $specialContentKey = self::$namespaces['special'] . 'content'; + $specialContentKey = static::$namespaces['special'] . 'content'; if (! isset($env)) { $env = $this->getStoreEnv(); @@ -3061,13 +3110,14 @@ class Compiler $nextIsRoot = false; $hasNamespace = $normalizedName[0] === '^' || $normalizedName[0] === '@' || $normalizedName[0] === '%'; + for (;;) { if (array_key_exists($normalizedName, $env->store)) { return $env->store[$normalizedName]; } if (! $hasNamespace && isset($env->marker)) { - if (! $nextIsRoot && !empty($env->store[$specialContentKey])) { + if (! $nextIsRoot && ! empty($env->store[$specialContentKey])) { $env = $env->store[$specialContentKey]->scope; $nextIsRoot = true; continue; @@ -3340,6 +3390,8 @@ class Compiler $urls = [$url, preg_replace('/[^\/]+$/', '_\0', $url)]; } + $hasExtension = preg_match('/[.]s?css$/', $url); + foreach ($this->importPaths as $dir) { if (is_string($dir)) { // check urls for normal import paths @@ -3349,7 +3401,7 @@ class Compiler . $full; if ($this->fileExists($file = $full . '.scss') || - $this->fileExists($file = $full) + ($hasExtension && $this->fileExists($file = $full)) ) { return $file; } @@ -3446,7 +3498,7 @@ class Compiler */ protected function fileExists($name) { - return is_file($name); + return file_exists($name) && is_file($name); } /** @@ -3460,7 +3512,7 @@ class Compiler */ protected function callScssFunction($name, $argValues, &$returnValue) { - $func = $this->get(self::$namespaces['function'] . $name, false); + $func = $this->get(static::$namespaces['function'] . $name, false); if (! $func) { return false; @@ -3489,7 +3541,7 @@ class Compiler $this->popEnv(); - $returnValue = ! isset($ret) ? self::$defaultValue : $ret; + $returnValue = ! isset($ret) ? static::$defaultValue : $ret; return true; } @@ -3513,7 +3565,7 @@ class Compiler list($f, $prototype) = $this->userFunctions[$name]; } elseif (($f = $this->getBuiltinFunction($name)) && is_callable($f)) { $libName = $f[1]; - $prototype = isset(self::$$libName) ? self::$$libName : null; + $prototype = isset(static::$$libName) ? static::$$libName : null; } else { return false; } @@ -3738,7 +3790,7 @@ class Compiler } if ($value === null) { - return self::$null; + return static::$null; } if (is_numeric($value)) { @@ -3746,7 +3798,7 @@ class Compiler } if ($value === '') { - return self::$emptyString; + return static::$emptyString; } if (preg_match('/^(#([0-9a-f]{6})|#([0-9a-f]{3}))$/i', $value, $m)) { @@ -3788,11 +3840,11 @@ class Compiler return $item; } - if ($item === self::$emptyList) { - return self::$emptyMap; + if ($item === static::$emptyList) { + return static::$emptyMap; } - return [Type::T_MAP, [$item], [self::$null]]; + return [Type::T_MAP, [$item], [static::$null]]; } /** @@ -4162,7 +4214,7 @@ class Compiler list($list, $value) = $args; if ($value[0] === Type::T_MAP) { - return self::$null; + return static::$null; } if ($list[0] === Type::T_MAP || @@ -4174,7 +4226,7 @@ class Compiler } if ($list[0] !== Type::T_LIST) { - return self::$null; + return static::$null; } $values = []; @@ -4185,7 +4237,7 @@ class Compiler $key = array_search($this->normalizeValue($value), $values); - return false === $key ? self::$null : $key + 1; + return false === $key ? static::$null : $key + 1; } protected static $libRgb = ['red', 'green', 'blue']; @@ -4755,7 +4807,7 @@ class Compiler $n += count($list[2]); } - return isset($list[2][$n]) ? $list[2][$n] : self::$defaultValue; + return isset($list[2][$n]) ? $list[2][$n] : static::$defaultValue; } protected static $libSetNth = ['list', 'n', 'value']; @@ -4793,7 +4845,7 @@ class Compiler } } - return self::$null; + return static::$null; } protected static $libMapKeys = ['map']; @@ -4944,7 +4996,7 @@ class Compiler switch ($value[0]) { case Type::T_KEYWORD: - if ($value === self::$true || $value === self::$false) { + if ($value === static::$true || $value === static::$false) { return 'bool'; } @@ -5017,7 +5069,7 @@ class Compiler $result = strpos($stringContent, $substringContent); - return $result === false ? self::$null : new Node\Number($result + 1, ''); + return $result === false ? static::$null : new Node\Number($result + 1, ''); } protected static $libStrInsert = ['string', 'insert', 'index']; @@ -5049,7 +5101,7 @@ class Compiler protected function libStrSlice($args) { if (isset($args[2]) && $args[2][1] == 0) { - return self::$nullString; + return static::$nullString; } $string = $this->coerceString($args[0]); @@ -5111,7 +5163,7 @@ class Compiler $name = $this->compileStringContent($string); // user defined functions - if ($this->has(self::$namespaces['function'] . $name)) { + if ($this->has(static::$namespaces['function'] . $name)) { return true; } @@ -5142,7 +5194,7 @@ class Compiler $string = $this->coerceString($args[0]); $name = $this->compileStringContent($string); - return $this->has(self::$namespaces['mixin'] . $name); + return $this->has(static::$namespaces['mixin'] . $name); } protected static $libVariableExists = ['name']; @@ -5200,7 +5252,7 @@ class Compiler protected static $libInspect = ['value']; protected function libInspect($args) { - if ($args[0] === self::$null) { + if ($args[0] === static::$null) { return [Type::T_KEYWORD, 'null']; } diff --git a/lib/scssphp/Compiler/Environment.php b/lib/scssphp/Compiler/Environment.php index d44bff765a5..b4b86e32db6 100644 --- a/lib/scssphp/Compiler/Environment.php +++ b/lib/scssphp/Compiler/Environment.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Exception/CompilerException.php b/lib/scssphp/Exception/CompilerException.php index 777e40ac5d2..45fc16713c9 100644 --- a/lib/scssphp/Exception/CompilerException.php +++ b/lib/scssphp/Exception/CompilerException.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Exception/ParserException.php b/lib/scssphp/Exception/ParserException.php index fbe6388f502..c0ee002d62e 100644 --- a/lib/scssphp/Exception/ParserException.php +++ b/lib/scssphp/Exception/ParserException.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Exception/RangeException.php b/lib/scssphp/Exception/RangeException.php new file mode 100644 index 00000000000..47192ff5f2c --- /dev/null +++ b/lib/scssphp/Exception/RangeException.php @@ -0,0 +1,21 @@ + + */ +class RangeException extends \Exception +{ +} diff --git a/lib/scssphp/Exception/ServerException.php b/lib/scssphp/Exception/ServerException.php index 5a878d2fb89..68d3a290060 100644 --- a/lib/scssphp/Exception/ServerException.php +++ b/lib/scssphp/Exception/ServerException.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Formatter.php b/lib/scssphp/Formatter.php index 2770bb2daa0..0d2635f1e55 100644 --- a/lib/scssphp/Formatter.php +++ b/lib/scssphp/Formatter.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Formatter/Compact.php b/lib/scssphp/Formatter/Compact.php index 94abe329504..aaf972b7409 100644 --- a/lib/scssphp/Formatter/Compact.php +++ b/lib/scssphp/Formatter/Compact.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Formatter/Compressed.php b/lib/scssphp/Formatter/Compressed.php index df7bc75fb38..17aca54a5e6 100644 --- a/lib/scssphp/Formatter/Compressed.php +++ b/lib/scssphp/Formatter/Compressed.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Formatter/Crunched.php b/lib/scssphp/Formatter/Crunched.php index ccba1333bf6..0a89bc48c1a 100644 --- a/lib/scssphp/Formatter/Crunched.php +++ b/lib/scssphp/Formatter/Crunched.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Formatter/Debug.php b/lib/scssphp/Formatter/Debug.php index 855742e7b0d..321c5368040 100644 --- a/lib/scssphp/Formatter/Debug.php +++ b/lib/scssphp/Formatter/Debug.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Formatter/Expanded.php b/lib/scssphp/Formatter/Expanded.php index 54db742ffdb..dff17e6b0ed 100644 --- a/lib/scssphp/Formatter/Expanded.php +++ b/lib/scssphp/Formatter/Expanded.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Formatter/Nested.php b/lib/scssphp/Formatter/Nested.php index 9fdb4dd0ab6..c4ff803c71d 100644 --- a/lib/scssphp/Formatter/Nested.php +++ b/lib/scssphp/Formatter/Nested.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Formatter/OutputBlock.php b/lib/scssphp/Formatter/OutputBlock.php index bb8d99b4e87..88e864023a7 100644 --- a/lib/scssphp/Formatter/OutputBlock.php +++ b/lib/scssphp/Formatter/OutputBlock.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Node.php b/lib/scssphp/Node.php index e6ed178ca22..eb543c73263 100644 --- a/lib/scssphp/Node.php +++ b/lib/scssphp/Node.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Node/Number.php b/lib/scssphp/Node/Number.php index a803a6cabab..d4f406faf06 100644 --- a/lib/scssphp/Node/Number.php +++ b/lib/scssphp/Node/Number.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * @@ -110,7 +110,7 @@ class Number extends Node implements \ArrayAccess $dimension = $this->dimension; - foreach (self::$unitTable['in'] as $unit => $conv) { + foreach (static::$unitTable['in'] as $unit => $conv) { $from = isset($this->units[$unit]) ? $this->units[$unit] : 0; $to = isset($units[$unit]) ? $units[$unit] : 0; $factor = pow($conv, $from - $to); @@ -265,7 +265,7 @@ class Number extends Node implements \ArrayAccess */ public function output(Compiler $compiler = null) { - $dimension = round($this->dimension, self::$precision); + $dimension = round($this->dimension, static::$precision); $units = array_filter($this->units, function ($unitSize) { return $unitSize; @@ -277,7 +277,7 @@ class Number extends Node implements \ArrayAccess $this->normalizeUnits($dimension, $units, 'in'); - $dimension = round($dimension, self::$precision); + $dimension = round($dimension, static::$precision); $units = array_filter($units, function ($unitSize) { return $unitSize; }); @@ -316,8 +316,8 @@ class Number extends Node implements \ArrayAccess $units = []; foreach ($this->units as $unit => $exp) { - if (isset(self::$unitTable[$baseUnit][$unit])) { - $factor = pow(self::$unitTable[$baseUnit][$unit], $exp); + if (isset(static::$unitTable[$baseUnit][$unit])) { + $factor = pow(static::$unitTable[$baseUnit][$unit], $exp); $unit = $baseUnit; $dimension /= $factor; diff --git a/lib/scssphp/Parser.php b/lib/scssphp/Parser.php index ed0621eae1b..619b7ba83d5 100644 --- a/lib/scssphp/Parser.php +++ b/lib/scssphp/Parser.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * @@ -83,17 +83,17 @@ class Parser $this->utf8 = ! $encoding || strtolower($encoding) === 'utf-8'; $this->patternModifiers = $this->utf8 ? 'Aisu' : 'Ais'; - if (empty(self::$operatorPattern)) { - self::$operatorPattern = '([*\/%+-]|[!=]\=|\>\=?|\<\=\>|\<\=?|and|or)'; + if (empty(static::$operatorPattern)) { + static::$operatorPattern = '([*\/%+-]|[!=]\=|\>\=?|\<\=\>|\<\=?|and|or)'; $commentSingle = '\/\/'; $commentMultiLeft = '\/\*'; $commentMultiRight = '\*\/'; - self::$commentPattern = $commentMultiLeft . '.*?' . $commentMultiRight; - self::$whitePattern = $this->utf8 - ? '/' . $commentSingle . '[^\n]*\s*|(' . self::$commentPattern . ')\s*|\s+/AisuS' - : '/' . $commentSingle . '[^\n]*\s*|(' . self::$commentPattern . ')\s*|\s+/AisS'; + static::$commentPattern = $commentMultiLeft . '.*?' . $commentMultiRight; + static::$whitePattern = $this->utf8 + ? '/' . $commentSingle . '[^\n]*\s*|(' . static::$commentPattern . ')\s*|\s+/AisuS' + : '/' . $commentSingle . '[^\n]*\s*|(' . static::$commentPattern . ')\s*|\s+/AisS'; } } @@ -563,9 +563,9 @@ class Parser list($line, $column) = $this->getSourcePosition($s); - $statement[self::SOURCE_LINE] = $line; - $statement[self::SOURCE_COLUMN] = $column; - $statement[self::SOURCE_INDEX] = $this->sourceIndex; + $statement[static::SOURCE_LINE] = $line; + $statement[static::SOURCE_COLUMN] = $column; + $statement[static::SOURCE_INDEX] = $this->sourceIndex; $this->charset = $statement; } @@ -922,7 +922,7 @@ class Parser { $gotWhite = false; - while (preg_match(self::$whitePattern, $this->buffer, $m, null, $this->count)) { + while (preg_match(static::$whitePattern, $this->buffer, $m, null, $this->count)) { if (isset($m[1]) && empty($this->commentsSeen[$this->count])) { $this->appendComment([Type::T_COMMENT, $m[1]]); @@ -959,9 +959,9 @@ class Parser if ($pos !== null) { list($line, $column) = $this->getSourcePosition($pos); - $statement[self::SOURCE_LINE] = $line; - $statement[self::SOURCE_COLUMN] = $column; - $statement[self::SOURCE_INDEX] = $this->sourceIndex; + $statement[static::SOURCE_LINE] = $line; + $statement[static::SOURCE_COLUMN] = $column; + $statement[static::SOURCE_INDEX] = $this->sourceIndex; } $this->env->children[] = $statement; @@ -1249,13 +1249,13 @@ class Parser */ protected function expHelper($lhs, $minP) { - $operators = self::$operatorPattern; + $operators = static::$operatorPattern; $ss = $this->seek(); $whiteBefore = isset($this->buffer[$this->count - 1]) && ctype_space($this->buffer[$this->count - 1]); - while ($this->match($operators, $m, false) && self::$precedence[$m[1]] >= $minP) { + while ($this->match($operators, $m, false) && static::$precedence[$m[1]] >= $minP) { $whiteAfter = isset($this->buffer[$this->count]) && ctype_space($this->buffer[$this->count]); $varAfter = isset($this->buffer[$this->count]) && @@ -1275,8 +1275,8 @@ class Parser } // peek and see if rhs belongs to next operator - if ($this->peek($operators, $next) && self::$precedence[$next[1]] > self::$precedence[$op]) { - $rhs = $this->expHelper($rhs, self::$precedence[$next[1]]); + if ($this->peek($operators, $next) && static::$precedence[$next[1]] > static::$precedence[$op]) { + $rhs = $this->expHelper($rhs, static::$precedence[$next[1]]); } $lhs = [Type::T_EXPRESSION, $op, $lhs, $rhs, $this->inParens, $whiteBefore, $whiteAfter]; @@ -1812,7 +1812,7 @@ class Parser $oldWhite = $this->eatWhiteDefault; $this->eatWhiteDefault = false; - $patt = '(.*?)([\'"]|#\{|' . $this->pregQuote($end) . '|' . self::$commentPattern . ')'; + $patt = '(.*?)([\'"]|#\{|' . $this->pregQuote($end) . '|' . static::$commentPattern . ')'; $nestingLevel = 0; @@ -1946,7 +1946,7 @@ class Parser // match comment hack if (preg_match( - self::$whitePattern, + static::$whitePattern, $this->buffer, $m, null, diff --git a/lib/scssphp/Server.php b/lib/scssphp/Server.php index 221655cad8c..e4caddb45de 100644 --- a/lib/scssphp/Server.php +++ b/lib/scssphp/Server.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * @@ -457,7 +457,7 @@ class Server */ public static function serveFrom($path) { - $server = new self($path); + $server = new static($path); $server->serve(); } } diff --git a/lib/scssphp/Type.php b/lib/scssphp/Type.php index 8c3886c82d5..2d659e4d592 100644 --- a/lib/scssphp/Type.php +++ b/lib/scssphp/Type.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * diff --git a/lib/scssphp/Util.php b/lib/scssphp/Util.php index 9f47c1d7976..b2a05db8130 100644 --- a/lib/scssphp/Util.php +++ b/lib/scssphp/Util.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * @@ -12,6 +12,7 @@ namespace Leafo\ScssPhp; use Leafo\ScssPhp\Base\Range; +use Leafo\ScssPhp\Exception\RangeException; /** * Utilties @@ -31,7 +32,7 @@ class Util * * @return mixed `value` adjusted to fall within range, if it was outside by a floating-point margin. * - * @throws \Exception + * @throws \Leafo\ScssPhp\Exception\RangeException */ public static function checkRange($name, Range $range, $value, $unit = '') { @@ -50,6 +51,6 @@ class Util return $range->last; } - throw new \Exception("$name {$val} must be between {$range->first} and {$range->last}$unit"); + throw new RangeException("$name {$val} must be between {$range->first} and {$range->last}$unit"); } } diff --git a/lib/scssphp/Version.php b/lib/scssphp/Version.php index 3be9cc31053..2d6eabc14ac 100644 --- a/lib/scssphp/Version.php +++ b/lib/scssphp/Version.php @@ -2,7 +2,7 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2017 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * @@ -18,5 +18,5 @@ namespace Leafo\ScssPhp; */ class Version { - const VERSION = 'v0.6.5'; + const VERSION = 'v0.6.7'; } diff --git a/lib/scssphp/moodle_readme.txt b/lib/scssphp/moodle_readme.txt index 711d80cd7c8..44fd815da84 100644 --- a/lib/scssphp/moodle_readme.txt +++ b/lib/scssphp/moodle_readme.txt @@ -1,11 +1,7 @@ scssphp ------- -Import git ref: 62536ec1b32b63499684a91d67e8b6d90508bad2 - (MOODLE_32_STABLE) - -Downloaded from: https://github.com/moodlehq/scssphp - Original at: https://github.com/leafo/scssphp +Downloaded from: https://github.com/leafo/scssphp Import procedure: diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml index 71400eaf826..faf7cd9b0c1 100644 --- a/lib/thirdpartylibs.xml +++ b/lib/thirdpartylibs.xml @@ -257,7 +257,7 @@ scssphp scssphp MIT - 0.6.5 + 0.6.7 spout