Changeset 115301 in spip-zone
- Timestamp:
- May 10, 2019, 8:03:27 AM (2 years ago)
- Location:
- _plugins_/scssphp/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/scssphp/trunk/lib/scssphp/src/Block.php
r115043 r115301 63 63 */ 64 64 public $children; 65 65 66 /** 66 67 * @var \Leafo\ScssPhp\Block -
_plugins_/scssphp/trunk/lib/scssphp/src/Compiler.php
r115183 r115301 150 150 151 151 protected $indentLevel; 152 protected $commentsSeen;153 152 protected $extends; 154 153 protected $extendsMap; … … 227 226 228 227 $this->indentLevel = -1; 229 $this->commentsSeen = [];230 228 $this->extends = []; 231 229 $this->extendsMap = []; … … 484 482 485 483 /** 484 * Glue parts of :not( or :nth-child( ... that are in general splitted in selectors parts 485 * 486 * @param array $parts 487 * 488 * @return array 489 */ 490 protected function glueFunctionSelectors($parts) 491 { 492 $new = []; 493 foreach ($parts as $part) { 494 if (is_array($part)) { 495 $part = $this->glueFunctionSelectors($part); 496 $new[] = $part; 497 } else { 498 // a selector part finishing with a ) is the last part of a :not( or :nth-child( 499 // and need to be joined to this 500 if (count($new) && is_string($new[count($new) - 1]) 501 && strlen($part) && substr($part, -1) === ')' && strpos($part, '(') === false 502 ) { 503 $new[count($new) - 1] .= $part; 504 } else { 505 $new[] = $part; 506 } 507 } 508 } 509 return $new; 510 } 511 512 /** 486 513 * Match extends 487 514 * … … 493 520 protected function matchExtends($selector, &$out, $from = 0, $initial = true) 494 521 { 522 $selector = $this->glueFunctionSelectors($selector); 523 495 524 foreach ($selector as $i => $part) { 496 525 if ($i < $from) { … … 519 548 for ($l = count($tempReplacement) - 1; $l >= 0; $l--) { 520 549 $slice = []; 550 521 551 foreach ($tempReplacement[$l] as $chunk) { 522 552 if (!in_array($chunk, $slice)) { … … 524 554 } 525 555 } 556 526 557 array_unshift($replacement, $slice); 527 558 … … 622 653 foreach ($counts as $idx => $count) { 623 654 list($target, $origin, /* $block */) = $this->extends[$idx]; 655 $origin = $this->glueFunctionSelectors($origin); 624 656 625 657 // check count … … 663 695 } 664 696 665 666 697 /** 667 698 * Extract a relationship from the fragment. … … 673 704 * 674 705 * @param array $fragment The selector fragment maybe ending with a direction relationship combinator. 706 * 675 707 * @return array The selector without the relationship fragment if any, the relationship fragment. 676 708 */ … … 857 889 858 890 $selfParent = $block->selfParent; 859 if (! $block->selfParent->selectors && isset($block->parent) && $block->parent && isset($block->parent->selectors) && $block->parent->selectors) { 891 892 if (! $block->selfParent->selectors && isset($block->parent) && $block->parent && 893 isset($block->parent->selectors) && $block->parent->selectors 894 ) { 860 895 $selfParent = $block->parent; 861 896 } … … 878 913 /** 879 914 * Filter at-root scope depending of with/without option 880 * @param $scope 881 * @param $without 915 * 916 * @param \Leafo\ScssPhp\Formatter\OutputBlock $scope 917 * @param mixed $without 918 * 882 919 * @return mixed 883 920 */ … … 899 936 break; 900 937 } 938 901 939 if (! $this->isWithout($without, $scope)) { 902 940 $s = clone $scope; … … 904 942 $s->lines = []; 905 943 $s->parent = null; 944 906 945 if ($s->type !== Type::T_MEDIA && $s->type !== Type::T_DIRECTIVE) { 907 946 $s->selectors = []; 908 947 } 948 909 949 $filteredScopes[] = $s; 910 950 } … … 916 956 } 917 957 } 958 918 959 if (!count($filteredScopes)) { 919 960 return $this->rootBlock; … … 922 963 $newScope = array_shift($filteredScopes); 923 964 $newScope->parent = $this->rootBlock; 965 924 966 $this->rootBlock->children[] = $newScope; 925 967 926 968 $p = &$newScope; 969 927 970 while (count($filteredScopes)) { 928 971 $s = array_shift($filteredScopes); … … 938 981 * found missing selector from a at-root compilation in the previous scope 939 982 * (if at-root is just enclosing a property, the selector is in the parent tree) 940 * @param $scope 941 * @param $previousScope 983 * 984 * @param \Leafo\ScssPhp\Formatter\OutputBlock $scope 985 * @param \Leafo\ScssPhp\Formatter\OutputBlock $previousScope 986 * 942 987 * @return mixed 943 988 */ … … 947 992 $scope->selectors = $this->findScopeSelectors($previousScope, $scope->depth); 948 993 } 994 949 995 if ($scope->children) { 950 996 foreach ($scope->children as $k => $c) { … … 958 1004 /** 959 1005 * Find a selector by the depth node in the scope 960 * @param $scope 961 * @param $depth 1006 * 1007 * @param \Leafo\ScssPhp\Formatter\OutputBlock $scope 1008 * @param integer $depth 1009 * 962 1010 * @return array 963 1011 */ … … 967 1015 return $scope->selectors; 968 1016 } 1017 969 1018 if ($scope->children) { 970 1019 foreach (array_reverse($scope->children) as $c) { … … 974 1023 } 975 1024 } 1025 976 1026 return []; 977 1027 } … … 1053 1103 * Filter WITH rules 1054 1104 * 1055 * @param integer $without1105 * @param integer $without 1056 1106 * @param \Leafo\ScssPhp\Block|\Leafo\ScssPhp\Formatter\OutputBlock $block 1057 1107 * … … 1069 1119 return ($without & static::WITH_SUPPORTS) ? true : false; 1070 1120 } 1121 1071 1122 if (isset($block->selectors) && strpos(serialize($block->selectors), '@supports') !== false) { 1072 1123 return ($without & static::WITH_SUPPORTS) ? true : false; … … 1074 1125 } 1075 1126 } 1127 1076 1128 if ((($without & static::WITH_RULE) && isset($block->selectors))) { 1077 1129 return true; … … 1123 1175 1124 1176 // wrap assign children in a block 1125 foreach ($block->children as $k => $child) { 1126 if ($child[0] === Type::T_ASSIGN) { 1177 // except for @font-face 1178 if ($block->type !== Type::T_DIRECTIVE || $block->name !== "font-face") { 1179 // need wrapping? 1180 $needWrapping = false; 1181 1182 foreach ($block->children as $child) { 1183 if ($child[0] === Type::T_ASSIGN) { 1184 $needWrapping = true; 1185 break; 1186 } 1187 } 1188 1189 if ($needWrapping) { 1127 1190 $wrapped = new Block; 1128 $wrapped->sourceName 1129 $wrapped->sourceIndex 1130 $wrapped->sourceLine 1191 $wrapped->sourceName = $block->sourceName; 1192 $wrapped->sourceIndex = $block->sourceIndex; 1193 $wrapped->sourceLine = $block->sourceLine; 1131 1194 $wrapped->sourceColumn = $block->sourceColumn; 1132 $wrapped->selectors 1133 $wrapped->comments 1134 $wrapped->parent 1135 $wrapped->children = [$child];1136 $wrapped->selfParent 1137 1138 $block->children [$k] = [Type::T_BLOCK, $wrapped];1195 $wrapped->selectors = []; 1196 $wrapped->comments = []; 1197 $wrapped->parent = $block; 1198 $wrapped->children = $block->children; 1199 $wrapped->selfParent = $block->selfParent; 1200 1201 $block->children = [[Type::T_BLOCK, $wrapped]]; 1139 1202 } 1140 1203 } … … 1200 1263 if (count($block->children)) { 1201 1264 $out->selectors = $this->multiplySelectors($env, $block->selfParent); 1265 1202 1266 // propagate selfParent to the children where they still can be useful 1203 1267 $selfParentSelectors = null; 1268 1204 1269 if (isset($block->selfParent->selectors)) { 1205 1270 $selfParentSelectors = $block->selfParent->selectors; 1206 1271 $block->selfParent->selectors = $out->selectors; 1207 1272 } 1273 1208 1274 $this->compileChildrenNoReturn($block->children, $out, $block->selfParent); 1275 1209 1276 // and revert for the following childs of the same block 1210 1277 if ($selfParentSelectors) { … … 1227 1294 $out = $this->makeOutputBlock(Type::T_COMMENT); 1228 1295 $out->lines[] = $block[1]; 1296 1229 1297 $this->scope->children[] = $out; 1230 1298 } … … 1459 1527 } 1460 1528 } 1529 1461 1530 return null; 1462 1531 } … … 1467 1536 * @param array $stms 1468 1537 * @param \Leafo\ScssPhp\Formatter\OutputBlock $out 1469 * @param \Leafo\ScssPhp\Block $selfParent1538 * @param \Leafo\ScssPhp\Block $selfParent 1470 1539 * 1471 1540 * @throws \Exception … … 1473 1542 protected function compileChildrenNoReturn($stms, OutputBlock $out, $selfParent = null) 1474 1543 { 1475 1476 1544 foreach ($stms as $stm) { 1477 if ($selfParent && isset($stm[1]) && is_object($stm[1]) && get_class($stm[1]) == 'Leafo\ScssPhp\Block') {1545 if ($selfParent && isset($stm[1]) && is_object($stm[1]) && $stm[1] instanceof Block) { 1478 1546 $stm[1]->selfParent = $selfParent; 1479 1547 $ret = $this->compileChild($stm, $out); 1480 1548 $stm[1]->selfParent = null; 1481 } 1482 elseif ($selfParent && $stm[0] === TYPE::T_INCLUDE) { 1549 } elseif ($selfParent && $stm[0] === TYPE::T_INCLUDE) { 1483 1550 $stm['selfParent'] = $selfParent; 1484 1551 $ret = $this->compileChild($stm, $out); … … 1494 1561 } 1495 1562 } 1563 } 1564 1565 1566 /** 1567 * evaluate media query : compile internal value keeping the structure inchanged 1568 * 1569 * @param array $queryList 1570 * 1571 * @return array 1572 */ 1573 protected function evaluateMediaQuery($queryList) 1574 { 1575 foreach ($queryList as $kql => $query) { 1576 foreach ($query as $kq => $q) { 1577 for ($i = 1; $i < count($q); $i++) { 1578 $value = $this->compileValue($q[$i]); 1579 1580 // the parser had no mean to know if media type or expression if it was an interpolation 1581 if ($q[0] == Type::T_MEDIA_TYPE && 1582 (strpos($value, '(') !== false || 1583 strpos($value, ')') !== false || 1584 strpos($value, ':') !== false) 1585 ) { 1586 $queryList[$kql][$kq][0] = Type::T_MEDIA_EXPRESSION; 1587 1588 if (strpos($value, 'and') !== false) { 1589 $values = explode('and', $value); 1590 $value = trim(array_pop($values)); 1591 1592 while ($v = trim(array_pop($values))) { 1593 $type = Type::T_MEDIA_EXPRESSION; 1594 1595 if (strpos($v, '(') === false && 1596 strpos($v, ')') === false && 1597 strpos($v, ':') === false 1598 ) { 1599 $type = Type::T_MEDIA_TYPE; 1600 } 1601 1602 if (substr($v, 0, 1) === '(' && substr($v, -1) === ')') { 1603 $v = substr($v, 1, -1); 1604 } 1605 1606 $queryList[$kql][] = [$type,[Type::T_KEYWORD, $v]]; 1607 } 1608 } 1609 1610 if (substr($value, 0, 1) === '(' && substr($value, -1) === ')') { 1611 $value = substr($value, 1, -1); 1612 } 1613 } 1614 1615 $queryList[$kql][$kq][$i] = [Type::T_KEYWORD, $value]; 1616 } 1617 } 1618 } 1619 1620 return $queryList; 1496 1621 } 1497 1622 … … 1568 1693 } 1569 1694 1695 /** 1696 * Merge direct relationships between selectors 1697 * 1698 * @param array $selectors1 1699 * @param array $selectors2 1700 * 1701 * @return array 1702 */ 1570 1703 protected function mergeDirectRelationships($selectors1, $selectors2) 1571 1704 { … … 1668 1801 * Compile import; returns true if the value was something that could be imported 1669 1802 * 1670 * @param array $rawPath1671 * @param array$out1672 * @param boolean $once1803 * @param array $rawPath 1804 * @param \Leafo\ScssPhp\Formatter\OutputBlock $out 1805 * @param boolean $once 1673 1806 * 1674 1807 * @return boolean 1675 1808 */ 1676 protected function compileImport($rawPath, $out, $once = false)1809 protected function compileImport($rawPath, OutputBlock $out, $once = false) 1677 1810 { 1678 1811 if ($rawPath[0] === Type::T_STRING) { … … 1734 1867 $this->sourceLine = $out->sourceLine; 1735 1868 $this->sourceIndex = array_search($out->sourceName, $this->sourceNames); 1869 1736 1870 if ($this->sourceIndex === false) { 1737 1871 $this->sourceIndex = null; … … 1806 1940 1807 1941 // handle shorthand syntax: size / line-height 1808 if ($compiledName === 'font' ) {1942 if ($compiledName === 'font' || $compiledName === 'grid-row' || $compiledName === 'grid-column') { 1809 1943 if ($value[0] === Type::T_VARIABLE) { 1810 // if the font value comes from variable, the content is already reduced (which means formulars where already calculated)1811 // so we need the original unreduced value1944 // if the font value comes from variable, the content is already reduced 1945 // (i.e., formulas were already calculated), so we need the original unreduced value 1812 1946 $value = $this->get($value[1], true, null, true); 1813 1947 } 1814 1948 1815 1949 $fontValue=&$value; 1950 1816 1951 if ($value[0] === Type::T_LIST && $value[1]==',') { 1817 1952 // this is the case if more than one font is given: example: "font: 400 1em/1.3 arial,helvetica" … … 2045 2180 // and assign this fake parent to childs 2046 2181 $selfParent = null; 2182 2047 2183 if (isset($child['selfParent']) && isset($child['selfParent']->selectors)) { 2048 2184 $selfParent = $child['selfParent']; 2049 } 2050 else { 2185 } else { 2051 2186 $parentSelectors = $this->multiplySelectors($this->env); 2187 2052 2188 if ($parentSelectors) { 2053 2189 $parent = new Block(); 2054 2190 $parent->selectors = $parentSelectors; 2191 2055 2192 foreach ($mixin->children as $k => $child) { 2056 if (isset($child[1]) && is_object($child[1]) && get_class($child[1]) == 'Leafo\ScssPhp\Block') {2193 if (isset($child[1]) && is_object($child[1]) && $child[1] instanceof Block) { 2057 2194 $mixin->children[$k][1]->parent = $parent; 2058 2195 } … … 2061 2198 } 2062 2199 2200 // clone the stored content to not have its scope spoiled by a further call to the same mixin 2201 // i.e., recursive @include of the same mixin 2063 2202 if (isset($content)) { 2064 $content->scope = $callingScope; 2065 2066 $this->setRaw(static::$namespaces['special'] . 'content', $content, $this->env); 2203 $copyContent = clone $content; 2204 $copyContent->scope = $callingScope; 2205 2206 $this->setRaw(static::$namespaces['special'] . 'content', $copyContent, $this->env); 2067 2207 } 2068 2208 … … 2095 2235 $storeEnv = $this->storeEnv; 2096 2236 $this->storeEnv = $content->scope; 2097 2098 2237 $this->compileChildrenNoReturn($content->children, $out); 2099 2238 … … 2170 2309 * @param array $value 2171 2310 * 2172 * @return array2311 * @return boolean 2173 2312 */ 2174 2313 protected function isTruthy($value) … … 2397 2536 $selfSelector = $this->multiplySelectors($this->env); 2398 2537 $selfSelector = $this->collapseSelectors($selfSelector); 2538 2399 2539 return [Type::T_STRING, '', [$selfSelector]]; 2400 2540 … … 2585 2725 return $strRight; 2586 2726 } 2727 2587 2728 return null; 2588 2729 } … … 3091 3232 * 3092 3233 * @param \Leafo\ScssPhp\Compiler\Environment $env 3093 * @param Leafo\ScssPhp\Block$selfParent3234 * @param \Leafo\ScssPhp\Block $selfParent 3094 3235 * 3095 3236 * @return array … … 3102 3243 3103 3244 $selfParentSelectors = null; 3245 3104 3246 if (!is_null($selfParent) and $selfParent->selectors) { 3105 3247 $selfParentSelectors = $this->evalSelectors($selfParent->selectors); … … 3117 3259 if ($selfParentSelectors) { 3118 3260 $previous = null; 3261 3119 3262 foreach ($selfParentSelectors as $selfParent) { 3120 3263 // if no '&' in the selector, each call will give same result, only add once 3121 3264 $s = $this->joinSelectors($parent, $selector, $selfParent); 3265 3122 3266 if ($s !== $previous) { 3123 3267 $selectors[serialize($s)] = $s; 3124 3268 } 3269 3125 3270 $previous = $s; 3126 3271 } … … 3136 3281 3137 3282 $selectors = array_values($selectors); 3283 3138 3284 return $selectors; 3139 3285 } … … 3145 3291 * @param array $child 3146 3292 * @param array $selfParentSelectors 3293 3147 3294 * @return array 3148 3295 */ … … 3158 3305 if ($p === static::$selfSelector) { 3159 3306 $setSelf = true; 3307 3160 3308 if (is_null($selfParentSelectors)) { 3161 3309 $selfParentSelectors = $parent; 3162 3310 } 3311 3163 3312 foreach ($selfParentSelectors as $i => $parentPart) { 3164 3313 if ($i > 0) { … … 3214 3363 : [[[Type::T_MEDIA_VALUE, $env->block->value]]]; 3215 3364 3365 $store = [$this->env, $this->storeEnv]; 3366 $this->env = $env; 3367 $this->storeEnv = null; 3368 $parentQueries = $this->evaluateMediaQuery($parentQueries); 3369 list($this->env, $this->storeEnv) = $store; 3370 3216 3371 if ($childQueries === null) { 3217 3372 $childQueries = $parentQueries; … … 3358 3513 3359 3514 $env->store[$name] = $value; 3515 3360 3516 if ($valueUnreduced) { 3361 3517 $env->storeUnreduced[$name] = $valueUnreduced; … … 3374 3530 { 3375 3531 $env->store[$name] = $value; 3532 3376 3533 if ($valueUnreduced) { 3377 3534 $env->storeUnreduced[$name] = $valueUnreduced; … … 3403 3560 $hasNamespace = $normalizedName[0] === '^' || $normalizedName[0] === '@' || $normalizedName[0] === '%'; 3404 3561 3562 $maxDepth = 10000; 3563 3405 3564 for (;;) { 3565 if ($maxDepth-- <= 0) { 3566 break; 3567 } 3406 3568 if (array_key_exists($normalizedName, $env->store)) { 3407 3569 if ($unreduced && isset($env->storeUnreduced[$normalizedName])) { 3408 3570 return $env->storeUnreduced[$normalizedName]; 3409 3571 } 3572 3410 3573 return $env->store[$normalizedName]; 3411 3574 } … … 3429 3592 3430 3593 if ($shouldThrow) { 3431 $this->throwError("Undefined variable \$$name" );3594 $this->throwError("Undefined variable \$$name" . ($maxDepth<=0 ? " (infinite recursion)" : "")); 3432 3595 } 3433 3596 … … 3664 3827 * Import file 3665 3828 * 3666 * @param string $path3667 * @param array$out3668 */ 3669 protected function importFile($path, $out)3829 * @param string $path 3830 * @param \Leafo\ScssPhp\Formatter\OutputBlock $out 3831 */ 3832 protected function importFile($path, OutputBlock $out) 3670 3833 { 3671 3834 // see if tree is cached … … 3765 3928 { 3766 3929 $this->ignoreErrors = $ignoreErrors; 3930 3767 3931 return $this; 3768 3932 } … … 3788 3952 3789 3953 $line = $this->sourceLine; 3790 $loc = isset($this->sourceNames[$this->sourceIndex]) ? $this->sourceNames[$this->sourceIndex] . " on line $line" : "line: $line"; 3954 $loc = isset($this->sourceNames[$this->sourceIndex]) 3955 ? $this->sourceNames[$this->sourceIndex] . " on line $line" 3956 : "line: $line"; 3791 3957 $msg = "$msg: $loc"; 3958 3792 3959 if ($this->callStack) { 3793 3960 $msg .= "\nCall Stack:\n"; 3794 3961 $ncall = 0; 3962 3795 3963 foreach (array_reverse($this->callStack) as $call) { 3796 3964 $msg .= "#" . $ncall++ . " " . $call['n'] . " "; 3797 $msg .= (isset($this->sourceNames[$call[Parser::SOURCE_INDEX]]) ? $this->sourceNames[$call[Parser::SOURCE_INDEX]] : '(unknown file)'); 3965 $msg .= (isset($this->sourceNames[$call[Parser::SOURCE_INDEX]]) 3966 ? $this->sourceNames[$call[Parser::SOURCE_INDEX]] 3967 : '(unknown file)'); 3798 3968 $msg .= " on line " . $call[Parser::SOURCE_LINE] . "\n"; 3799 3969 } -
_plugins_/scssphp/trunk/lib/scssphp/src/Parser.php
r115183 r115301 68 68 private $encoding; 69 69 private $patternModifiers; 70 private $commentsSeen; 70 71 71 72 /** … … 86 87 $this->utf8 = ! $encoding || strtolower($encoding) === 'utf-8'; 87 88 $this->patternModifiers = $this->utf8 ? 'Aisu' : 'Ais'; 89 $this->commentsSeen = []; 88 90 89 91 if (empty(static::$operatorPattern)) { … … 442 444 443 445 $this->seek($s); 444 445 446 446 447 if ($this->literal('@return', 7) && ($this->valueList($retVal) || true) && $this->end()) { … … 794 795 795 796 $this->env = $block->parent; 797 796 798 unset($block->parent); 797 799 798 800 $comments = $block->comments; 801 799 802 if ($comments) { 800 803 $this->env->comments = $comments; … … 830 833 * 831 834 * @param integer $where 832 *833 * @return integer834 835 */ 835 836 protected function seek($where) … … 890 891 protected function match($regex, &$out, $eatWhitespace = null) 891 892 { 892 893 893 $r = '/' . $regex . '/' . $this->patternModifiers; 894 894 … … 910 910 } 911 911 912 913 912 /** 914 913 * Match a single string … … 921 920 protected function matchChar($char, $eatWhitespace = null) 922 921 { 923 924 922 if (! isset($this->buffer[$this->count]) || $this->buffer[$this->count] !== $char) { 925 923 return false; … … 937 935 return true; 938 936 } 939 940 937 941 938 /** … … 966 963 return true; 967 964 } 968 969 965 970 966 /** … … 1193 1189 * Parse comma separated value list 1194 1190 * 1195 * @param string$out1191 * @param array $out 1196 1192 * 1197 1193 * @return boolean … … 1229 1225 $items = []; 1230 1226 $value = null; 1227 1231 1228 while ($this->$parseItem($value)) { 1232 1229 $items[] = $value; … … 1266 1263 1267 1264 if ($this->matchChar('(')) { 1268 if ($this->matchChar(')')) { 1269 $out = [Type::T_LIST, '', []]; 1270 1271 return true; 1272 } 1273 1274 if ($this->valueList($out) && $this->matchChar(')') && $out[0] === Type::T_LIST) { 1275 return true; 1276 } 1277 1278 $this->seek($s); 1279 1280 if ($this->map($out)) { 1265 if ($this->parenExpression($out, $s, ")")) { 1266 return true; 1267 } 1268 1269 $this->seek($s); 1270 } 1271 1272 if ($this->matchChar('[')) { 1273 if ($this->parenExpression($out, $s, "]")) { 1281 1274 return true; 1282 1275 } … … 1288 1281 $out = $this->expHelper($lhs, 0); 1289 1282 1283 return true; 1284 } 1285 1286 return false; 1287 } 1288 1289 /** 1290 * Parse expression specifically checking for lists in parenthesis or brackets 1291 * 1292 * @param array $out 1293 * @param integer $s 1294 * @param string $closingParen 1295 * 1296 * @return boolean 1297 */ 1298 protected function parenExpression(&$out, $s, $closingParen = ")") 1299 { 1300 if ($this->matchChar($closingParen)) { 1301 $out = [Type::T_LIST, '', []]; 1302 1303 return true; 1304 } 1305 1306 if ($this->valueList($out) && $this->matchChar($closingParen) && $out[0] === Type::T_LIST) { 1307 return true; 1308 } 1309 1310 $this->seek($s); 1311 1312 if ($this->map($out)) { 1290 1313 return true; 1291 1314 } … … 1354 1377 protected function value(&$out) 1355 1378 { 1356 1357 1379 if (! isset($this->buffer[$this->count])) { 1358 1380 return false; … … 1381 1403 if ($this->whitespace() && $this->value($inner)) { 1382 1404 $out = [Type::T_UNARY, 'not', $inner, $this->inParens]; 1405 1383 1406 return true; 1384 1407 } … … 1388 1411 if ($this->parenValue($inner)) { 1389 1412 $out = [Type::T_UNARY, 'not', $inner, $this->inParens]; 1413 1390 1414 return true; 1391 1415 } … … 1397 1421 if ($char === '+') { 1398 1422 $this->count++; 1423 1399 1424 if ($this->value($inner)) { 1400 1425 $out = [Type::T_UNARY, '+', $inner, $this->inParens]; 1401 1426 return true; 1402 1427 } 1428 1403 1429 $this->count--; 1430 1404 1431 return false; 1405 1432 } 1406 1407 1433 1408 1434 // negation 1409 1435 if ($char === '-') { 1410 1436 $this->count++; 1437 1411 1438 if ($this->variable($inner) || $this->unit($inner) || $this->parenValue($inner)) { 1412 1439 $out = [Type::T_UNARY, '-', $inner, $this->inParens]; … … 1443 1470 return true; 1444 1471 } 1445 1446 1472 1447 1473 if ($this->unit($out)) { … … 1539 1565 * 1540 1566 * @param string $name 1541 * @param array $out1567 * @param array $func 1542 1568 * 1543 1569 * @return boolean … … 1790 1816 * Parse number with unit 1791 1817 * 1792 * @param array $ out1818 * @param array $unit 1793 1819 * 1794 1820 * @return boolean … … 2219 2245 } 2220 2246 2221 2222 2247 //self 2223 2248 switch ($char) { … … 2236 2261 } 2237 2262 2238 2239 2263 if ($char === '\\' && $this->match('\\\\\S', $m)) { 2240 2264 $parts[] = $m[0]; … … 2242 2266 } 2243 2267 2244 2245 2268 if ($char === '%') { 2246 2269 $this->count++; 2270 2247 2271 if ($this->placeholder($placeholder)) { 2248 2272 $parts[] = '%'; … … 2250 2274 continue; 2251 2275 } 2276 2252 2277 break; 2253 2278 } … … 2263 2288 continue; 2264 2289 } 2265 2266 2290 2267 2291 // a pseudo selector … … 2274 2298 $part = ':'; 2275 2299 } 2300 2276 2301 if ($this->mixedKeyword($nameParts)) { 2277 2302 $parts[] = $part; … … 2302 2327 } 2303 2328 2304 2305 $this->seek($s); 2306 2329 $this->seek($s); 2307 2330 2308 2331 // attribute selector … … 2325 2348 $this->seek($s); 2326 2349 2327 2328 2350 // for keyframes 2329 2351 if ($this->unit($unit)) { … … 2336 2358 continue; 2337 2359 } 2338 2339 2340 2341 2360 2342 2361 break; … … 2611 2630 * @param integer $pos 2612 2631 * 2613 * @return integer2632 * @return array 2614 2633 */ 2615 2634 private function getSourcePosition($pos) -
_plugins_/scssphp/trunk/lib/scssphp/src/SourceMap/SourceMapGenerator.php
r115044 r115301 86 86 */ 87 87 protected $sources = []; 88 protected $source _keys = [];88 protected $sourceKeys = []; 89 89 90 90 /** … … 111 111 { 112 112 $this->mappings[] = [ 113 'generated_line' => $generatedLine,113 'generated_line' => $generatedLine, 114 114 'generated_column' => $generatedColumn, 115 'original_line' => $originalLine,116 'original_column' => $originalColumn,117 'source_file' => $sourceFile115 'original_line' => $originalLine, 116 'original_column' => $originalColumn, 117 'source_file' => $sourceFile 118 118 ]; 119 119 … … 124 124 * Saves the source map to a file 125 125 * 126 * @param string $file The absolute path to a file127 126 * @param string $content The content to write 127 * 128 * @return string 128 129 * 129 130 * @throws \Leafo\ScssPhp\Exception\CompilerException If the file could not be saved … … 181 182 $sourceMap['sources'] = []; 182 183 183 foreach ($this->sources as $source _uri => $source_filename) {184 $sourceMap['sources'][] = $this->normalizeFilename($source _filename);184 foreach ($this->sources as $sourceUri => $sourceFilename) { 185 $sourceMap['sources'][] = $this->normalizeFilename($sourceFilename); 185 186 } 186 187 … … 237 238 } 238 239 239 $this->source _keys = array_flip(array_keys($this->sources));240 $this->sourceKeys = array_flip(array_keys($this->sources)); 240 241 241 242 // group mappings by generated line number. … … 249 250 $lastGeneratedLine = $lastOriginalIndex = $lastOriginalLine = $lastOriginalColumn = 0; 250 251 251 foreach ($groupedMap as $lineNumber => $line _map) {252 foreach ($groupedMap as $lineNumber => $lineMap) { 252 253 while (++$lastGeneratedLine < $lineNumber) { 253 254 $groupedMapEncoded[] = ';'; … … 257 258 $lastGeneratedColumn = 0; 258 259 259 foreach ($line _map as $m) {260 foreach ($lineMap as $m) { 260 261 $mapEncoded = $this->encoder->encode($m['generated_column'] - $lastGeneratedColumn); 261 262 $lastGeneratedColumn = $m['generated_column']; … … 294 295 protected function findFileIndex($filename) 295 296 { 296 return $this->source_keys[$filename]; 297 } 298 297 return $this->sourceKeys[$filename]; 298 } 299 300 /** 301 * Normalize filename 302 * 303 * @param string $filename 304 * 305 * @return string 306 */ 299 307 protected function normalizeFilename($filename) 300 308 { -
_plugins_/scssphp/trunk/lib/scssphp/src/Version.php
r115183 r115301 19 19 class Version 20 20 { 21 const VERSION = 'v0.8. 0.1';21 const VERSION = 'v0.8.2.1'; 22 22 } -
_plugins_/scssphp/trunk/paquet.xml
r115259 r115301 2 2 prefix="scssphp" 3 3 categorie="outil" 4 version="1.9. 1"4 version="1.9.2" 5 5 etat="test" 6 6 compatibilite="[2.1.0;3.2.*]" … … 22 22 <pipeline nom="formulaire_admin" inclure="scssphp_pipelines.php" /> 23 23 24 <procure nom="scssphp" version="0.8. 0.1" />24 <procure nom="scssphp" version="0.8.2.1" /> 25 25 26 26 <spip compatibilite="[3.1.0;[">
Note: See TracChangeset
for help on using the changeset viewer.