Changeset 2820106
- Timestamp:
- 11/17/2022 10:31:05 PM (3 years ago)
- Location:
- wp-scss/trunk
- Files:
-
- 23 edited
-
readme.md (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
scssphp/bin/pscss (modified) (4 diffs)
-
scssphp/composer.json (modified) (4 diffs)
-
scssphp/src/Base/Range.php (modified) (2 diffs)
-
scssphp/src/Block.php (modified) (3 diffs)
-
scssphp/src/Colors.php (modified) (1 diff)
-
scssphp/src/Compiler.php (modified) (105 diffs)
-
scssphp/src/Compiler/Environment.php (modified) (2 diffs)
-
scssphp/src/Formatter.php (modified) (4 diffs)
-
scssphp/src/Formatter/Compressed.php (modified) (1 diff)
-
scssphp/src/Formatter/Nested.php (modified) (2 diffs)
-
scssphp/src/Formatter/OutputBlock.php (modified) (2 diffs)
-
scssphp/src/Node.php (modified) (1 diff)
-
scssphp/src/Node/Number.php (modified) (8 diffs)
-
scssphp/src/Parser.php (modified) (77 diffs)
-
scssphp/src/SourceMap/Base64.php (modified) (2 diffs)
-
scssphp/src/SourceMap/Base64VLQ.php (modified) (4 diffs)
-
scssphp/src/SourceMap/SourceMapGenerator.php (modified) (3 diffs)
-
scssphp/src/Type.php (modified) (1 diff)
-
scssphp/src/Util.php (modified) (1 diff)
-
scssphp/src/Version.php (modified) (1 diff)
-
wp-scss.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-scss/trunk/readme.md
r2616813 r2820106 36 36 - Crunched - Same as Compressed, but also removes multi-line comments. 37 37 38 See examples of each in [scssphp's documentation](http://scssphp.github.io/scssphp) 38 See examples of each in [ScssPHP's documentation](http://scssphp.github.io/scssphp) 39 40 - Current version of ScssPHP is 1.10.0 39 41 40 42 #### Source Map Mode … … 60 62 ## Directions 61 63 62 _This plugin requires at least php 5.6 to work._ 64 _This plugin requires at least php 5.6 to work._ . Tested up to php 7.4 63 65 64 66 #### Importing Subfiles … … 111 113 ## Changelog 112 114 115 - 3.0.0 116 - Updates ScssPHP to version [1.10.0](https://github.com/scssphp/scssphp/releases/tag/v1.10.0) thanks to [fabarea](https://github.com/ConnectThink/WP-SCSS/issues/228) 113 117 - 2.4.0 114 - Changes the base_compiling_folder to store key not path todirectory [shadoath](https://github.com/ConnectThink/WP-SCSS/issues/219)118 - Changes the base_compiling_folder to store key not path of directory [shadoath](https://github.com/ConnectThink/WP-SCSS/issues/219) 115 119 - This allows deploying from local or staging to production by not saving absolute paths in DB. 116 120 - 2.3.5 -
wp-scss/trunk/readme.txt
r2616813 r2820106 4 4 Plugin URI: https://github.com/ConnectThink/WP-SCSS 5 5 Requires at least: 3.0.1 6 Tested up to: 5.86 Tested up to: 6.0 7 7 Requires PHP: 5.6 8 Stable tag: 2.4.08 Stable tag: 3.0.0 9 9 License: GPLv3 or later 10 10 License URI: http://www.gnu.org/copyleft/gpl.html … … 76 76 77 77 == Changelog == 78 79 = 3.0.0 = 80 - Updates ScssPHP to version [1.10.0](https://github.com/scssphp/scssphp/releases/tag/v1.10.0) thanks to [fabarea](https://github.com/ConnectThink/WP-SCSS/issues/228) 81 82 = 2.4.0 = 83 - Changes the base_compiling_folder to store key not path to directory [shadoath](https://github.com/ConnectThink/WP-SCSS/issues/219) 84 - This allows deploying from local or staging to production by not saving absolute paths in DB. 78 85 79 86 = 2.3.5 = -
wp-scss/trunk/scssphp/bin/pscss
r2549034 r2820106 27 27 28 28 $style = null; 29 $loadPaths = null;29 $loadPaths = []; 30 30 $dumpTree = false; 31 31 $inputFile = null; … … 39 39 * Parse argument 40 40 * 41 * @param int eger$i42 * @param array$options41 * @param int $i 42 * @param string[] $options 43 43 * 44 44 * @return string|null … … 149 149 150 150 if (isset($value)) { 151 $loadPaths = $value;151 $loadPaths[] = $value; 152 152 continue; 153 153 } … … 189 189 190 190 if ($loadPaths) { 191 $scss->setImportPaths( explode(PATH_SEPARATOR, $loadPaths));191 $scss->setImportPaths($loadPaths); 192 192 } 193 193 -
wp-scss/trunk/scssphp/composer.json
r2549034 r2820106 41 41 "squizlabs/php_codesniffer": "~3.5", 42 42 "symfony/phpunit-bridge": "^5.1", 43 "thoughtbot/bourbon": "^7.0", 43 44 "twbs/bootstrap": "~5.0", 44 "twbs/bootstrap4": "4.6. 0",45 "twbs/bootstrap4": "4.6.1", 45 46 "zurb/foundation": "~6.5" 46 47 }, … … 50 51 "package": { 51 52 "name": "sass/sass-spec", 52 "version": "2021. 05.10",53 "version": "2021.11.30", 53 54 "source": { 54 55 "type": "git", 55 56 "url": "https://github.com/sass/sass-spec.git", 56 "reference": " b9bf24a936528f333fb30ee59ca550c6da551c11"57 "reference": "ee5b460ac84b1ce27b86e22c0252b4296444cf3a" 57 58 }, 58 59 "dist": { 59 60 "type": "zip", 60 "url": "https://api.github.com/repos/sass/sass-spec/zipball/b9bf24a936528f333fb30ee59ca550c6da551c11", 61 "reference": "b9bf24a936528f333fb30ee59ca550c6da551c11", 61 "url": "https://api.github.com/repos/sass/sass-spec/zipball/ee5b460ac84b1ce27b86e22c0252b4296444cf3a", 62 "reference": "ee5b460ac84b1ce27b86e22c0252b4296444cf3a", 63 "shasum": "" 64 } 65 } 66 }, 67 { 68 "type": "package", 69 "package": { 70 "name": "thoughtbot/bourbon", 71 "version": "v7.0.0", 72 "source": { 73 "type": "git", 74 "url": "https://github.com/thoughtbot/bourbon.git", 75 "reference": "fbe338ee6807e7f7aa996d82c8a16f248bb149b3" 76 }, 77 "dist": { 78 "type": "zip", 79 "url": "https://api.github.com/repos/thoughtbot/bourbon/zipball/fbe338ee6807e7f7aa996d82c8a16f248bb149b3", 80 "reference": "fbe338ee6807e7f7aa996d82c8a16f248bb149b3", 62 81 "shasum": "" 63 82 } … … 68 87 "package": { 69 88 "name": "twbs/bootstrap4", 70 "version": "v4.6. 0",89 "version": "v4.6.1", 71 90 "source": { 72 91 "type": "git", 73 92 "url": "https://github.com/twbs/bootstrap.git", 74 "reference": " 6ffb0b48e455430f8a5359ed689ad64c1143fac2"93 "reference": "043a03c95a2ad6738f85b65e53b9dbdfb03b8d10" 75 94 }, 76 95 "dist": { 77 96 "type": "zip", 78 "url": "https://api.github.com/repos/twbs/bootstrap/zipball/ 6ffb0b48e455430f8a5359ed689ad64c1143fac2",79 "reference": " 6ffb0b48e455430f8a5359ed689ad64c1143fac2",97 "url": "https://api.github.com/repos/twbs/bootstrap/zipball/043a03c95a2ad6738f85b65e53b9dbdfb03b8d10", 98 "reference": "043a03c95a2ad6738f85b65e53b9dbdfb03b8d10", 80 99 "shasum": "" 81 100 } … … 85 104 "bin": ["bin/pscss"], 86 105 "config": { 87 "sort-packages": true 106 "sort-packages": true, 107 "allow-plugins": { 108 "bamarni/composer-bin-plugin": true 109 } 88 110 } 89 111 } -
wp-scss/trunk/scssphp/src/Base/Range.php
r2549034 r2820106 35 35 * Initialize range 36 36 * 37 * @param int eger|float $first38 * @param int eger|float $last37 * @param int|float $first 38 * @param int|float $last 39 39 */ 40 40 public function __construct($first, $last) … … 47 47 * Test for inclusion in range 48 48 * 49 * @param int eger|float $value49 * @param int|float $value 50 50 * 51 * @return bool ean51 * @return bool 52 52 */ 53 53 public function includes($value) -
wp-scss/trunk/scssphp/src/Block.php
r2549034 r2820106 23 23 { 24 24 /** 25 * @var string 25 * @var string|null 26 26 */ 27 27 public $type; 28 28 29 29 /** 30 * @var \ScssPhp\ScssPhp\Block30 * @var Block|null 31 31 */ 32 32 public $parent; … … 38 38 39 39 /** 40 * @var int eger40 * @var int 41 41 */ 42 42 public $sourceIndex; 43 43 44 44 /** 45 * @var int eger45 * @var int 46 46 */ 47 47 public $sourceLine; 48 48 49 49 /** 50 * @var int eger50 * @var int 51 51 */ 52 52 public $sourceColumn; … … 68 68 69 69 /** 70 * @var \ScssPhp\ScssPhp\Block|null70 * @var Block|null 71 71 */ 72 72 public $selfParent; -
wp-scss/trunk/scssphp/src/Colors.php
r2549034 r2820106 205 205 * Reverse conversion : from RGBA to a color name if possible 206 206 * 207 * @param int eger$r208 * @param int eger$g209 * @param int eger$b210 * @param int eger|float $a207 * @param int $r 208 * @param int $g 209 * @param int $b 210 * @param int|float $a 211 211 * 212 212 * @return string|null -
wp-scss/trunk/scssphp/src/Compiler.php
r2549034 r2820106 14 14 15 15 use ScssPhp\ScssPhp\Base\Range; 16 use ScssPhp\ScssPhp\Block\AtRootBlock; 17 use ScssPhp\ScssPhp\Block\CallableBlock; 18 use ScssPhp\ScssPhp\Block\DirectiveBlock; 19 use ScssPhp\ScssPhp\Block\EachBlock; 20 use ScssPhp\ScssPhp\Block\ElseBlock; 21 use ScssPhp\ScssPhp\Block\ElseifBlock; 22 use ScssPhp\ScssPhp\Block\ForBlock; 23 use ScssPhp\ScssPhp\Block\IfBlock; 24 use ScssPhp\ScssPhp\Block\MediaBlock; 25 use ScssPhp\ScssPhp\Block\NestedPropertyBlock; 26 use ScssPhp\ScssPhp\Block\WhileBlock; 16 27 use ScssPhp\ScssPhp\Compiler\CachedResult; 17 28 use ScssPhp\ScssPhp\Compiler\Environment; … … 138 149 public static $with = [Type::T_KEYWORD, 'with']; 139 150 public static $without = [Type::T_KEYWORD, 'without']; 151 private static $emptyArgumentList = [Type::T_LIST, '', [], []]; 140 152 141 153 /** … … 195 207 196 208 /** 209 * @var bool 210 */ 211 private $charset = true; 212 213 /** 197 214 * @var string|\ScssPhp\ScssPhp\Formatter 198 215 */ … … 222 239 /** 223 240 * @var bool|null 241 * 242 * @deprecated 224 243 */ 225 244 protected $charsetSeen; … … 464 483 $this->scope = null; 465 484 $this->storeEnv = null; 466 $this->charsetSeen = null;467 485 $this->shouldEvaluate = null; 468 486 $this->ignoreCallStackMessage = false; … … 517 535 $prefix = ''; 518 536 519 if (!$this->charsetSeen) { 520 if (strlen($out) !== Util::mbStrlen($out)) { 521 $prefix = '@charset "UTF-8";' . "\n"; 522 $out = $prefix . $out; 523 } 537 if ($this->charset && strlen($out) !== Util::mbStrlen($out)) { 538 $prefix = '@charset "UTF-8";' . "\n"; 539 $out = $prefix . $out; 524 540 } 525 541 … … 640 656 * @param array $origin 641 657 * 642 * @return bool ean658 * @return bool 643 659 */ 644 660 protected function isSelfExtend($target, $origin) … … 849 865 * Match extends 850 866 * 851 * @param array $selector852 * @param array $out853 * @param int eger$from854 * @param bool ean$initial867 * @param array $selector 868 * @param array $out 869 * @param int $from 870 * @param bool $initial 855 871 * 856 872 * @return void … … 985 1001 * @param array $matches 986 1002 * 987 * @return bool ean1003 * @return bool 988 1004 */ 989 1005 protected function isPseudoSelector($part, &$matches) … … 1047 1063 * Match extends single 1048 1064 * 1049 * @param array $rawSingle1050 * @param array $outOrigin1051 * @param bool ean$initial1052 * 1053 * @return bool ean1065 * @param array $rawSingle 1066 * @param array $outOrigin 1067 * @param bool $initial 1068 * 1069 * @return bool 1054 1070 */ 1055 1071 protected function matchExtendsSingle($rawSingle, &$outOrigin, $initial = true) … … 1266 1282 protected function compileMedia(Block $media) 1267 1283 { 1284 assert($media instanceof MediaBlock); 1268 1285 $this->pushEnv($media); 1269 1286 … … 1343 1360 * Compile directive 1344 1361 * 1345 * @param \ScssPhp\ScssPhp\Block|array$directive1362 * @param DirectiveBlock|array $directive 1346 1363 * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out 1347 1364 * … … 1409 1426 protected function compileAtRoot(Block $block) 1410 1427 { 1428 assert($block instanceof AtRootBlock); 1411 1429 $env = $this->pushEnv($block); 1412 1430 $envs = $this->compactEnv($env); … … 1457 1475 1458 1476 /** 1459 * Filter at-root scope depending o fwith/without option1477 * Filter at-root scope depending on with/without option 1460 1478 * 1461 1479 * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $scope … … 1557 1575 * 1558 1576 * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $scope 1559 * @param int eger$depth1577 * @param int $depth 1560 1578 * 1561 1579 * @return array … … 1581 1599 * Compile @at-root's with: inclusion / without: exclusion into 2 lists uses to filter scope/env later 1582 1600 * 1583 * @param array $withCondition1601 * @param array|null $withCondition 1584 1602 * 1585 1603 * @return array 1604 * 1605 * @phpstan-return array{array<string, bool>, array<string, bool>} 1586 1606 */ 1587 1607 protected function compileWith($withCondition) … … 1603 1623 } 1604 1624 1605 if ($this->mapHasKey($withCondition, static::$with)) { 1625 $withConfig = $this->mapGet($withCondition, static::$with); 1626 if ($withConfig !== null) { 1606 1627 $without = []; // cancel the default 1607 $list = $this->coerceList($ this->libMapGet([$withCondition, static::$with]));1628 $list = $this->coerceList($withConfig); 1608 1629 1609 1630 foreach ($list[2] as $item) { … … 1614 1635 } 1615 1636 1616 if ($this->mapHasKey($withCondition, static::$without)) { 1637 $withoutConfig = $this->mapGet($withCondition, static::$without); 1638 if ($withoutConfig !== null) { 1617 1639 $without = []; // cancel the default 1618 $list = $this->coerceList($ this->libMapGet([$withCondition, static::$without]));1640 $list = $this->coerceList($withoutConfig); 1619 1641 1620 1642 foreach ($list[2] as $item) { … … 1666 1688 * @param array $without 1667 1689 * 1668 * @return bool ean1690 * @return bool 1669 1691 */ 1670 1692 protected function isWith($block, $with, $without) … … 1676 1698 1677 1699 if ($block->type === Type::T_DIRECTIVE) { 1700 assert($block instanceof DirectiveBlock || $block instanceof OutputBlock); 1678 1701 if (isset($block->name)) { 1679 1702 return $this->testWithWithout($this->compileDirectiveName($block->name), $with, $without); … … 1711 1734 * @param array $without 1712 1735 * 1713 * @return bool ean1736 * @return bool 1714 1737 * true if the block should be kept, false to reject 1715 1738 */ … … 1766 1789 protected function compileNestedPropertiesBlock(Block $block, OutputBlock $out) 1767 1790 { 1791 assert($block instanceof NestedPropertyBlock); 1768 1792 $prefix = $this->compileValue($block->prefix) . '-'; 1769 1793 … … 1784 1808 1785 1809 case Type::T_NESTED_PROPERTY: 1810 assert($child[1] instanceof NestedPropertyBlock); 1786 1811 array_unshift($child[1]->prefix[2], $prefix); 1787 1812 break; … … 1809 1834 // wrap assign children in a block 1810 1835 // except for @font-face 1811 if ( $block->type !== Type::T_DIRECTIVE|| $this->compileDirectiveName($block->name) !== 'font-face') {1836 if (!$block instanceof DirectiveBlock || $this->compileDirectiveName($block->name) !== 'font-face') { 1812 1837 // need wrapping? 1813 1838 $needWrapping = false; … … 1898 1923 * Compile the value of a comment that can have interpolation 1899 1924 * 1900 * @param array $value1901 * @param bool ean$pushEnv1925 * @param array $value 1926 * @param bool $pushEnv 1902 1927 * 1903 1928 * @return string … … 2216 2241 * @param array $selector 2217 2242 * 2218 * @return bool ean2243 * @return bool 2219 2244 */ 2220 2245 protected function hasSelectorPlaceholder($selector) … … 2633 2658 * @param array $rawPath 2634 2659 * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out 2635 * @param bool ean$once2636 * 2637 * @return bool ean2660 * @param bool $once 2661 * 2662 * @return bool 2638 2663 */ 2639 2664 protected function compileImport($rawPath, OutputBlock $out, $once = false) … … 2770 2795 $child = $this->makeOutputBlock(Type::T_COMMENT); 2771 2796 $child->lines[] = $line; 2772 $child->sourceName = $this->sourceNames[$this->sourceIndex] ;2797 $child->sourceName = $this->sourceNames[$this->sourceIndex] ?: '(stdin)'; 2773 2798 $child->sourceLine = $this->sourceLine; 2774 2799 $child->sourceColumn = $this->sourceColumn; … … 2878 2903 2879 2904 case Type::T_CHARSET: 2880 if (! $this->charsetSeen) {2881 $this->charsetSeen = true;2882 $this->appendRootDirective('@charset ' . $this->compileValue($child[1]) . ';', $out);2883 }2884 2905 break; 2885 2906 … … 3045 3066 case Type::T_FUNCTION: 3046 3067 list(, $block) = $child; 3068 assert($block instanceof CallableBlock); 3047 3069 // the block need to be able to go up to it's parent env to resolve vars 3048 3070 $block->parentEnv = $this->getStoreEnv(); … … 3073 3095 } 3074 3096 3097 if (\count($result) > 1) { 3098 $replacement = implode(', ', $result); 3099 $fname = $this->getPrettyPath($this->sourceNames[$this->sourceIndex]); 3100 $line = $this->sourceLine; 3101 3102 $message = <<<EOL 3103 on line $line of $fname: 3104 Compound selectors may no longer be extended. 3105 Consider `@extend $replacement` instead. 3106 See http://bit.ly/ExtendCompound for details. 3107 EOL; 3108 3109 $this->logger->warn($message); 3110 } 3111 3075 3112 $this->pushExtends($result, $selectors, $child); 3076 3113 } … … 3080 3117 case Type::T_IF: 3081 3118 list(, $if) = $child; 3119 assert($if instanceof IfBlock); 3082 3120 3083 3121 if ($this->isTruthy($this->reduce($if->cond, true))) { … … 3087 3125 foreach ($if->cases as $case) { 3088 3126 if ( 3089 $case ->type === Type::T_ELSE||3090 $case ->type === Type::T_ELSEIF&& $this->isTruthy($this->reduce($case->cond))3127 $case instanceof ElseBlock || 3128 $case instanceof ElseifBlock && $this->isTruthy($this->reduce($case->cond)) 3091 3129 ) { 3092 3130 return $this->compileChildren($case->children, $out); … … 3097 3135 case Type::T_EACH: 3098 3136 list(, $each) = $child; 3137 assert($each instanceof EachBlock); 3099 3138 3100 3139 $list = $this->coerceList($this->reduce($each->list), ',', true); … … 3131 3170 case Type::T_WHILE: 3132 3171 list(, $while) = $child; 3172 assert($while instanceof WhileBlock); 3133 3173 3134 3174 while ($this->isTruthy($this->reduce($while->cond, true))) { … … 3143 3183 case Type::T_FOR: 3144 3184 list(, $for) = $child; 3185 assert($for instanceof ForBlock); 3145 3186 3146 3187 $startNumber = $this->assertNumber($this->reduce($for->start, true)); … … 3203 3244 } 3204 3245 3246 assert($mixin instanceof CallableBlock); 3247 3205 3248 $callingScope = $this->getStoreEnv(); 3206 3249 … … 3375 3418 * @param array|Number $value 3376 3419 * 3377 * @return bool ean3420 * @return bool 3378 3421 */ 3379 3422 public function isTruthy($value) … … 3387 3430 * @param string $value 3388 3431 * 3389 * @return bool ean3432 * @return bool 3390 3433 */ 3391 3434 protected function isImmediateRelationshipCombinator($value) … … 3399 3442 * @param array $value 3400 3443 * 3401 * @return bool ean3444 * @return bool 3402 3445 */ 3403 3446 protected function shouldEval($value) … … 3422 3465 * 3423 3466 * @param array|Number $value 3424 * @param bool ean$inExp3467 * @param bool $inExp 3425 3468 * 3426 3469 * @return array|Number … … 3813 3856 // try to find a native lib function 3814 3857 $normalizedName = $this->normalizeName($name); 3815 $libName = null;3816 3858 3817 3859 if (isset($this->userFunctions[$normalizedName])) { … … 3822 3864 } 3823 3865 3866 $lowercasedName = strtolower($normalizedName); 3867 3868 // Special functions overriding a CSS function are case-insensitive. We normalize them as lowercase 3869 // to avoid the deprecation warning about the wrong case being used. 3870 if ($lowercasedName === 'min' || $lowercasedName === 'max') { 3871 $normalizedName = $lowercasedName; 3872 } 3873 3824 3874 if (($f = $this->getBuiltinFunction($normalizedName)) && \is_callable($f)) { 3825 3875 $libName = $f[1]; 3826 3876 $prototype = isset(static::$$libName) ? static::$$libName : null; 3877 3878 // All core functions have a prototype defined. Not finding the 3879 // prototype can mean 2 things: 3880 // - the function comes from a child class (deprecated just after) 3881 // - the function was found with a different case, which relates to calling the 3882 // wrong Sass function due to our camelCase usage (`fade-in()` vs `fadein()`), 3883 // because PHP method names are case-insensitive while property names are 3884 // case-sensitive. 3885 if ($prototype === null || strtolower($normalizedName) !== $normalizedName) { 3886 $r = new \ReflectionMethod($this, $libName); 3887 $actualLibName = $r->name; 3888 3889 if ($actualLibName !== $libName || strtolower($normalizedName) !== $normalizedName) { 3890 $kebabCaseName = preg_replace('~(?<=\\w)([A-Z])~', '-$1', substr($actualLibName, 3)); 3891 assert($kebabCaseName !== null); 3892 $originalName = strtolower($kebabCaseName); 3893 $warning = "Calling built-in functions with a non-standard name is deprecated since Scssphp 1.8.0 and will not work anymore in 2.0 (they will be treated as CSS function calls instead).\nUse \"$originalName\" instead of \"$name\"."; 3894 @trigger_error($warning, E_USER_DEPRECATED); 3895 $fname = $this->getPrettyPath($this->sourceNames[$this->sourceIndex]); 3896 $line = $this->sourceLine; 3897 Warn::deprecation("$warning\n on line $line of $fname"); 3898 3899 // Use the actual function definition 3900 $prototype = isset(static::$$actualLibName) ? static::$$actualLibName : null; 3901 $f[1] = $libName = $actualLibName; 3902 } 3903 } 3827 3904 3828 3905 if (\get_class($this) !== __CLASS__ && !isset($this->warnedChildFunctions[$libName])) { … … 3893 3970 } 3894 3971 3972 if ($value[1] === '' && count($value[2]) > 1) { 3973 $value[1] = ' '; 3974 } 3975 3895 3976 return $value; 3896 3977 … … 4008 4089 * 4009 4090 * @param array|Number $left 4010 * @param array|Number $right4011 * @param bool ean$shouldEval4091 * @param array|Number $right 4092 * @param bool $shouldEval 4012 4093 * 4013 4094 * @return array|Number|null … … 4037 4118 * @param array|Number $left 4038 4119 * @param array|Number $right 4039 * @param bool ean$shouldEval4120 * @param bool $shouldEval 4040 4121 * 4041 4122 * @return array|Number|null … … 4463 4544 if ( 4464 4545 $value[1] === "'" && 4465 (strpos($content, '"') === false or strpos($content, "'") !== false) && 4466 strpbrk($content, '{}\\\'') !== false 4546 (strpos($content, '"') === false or strpos($content, "'") !== false) 4467 4547 ) { 4468 4548 $value[1] = '"'; … … 4516 4596 } 4517 4597 } 4598 4599 $separator = $delim === '/' ? ' /' : $delim; 4518 4600 4519 4601 $prefix_value = ''; … … 4555 4637 } 4556 4638 4557 return $pre . substr(implode( "$delim", $filtered), \strlen($prefix_value)) . $post;4639 return $pre . substr(implode($separator, $filtered), \strlen($prefix_value)) . $post; 4558 4640 4559 4641 case Type::T_MAP: … … 4827 4909 * Join selectors; looks for & to replace, or append parent before child 4828 4910 * 4829 * @param array $parent4830 * @param array $child4831 * @param bool ean$stillHasSelf4832 * @param array $selfParentSelectors4911 * @param array $parent 4912 * @param array $child 4913 * @param bool $stillHasSelf 4914 * @param array $selfParentSelectors 4833 4915 4834 4916 * @return array … … 4907 4989 return $this->multiplyMedia($env->parent, $childQueries); 4908 4990 } 4991 4992 assert($env->block instanceof MediaBlock); 4909 4993 4910 4994 $parentQueries = isset($env->block->queryList) … … 5042 5126 * @param string $name 5043 5127 * @param mixed $value 5044 * @param bool ean$shadow5128 * @param bool $shadow 5045 5129 * @param \ScssPhp\ScssPhp\Compiler\Environment $env 5046 5130 * @param mixed $valueUnreduced … … 5148 5232 * 5149 5233 * @param string $name 5150 * @param bool ean$shouldThrow5234 * @param bool $shouldThrow 5151 5235 * @param \ScssPhp\ScssPhp\Compiler\Environment $env 5152 * @param bool ean$unreduced5236 * @param bool $unreduced 5153 5237 * 5154 5238 * @return mixed|null … … 5217 5301 * @param \ScssPhp\ScssPhp\Compiler\Environment $env 5218 5302 * 5219 * @return bool ean5303 * @return bool 5220 5304 */ 5221 5305 protected function has($name, Environment $env = null) … … 5407 5491 * @api 5408 5492 * 5409 * @param int eger$numberPrecision5493 * @param int $numberPrecision 5410 5494 * 5411 5495 * @return void … … 5485 5569 5486 5570 /** 5571 * Configures the handling of non-ASCII outputs. 5572 * 5573 * If $charset is `true`, this will include a `@charset` declaration or a 5574 * UTF-8 [byte-order mark][] if the stylesheet contains any non-ASCII 5575 * characters. Otherwise, it will never include a `@charset` declaration or a 5576 * byte-order mark. 5577 * 5578 * [byte-order mark]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8 5579 * 5580 * @param bool $charset 5581 * 5582 * @return void 5583 */ 5584 public function setCharset($charset) 5585 { 5586 $this->charset = $charset; 5587 } 5588 5589 /** 5487 5590 * Enable/disable source maps 5488 5591 * 5489 5592 * @api 5490 5593 * 5491 * @param int eger$sourceMap5594 * @param int $sourceMap 5492 5595 * 5493 5596 * @return void … … 5858 5961 5859 5962 if (0 === strpos($normalizedPath, $normalizedRootDirectory)) { 5860 return substr($ normalizedPath, \strlen($normalizedRootDirectory));5963 return substr($path, \strlen($normalizedRootDirectory)); 5861 5964 } 5862 5965 … … 5891 5994 * @api 5892 5995 * 5893 * @param bool ean$ignoreErrors5996 * @param bool $ignoreErrors 5894 5997 * 5895 5998 * @return \ScssPhp\ScssPhp\Compiler … … 6030 6133 * Beautify call stack for output 6031 6134 * 6032 * @param bool ean$all6135 * @param bool $all 6033 6136 * @param int|null $limit 6034 6137 * … … 6090 6193 * Call SCSS @function 6091 6194 * 6092 * @param Object$func6093 * @param array $argValues6195 * @param CallableBlock|null $func 6196 * @param array $argValues 6094 6197 * 6095 6198 * @return array|Number … … 6665 6768 * @param array[] $argDef 6666 6769 * @param array|null $argValues 6667 * @param boolean $storeInEnv 6668 * @param boolean $reduce 6669 * only used if $storeInEnv = false 6770 * @param bool $storeInEnv 6771 * @param bool $reduce only used if $storeInEnv = false 6670 6772 * 6671 6773 * @return array<string, array|Number> … … 6862 6964 6863 6965 /** 6864 * Coerce something to map 6865 * 6866 * @param array|Number $item 6867 * 6868 * @return array|Number 6869 */ 6870 protected function coerceMap($item) 6871 { 6966 * Tries to convert an item to a Sass map 6967 * 6968 * @param Number|array $item 6969 * 6970 * @return array|null 6971 */ 6972 private function tryMap($item) 6973 { 6974 if ($item instanceof Number) { 6975 return null; 6976 } 6977 6872 6978 if ($item[0] === Type::T_MAP) { 6873 6979 return $item; … … 6881 6987 } 6882 6988 6989 return null; 6990 } 6991 6992 /** 6993 * Coerce something to map 6994 * 6995 * @param array|Number $item 6996 * 6997 * @return array|Number 6998 */ 6999 protected function coerceMap($item) 7000 { 7001 $map = $this->tryMap($item); 7002 7003 if ($map !== null) { 7004 return $map; 7005 } 7006 6883 7007 return $item; 6884 7008 } … … 6889 7013 * @param array|Number $item 6890 7014 * @param string $delim 6891 * @param bool ean$removeTrailingNull7015 * @param bool $removeTrailingNull 6892 7016 * 6893 7017 * @return array … … 6896 7020 { 6897 7021 if ($item instanceof Number) { 6898 return [Type::T_LIST, $delim, [$item]];7022 return [Type::T_LIST, '', [$item]]; 6899 7023 } 6900 7024 … … 6917 7041 $value = $values[$i]; 6918 7042 6919 switch ($key[0]) {6920 case Type::T_LIST:6921 case Type::T_MAP:6922 case Type::T_STRING:6923 case Type::T_NULL:6924 break;6925 6926 default:6927 $key = [Type::T_KEYWORD, $this->compileStringContent($this->coerceString($key))];6928 break;6929 }6930 6931 7043 $list[] = [ 6932 7044 Type::T_LIST, 6933 ' ',7045 ' ', 6934 7046 [$key, $value] 6935 7047 ]; 6936 7048 } 6937 7049 6938 return [Type::T_LIST, ',', $list];6939 } 6940 6941 return [Type::T_LIST, $delim, [$item]];7050 return [Type::T_LIST, $list ? ',' : '', $list]; 7051 } 7052 7053 return [Type::T_LIST, '', [$item]]; 6942 7054 } 6943 7055 … … 7080 7192 7081 7193 /** 7082 * @param int eger|Number $value7083 * @param bool ean$isAlpha7084 * 7085 * @return int eger|mixed7194 * @param int|Number $value 7195 * @param bool $isAlpha 7196 * 7197 * @return int|mixed 7086 7198 */ 7087 7199 protected function compileRGBAValue($value, $isAlpha = false) … … 7095 7207 7096 7208 /** 7097 * @param mixed $value7098 * @param int eger|float $min7099 * @param int eger|float $max7100 * @param bool ean$isInt7101 * 7102 * @return int eger|mixed7209 * @param mixed $value 7210 * @param int|float $min 7211 * @param int|float $max 7212 * @param bool $isInt 7213 * 7214 * @return int|mixed 7103 7215 */ 7104 7216 protected function compileColorPartValue($value, $min, $max, $isInt = true) … … 7194 7306 * @param array|Number $value 7195 7307 * 7196 * @return integer|float 7308 * @return int|float 7309 * 7310 * @deprecated 7197 7311 */ 7198 7312 protected function coercePercent($value) 7199 7313 { 7314 @trigger_error(sprintf('"%s" is deprecated since 1.7.0.', __METHOD__), E_USER_DEPRECATED); 7315 7200 7316 if ($value instanceof Number) { 7201 7317 if ($value->hasUnit('%')) { … … 7223 7339 public function assertMap($value, $varName = null) 7224 7340 { 7225 $ value = $this->coerceMap($value);7226 7227 if ($ value[0] !== Type::T_MAP) {7341 $map = $this->tryMap($value); 7342 7343 if ($map === null) { 7228 7344 $value = $this->compileValue($value); 7229 7345 … … 7231 7347 } 7232 7348 7233 return $ value;7349 return $map; 7234 7350 } 7235 7351 … … 7328 7444 * @param string|null $varName 7329 7445 * 7330 * @return int eger7446 * @return int 7331 7447 * 7332 7448 * @throws SassScriptException … … 7392 7508 * @internal 7393 7509 * 7394 * @param int eger$red7395 * @param int eger$green7396 * @param int eger$blue7510 * @param int $red 7511 * @param int $green 7512 * @param int $blue 7397 7513 * 7398 7514 * @return array … … 7424 7540 } 7425 7541 7426 return [Type::T_HSL, fmod($h , 360), $s * 100, $l / 5.1];7542 return [Type::T_HSL, fmod($h + 360, 360), $s * 100, $l / 5.1]; 7427 7543 } 7428 7544 … … 7498 7614 * @api 7499 7615 * 7500 * @param int eger$hue H from 0 to 3607501 * @param int eger$whiteness W from 0 to 1007502 * @param int eger$blackness B from 0 to 1007616 * @param int $hue H from 0 to 360 7617 * @param int $whiteness W from 0 to 100 7618 * @param int $blackness B from 0 to 100 7503 7619 * 7504 7620 * @return array … … 7530 7646 * @api 7531 7647 * 7532 * @param int eger$red7533 * @param int eger$green7534 * @param int eger$blue7648 * @param int $red 7649 * @param int $green 7650 * @param int $blue 7535 7651 * 7536 7652 * @return array … … 7660 7776 $values = []; 7661 7777 7662 7663 7778 foreach ($list[2] as $item) { 7664 7779 $values[] = $this->normalizeValue($item); … … 7705 7820 } 7706 7821 } else { 7707 $color = [Type::T_STRING, '', [$funcName . '(', $args[0], ' )']];7822 $color = [Type::T_STRING, '', [$funcName . '(', $args[0], ', ', $args[1], ')']]; 7708 7823 } 7709 7824 break; … … 8006 8121 // mix two colors 8007 8122 protected static $libMix = [ 8008 ['color1', 'color2', 'weight: 0.5'],8009 ['color-1', 'color-2', 'weight: 0.5']8123 ['color1', 'color2', 'weight:50%'], 8124 ['color-1', 'color-2', 'weight:50%'] 8010 8125 ]; 8011 8126 protected function libMix($args) … … 8015 8130 $first = $this->assertColor($first, 'color1'); 8016 8131 $second = $this->assertColor($second, 'color2'); 8017 $weight = $this->coercePercent($this->assertNumber($weight, 'weight'));8132 $weightScale = $this->assertNumber($weight, 'weight')->valueInRange(0, 100, 'weight') / 100; 8018 8133 8019 8134 $firstAlpha = isset($first[4]) ? $first[4] : 1; 8020 8135 $secondAlpha = isset($second[4]) ? $second[4] : 1; 8021 8136 8022 $w = $weight * 2 - 1; 8023 $a = $firstAlpha - $secondAlpha; 8024 8025 $w1 = (($w * $a === -1 ? $w : ($w + $a) / (1 + $w * $a)) + 1) / 2.0; 8026 $w2 = 1.0 - $w1; 8137 $normalizedWeight = $weightScale * 2 - 1; 8138 $alphaDistance = $firstAlpha - $secondAlpha; 8139 8140 $combinedWeight = $normalizedWeight * $alphaDistance == -1 ? $normalizedWeight : ($normalizedWeight + $alphaDistance) / (1 + $normalizedWeight * $alphaDistance); 8141 $weight1 = ($combinedWeight + 1) / 2.0; 8142 $weight2 = 1.0 - $weight1; 8027 8143 8028 8144 $new = [Type::T_COLOR, 8029 $w 1 * $first[1] + $w2 * $second[1],8030 $w 1 * $first[2] + $w2 * $second[2],8031 $w 1 * $first[3] + $w2 * $second[3],8145 $weight1 * $first[1] + $weight2 * $second[1], 8146 $weight1 * $first[2] + $weight2 * $second[2], 8147 $weight1 * $first[3] + $weight2 * $second[3], 8032 8148 ]; 8033 8149 8034 8150 if ($firstAlpha != 1.0 || $secondAlpha != 1.0) { 8035 $new[] = $firstAlpha * $weight + $secondAlpha * (1 - $weight);8151 $new[] = $firstAlpha * $weightScale + $secondAlpha * (1 - $weightScale); 8036 8152 } 8037 8153 … … 8110 8226 } 8111 8227 8112 $hueValue = $hue->getDimension() % 360;8228 $hueValue = fmod($hue->getDimension(), 360); 8113 8229 8114 8230 while ($hueValue < 0) { … … 8288 8404 */ 8289 8405 8406 /** 8407 * @param array $color 8408 * @param int $idx 8409 * @param int|float $amount 8410 * 8411 * @return array 8412 */ 8290 8413 protected function adjustHsl($color, $idx, $amount) 8291 8414 { 8292 8415 $hsl = $this->toHSL($color[1], $color[2], $color[3]); 8293 8416 $hsl[$idx] += $amount; 8417 8418 if ($idx !== 1) { 8419 // Clamp the saturation and lightness 8420 $hsl[$idx] = min(max(0, $hsl[$idx]), 100); 8421 } 8422 8294 8423 $out = $this->toRGB($hsl[1], $hsl[2], $hsl[3]); 8295 8424 … … 8339 8468 } 8340 8469 8341 $color = $this->assertColor($ value, 'color');8342 $amount = 100 * $this->coercePercent($this->assertNumber($args[1], 'amount'));8343 8344 return $this->adjustHsl($color, 2, $amount );8470 $color = $this->assertColor($args[0], 'color'); 8471 $amount = $this->assertNumber($args[1], 'amount'); 8472 8473 return $this->adjustHsl($color, 2, $amount->valueInRange(0, 100, 'amount')); 8345 8474 } 8346 8475 … … 8349 8478 { 8350 8479 $color = $this->assertColor($args[0], 'color'); 8351 $amount = 100 * $this->coercePercent($this->assertNumber($args[1], 'amount'));8352 8353 return $this->adjustHsl($color, 2, -$amount );8480 $amount = $this->assertNumber($args[1], 'amount'); 8481 8482 return $this->adjustHsl($color, 2, -$amount->valueInRange(0, 100, 'amount')); 8354 8483 } 8355 8484 … … 8372 8501 } 8373 8502 8374 protected static $libInvert = ['color', 'weight:1 '];8503 protected static $libInvert = ['color', 'weight:100%']; 8375 8504 protected function libInvert($args) 8376 8505 { 8377 8506 $value = $args[0]; 8378 8507 8508 $weight = $this->assertNumber($args[1], 'weight'); 8509 8379 8510 if ($value instanceof Number) { 8511 if ($weight->getDimension() != 100 || !$weight->hasUnit('%')) { 8512 throw new SassScriptException('Only one argument may be passed to the plain-CSS invert() function.'); 8513 } 8514 8380 8515 return null; 8381 8516 } 8382 8383 $weight = $this->coercePercent($this->assertNumber($args[1], 'weight'));8384 8517 8385 8518 $color = $this->assertColor($value, 'color'); … … 8389 8522 $inverted[3] = 255 - $inverted[3]; 8390 8523 8391 if ($weight < 1) { 8392 return $this->libMix([$inverted, $color, new Number($weight, '')]); 8393 } 8394 8395 return $inverted; 8524 return $this->libMix([$inverted, $color, $weight]); 8396 8525 } 8397 8526 … … 8401 8530 { 8402 8531 $color = $this->assertColor($args[0], 'color'); 8403 $amount = $this-> coercePercent($this->assertNumber($args[1], 'amount'));8404 8405 $color[4] = (isset($color[4]) ? $color[4] : 1) + $amount ;8532 $amount = $this->assertNumber($args[1], 'amount'); 8533 8534 $color[4] = (isset($color[4]) ? $color[4] : 1) + $amount->valueInRange(0, 1, 'amount'); 8406 8535 $color[4] = min(1, max(0, $color[4])); 8407 8536 … … 8420 8549 { 8421 8550 $color = $this->assertColor($args[0], 'color'); 8422 $amount = $this-> coercePercent($this->assertNumber($args[1], 'amount'));8423 8424 $color[4] = (isset($color[4]) ? $color[4] : 1) - $amount ;8551 $amount = $this->assertNumber($args[1], 'amount'); 8552 8553 $color[4] = (isset($color[4]) ? $color[4] : 1) - $amount->valueInRange(0, 1, 'amount'); 8425 8554 $color[4] = min(1, max(0, $color[4])); 8426 8555 … … 8571 8700 $list = $this->coerceList($args[0]); 8572 8701 8573 if ( \count($list[2]) <= 1 && empty($list['enclosing'])) {8702 if ($list[1] === '' && \count($list[2]) <= 1 && empty($list['enclosing'])) { 8574 8703 return [Type::T_KEYWORD, 'space']; 8575 8704 } … … 8577 8706 if ($list[1] === ',') { 8578 8707 return [Type::T_KEYWORD, 'comma']; 8708 } 8709 8710 if ($list[1] === '/') { 8711 return [Type::T_KEYWORD, 'slash']; 8579 8712 } 8580 8713 … … 8618 8751 } 8619 8752 8620 protected static $libMapGet = ['map', 'key' ];8753 protected static $libMapGet = ['map', 'key', 'keys...']; 8621 8754 protected function libMapGet($args) 8622 8755 { 8623 8756 $map = $this->assertMap($args[0], 'map'); 8624 $key = $args[1]; 8625 8626 if (! \is_null($key)) { 8627 $key = $this->compileStringContent($this->coerceString($key)); 8628 8629 for ($i = \count($map[1]) - 1; $i >= 0; $i--) { 8630 if ($key === $this->compileStringContent($this->coerceString($map[1][$i]))) { 8631 return $map[2][$i]; 8632 } 8633 } 8634 } 8635 8636 return static::$null; 8757 if (!isset($args[2])) { 8758 // BC layer for usages of the function from PHP code rather than from the Sass function 8759 $args[2] = self::$emptyArgumentList; 8760 } 8761 $keys = array_merge([$args[1]], $args[2][2]); 8762 $value = static::$null; 8763 8764 foreach ($keys as $key) { 8765 if (!\is_array($map) || $map[0] !== Type::T_MAP) { 8766 return static::$null; 8767 } 8768 8769 $map = $this->mapGet($map, $key); 8770 8771 if ($map === null) { 8772 return static::$null; 8773 } 8774 8775 $value = $map; 8776 } 8777 8778 return $value; 8779 } 8780 8781 /** 8782 * Gets the value corresponding to that key in the map 8783 * 8784 * @param array $map 8785 * @param Number|array $key 8786 * 8787 * @return Number|array|null 8788 */ 8789 private function mapGet(array $map, $key) 8790 { 8791 $index = $this->mapGetEntryIndex($map, $key); 8792 8793 if ($index !== null) { 8794 return $map[2][$index]; 8795 } 8796 8797 return null; 8798 } 8799 8800 /** 8801 * Gets the index corresponding to that key in the map entries 8802 * 8803 * @param array $map 8804 * @param Number|array $key 8805 * 8806 * @return int|null 8807 */ 8808 private function mapGetEntryIndex(array $map, $key) 8809 { 8810 $key = $this->compileStringContent($this->coerceString($key)); 8811 8812 for ($i = \count($map[1]) - 1; $i >= 0; $i--) { 8813 if ($key === $this->compileStringContent($this->coerceString($map[1][$i]))) { 8814 return $i; 8815 } 8816 } 8817 8818 return null; 8637 8819 } 8638 8820 … … 8684 8866 } 8685 8867 8686 protected static $libMapHasKey = ['map', 'key' ];8868 protected static $libMapHasKey = ['map', 'key', 'keys...']; 8687 8869 protected function libMapHasKey($args) 8688 8870 { 8689 8871 $map = $this->assertMap($args[0], 'map'); 8690 8691 return $this->toBool($this->mapHasKey($map, $args[1])); 8872 if (!isset($args[2])) { 8873 // BC layer for usages of the function from PHP code rather than from the Sass function 8874 $args[2] = self::$emptyArgumentList; 8875 } 8876 $keys = array_merge([$args[1]], $args[2][2]); 8877 $lastKey = array_pop($keys); 8878 8879 foreach ($keys as $key) { 8880 $value = $this->mapGet($map, $key); 8881 8882 if ($value === null || $value instanceof Number || $value[0] !== Type::T_MAP) { 8883 return self::$false; 8884 } 8885 8886 $map = $value; 8887 } 8888 8889 return $this->toBool($this->mapHasKey($map, $lastKey)); 8692 8890 } 8693 8891 … … 8712 8910 protected static $libMapMerge = [ 8713 8911 ['map1', 'map2'], 8714 ['map-1', 'map-2'] 8912 ['map-1', 'map-2'], 8913 ['map1', 'args...'] 8715 8914 ]; 8716 8915 protected function libMapMerge($args) 8717 8916 { 8718 8917 $map1 = $this->assertMap($args[0], 'map1'); 8719 $map2 = $this->assertMap($args[1], 'map2'); 8720 8918 $map2 = $args[1]; 8919 $keys = []; 8920 if ($map2[0] === Type::T_LIST && isset($map2[3]) && \is_array($map2[3])) { 8921 // This is an argument list for the variadic signature 8922 if (\count($map2[2]) === 0) { 8923 throw new SassScriptException('Expected $args to contain a key.'); 8924 } 8925 if (\count($map2[2]) === 1) { 8926 throw new SassScriptException('Expected $args to contain a value.'); 8927 } 8928 $keys = $map2[2]; 8929 $map2 = array_pop($keys); 8930 } 8931 $map2 = $this->assertMap($map2, 'map2'); 8932 8933 return $this->modifyMap($map1, $keys, function ($oldValue) use ($map2) { 8934 $nestedMap = $this->tryMap($oldValue); 8935 8936 if ($nestedMap === null) { 8937 return $map2; 8938 } 8939 8940 return $this->mergeMaps($nestedMap, $map2); 8941 }); 8942 } 8943 8944 /** 8945 * @param array $map 8946 * @param array $keys 8947 * @param callable $modify 8948 * @param bool $addNesting 8949 * 8950 * @return Number|array 8951 * 8952 * @phpstan-param array<Number|array> $keys 8953 * @phpstan-param callable(Number|array): (Number|array) $modify 8954 */ 8955 private function modifyMap(array $map, array $keys, callable $modify, $addNesting = true) 8956 { 8957 if ($keys === []) { 8958 return $modify($map); 8959 } 8960 8961 return $this->modifyNestedMap($map, $keys, $modify, $addNesting); 8962 } 8963 8964 /** 8965 * @param array $map 8966 * @param array $keys 8967 * @param callable $modify 8968 * @param bool $addNesting 8969 * 8970 * @return array 8971 * 8972 * @phpstan-param non-empty-array<Number|array> $keys 8973 * @phpstan-param callable(Number|array): (Number|array) $modify 8974 */ 8975 private function modifyNestedMap(array $map, array $keys, callable $modify, $addNesting) 8976 { 8977 $key = array_shift($keys); 8978 8979 $nestedValueIndex = $this->mapGetEntryIndex($map, $key); 8980 8981 if ($keys === []) { 8982 if ($nestedValueIndex !== null) { 8983 $map[2][$nestedValueIndex] = $modify($map[2][$nestedValueIndex]); 8984 } else { 8985 $map[1][] = $key; 8986 $map[2][] = $modify(self::$null); 8987 } 8988 8989 return $map; 8990 } 8991 8992 $nestedMap = $nestedValueIndex !== null ? $this->tryMap($map[2][$nestedValueIndex]) : null; 8993 8994 if ($nestedMap === null && !$addNesting) { 8995 return $map; 8996 } 8997 8998 if ($nestedMap === null) { 8999 $nestedMap = self::$emptyMap; 9000 } 9001 9002 $newNestedMap = $this->modifyNestedMap($nestedMap, $keys, $modify, $addNesting); 9003 9004 if ($nestedValueIndex !== null) { 9005 $map[2][$nestedValueIndex] = $newNestedMap; 9006 } else { 9007 $map[1][] = $key; 9008 $map[2][] = $newNestedMap; 9009 } 9010 9011 return $map; 9012 } 9013 9014 /** 9015 * Merges 2 Sass maps together 9016 * 9017 * @param array $map1 9018 * @param array $map2 9019 * 9020 * @return array 9021 */ 9022 private function mergeMaps(array $map1, array $map2) 9023 { 8721 9024 foreach ($map2[1] as $i2 => $key2) { 8722 $key = $this->compileStringContent($this->coerceString($key2)); 8723 8724 foreach ($map1[1] as $i1 => $key1) { 8725 if ($key === $this->compileStringContent($this->coerceString($key1))) { 8726 $map1[2][$i1] = $map2[2][$i2]; 8727 continue 2; 8728 } 8729 } 8730 8731 $map1[1][] = $map2[1][$i2]; 9025 $map1EntryIndex = $this->mapGetEntryIndex($map1, $key2); 9026 9027 if ($map1EntryIndex !== null) { 9028 $map1[2][$map1EntryIndex] = $map2[2][$i2]; 9029 continue; 9030 } 9031 9032 $map1[1][] = $key2; 8732 9033 $map1[2][] = $map2[2][$i2]; 8733 9034 } … … 8777 9078 * @return string 8778 9079 * @throws CompilerException 9080 * 9081 * @deprecated 8779 9082 */ 8780 9083 protected function listSeparatorForJoin($list1, $sep) 8781 9084 { 9085 @trigger_error(sprintf('The "%s" method is deprecated.', __METHOD__), E_USER_DEPRECATED); 9086 8782 9087 if (! isset($sep)) { 8783 9088 return $list1[1]; … … 8796 9101 } 8797 9102 8798 protected static $libJoin = ['list1', 'list2', 'separator: null', 'bracketed:auto'];9103 protected static $libJoin = ['list1', 'list2', 'separator:auto', 'bracketed:auto']; 8799 9104 protected function libJoin($args) 8800 9105 { … … 8803 9108 $list1 = $this->coerceList($list1, ' ', true); 8804 9109 $list2 = $this->coerceList($list2, ' ', true); 8805 $sep = $this->listSeparatorForJoin($list1, $sep); 9110 9111 switch ($this->compileStringContent($this->assertString($sep, 'separator'))) { 9112 case 'comma': 9113 $separator = ','; 9114 break; 9115 9116 case 'space': 9117 $separator = ' '; 9118 break; 9119 9120 case 'slash': 9121 $separator = '/'; 9122 break; 9123 9124 case 'auto': 9125 if ($list1[1] !== '' || count($list1[2]) > 1 || !empty($list1['enclosing']) && $list1['enclosing'] !== 'parent') { 9126 $separator = $list1[1] ?: ' '; 9127 } elseif ($list2[1] !== '' || count($list2[2]) > 1 || !empty($list2['enclosing']) && $list2['enclosing'] !== 'parent') { 9128 $separator = $list2[1] ?: ' '; 9129 } else { 9130 $separator = ' '; 9131 } 9132 break; 9133 9134 default: 9135 throw SassScriptException::forArgument('Must be "space", "comma", "slash", or "auto".', 'separator'); 9136 } 8806 9137 8807 9138 if ($bracketed === static::$true) { … … 8830 9161 } 8831 9162 8832 $res = [Type::T_LIST, $sep, array_merge($list1[2], $list2[2])]; 8833 8834 if (isset($list1['enclosing'])) { 8835 $res['enlcosing'] = $list1['enclosing']; 8836 } 9163 $res = [Type::T_LIST, $separator, array_merge($list1[2], $list2[2])]; 8837 9164 8838 9165 if ($bracketed) { … … 8843 9170 } 8844 9171 8845 protected static $libAppend = ['list', 'val', 'separator: null'];9172 protected static $libAppend = ['list', 'val', 'separator:auto']; 8846 9173 protected function libAppend($args) 8847 9174 { … … 8849 9176 8850 9177 $list1 = $this->coerceList($list1, ' ', true); 8851 $sep = $this->listSeparatorForJoin($list1, $sep); 8852 $res = [Type::T_LIST, $sep, array_merge($list1[2], [$value])]; 9178 9179 switch ($this->compileStringContent($this->assertString($sep, 'separator'))) { 9180 case 'comma': 9181 $separator = ','; 9182 break; 9183 9184 case 'space': 9185 $separator = ' '; 9186 break; 9187 9188 case 'slash': 9189 $separator = '/'; 9190 break; 9191 9192 case 'auto': 9193 $separator = $list1[1] === '' && \count($list1[2]) <= 1 && (empty($list1['enclosing']) || $list1['enclosing'] === 'parent') ? ' ' : $list1[1]; 9194 break; 9195 9196 default: 9197 throw SassScriptException::forArgument('Must be "space", "comma", "slash", or "auto".', 'separator'); 9198 } 9199 9200 $res = [Type::T_LIST, $separator, array_merge($list1[2], [$value])]; 8853 9201 8854 9202 if (isset($list1['enclosing'])) { … … 8873 9221 if (! \is_null($firstList)) { 8874 9222 foreach ($firstList[2] as $key => $item) { 8875 $list = [Type::T_LIST, ' ', [$item]];9223 $list = [Type::T_LIST, ' ', [$item]]; 8876 9224 8877 9225 foreach ($argLists as $arg) { … … 9253 9601 $value['enclosing'] = 'forced_' . $value['enclosing']; 9254 9602 $force_enclosing_display = true; 9603 } elseif (! \count($value[2])) { 9604 $value['enclosing'] = 'forced_parent'; 9255 9605 } 9256 9606 … … 9376 9726 * @param array $sub 9377 9727 * 9378 * @return bool ean9728 * @return bool 9379 9729 */ 9380 9730 protected function isSuperSelector($super, $sub) … … 9457 9807 * @param array $subParts 9458 9808 * 9459 * @return bool ean9809 * @return bool 9460 9810 */ 9461 9811 protected function isSuperPart($superParts, $subParts) … … 9524 9874 $appended = []; 9525 9875 9526 foreach ($lastSelectors as $lastSelector) { 9527 $previous = $previousSelectors; 9528 9529 foreach ($lastSelector as $lastSelectorParts) { 9530 foreach ($lastSelectorParts as $lastSelectorPart) { 9531 foreach ($previous as $i => $previousSelector) { 9532 foreach ($previousSelector as $j => $previousSelectorParts) { 9533 $previous[$i][$j][] = $lastSelectorPart; 9876 foreach ($previousSelectors as $previousSelector) { 9877 foreach ($lastSelectors as $lastSelector) { 9878 $previous = $previousSelector; 9879 foreach ($previousSelector as $j => $previousSelectorParts) { 9880 foreach ($lastSelector as $lastSelectorParts) { 9881 foreach ($lastSelectorParts as $lastSelectorPart) { 9882 $previous[$j][] = $lastSelectorPart; 9534 9883 } 9535 9884 } 9536 9885 } 9537 } 9538 9539 foreach ($previous as $ps) { 9540 $appended[] = $ps; 9886 9887 $appended[] = $previous; 9541 9888 } 9542 9889 } … … 9594 9941 * used by selector-extend and selector-replace that use the same logic 9595 9942 * 9596 * @param array $selectors9597 * @param array $extendee9598 * @param array $extender9599 * @param bool ean$replace9943 * @param array $selectors 9944 * @param array $extendee 9945 * @param array $extender 9946 * @param bool $replace 9600 9947 * 9601 9948 * @return array -
wp-scss/trunk/scssphp/src/Compiler/Environment.php
r2549034 r2820106 33 33 34 34 /** 35 * @var Environment|null 36 */ 37 public $declarationScopeParent; 38 39 /** 40 * @var Environment|null 41 */ 42 public $parentStore; 43 44 /** 45 * @var array|null 46 */ 47 public $selectors; 48 49 /** 50 * @var string|null 51 */ 52 public $marker; 53 54 /** 35 55 * @var array 36 56 */ … … 43 63 44 64 /** 45 * @var int eger65 * @var int 46 66 */ 47 67 public $depth; -
wp-scss/trunk/scssphp/src/Formatter.php
r2549034 r2820106 26 26 { 27 27 /** 28 * @var int eger28 * @var int 29 29 */ 30 30 public $indentLevel; … … 61 61 62 62 /** 63 * @var bool ean63 * @var bool 64 64 */ 65 65 public $keepSemicolons; … … 71 71 72 72 /** 73 * @var int eger73 * @var int 74 74 */ 75 75 protected $currentLine; 76 76 77 77 /** 78 * @var int eger78 * @var int 79 79 */ 80 80 protected $currentColumn; … … 240 240 * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block 241 241 * 242 * @return bool ean242 * @return bool 243 243 */ 244 244 protected function testEmptyChildren($block) -
wp-scss/trunk/scssphp/src/Formatter/Compressed.php
r2549034 r2820106 51 51 if (substr($line, 0, 2) === '/*' && substr($line, 2, 1) !== '!') { 52 52 unset($block->lines[$index]); 53 } elseif (substr($line, 0, 3) === '/*!') {54 $block->lines[$index] = '/*' . substr($line, 3);55 53 } 56 54 } -
wp-scss/trunk/scssphp/src/Formatter/Nested.php
r2549034 r2820106 28 28 { 29 29 /** 30 * @var int eger30 * @var int 31 31 */ 32 32 private $depth; … … 222 222 * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block 223 223 * 224 * @return bool ean224 * @return bool 225 225 */ 226 226 private function hasFlatChild($block) -
wp-scss/trunk/scssphp/src/Formatter/OutputBlock.php
r2549034 r2820106 28 28 29 29 /** 30 * @var int eger30 * @var int 31 31 */ 32 32 public $depth; … … 58 58 59 59 /** 60 * @var int eger|null60 * @var int|null 61 61 */ 62 62 public $sourceLine; 63 63 64 64 /** 65 * @var int eger|null65 * @var int|null 66 66 */ 67 67 public $sourceColumn; -
wp-scss/trunk/scssphp/src/Node.php
r2549034 r2820106 28 28 29 29 /** 30 * @var int eger30 * @var int 31 31 */ 32 32 public $sourceIndex; -
wp-scss/trunk/scssphp/src/Node/Number.php
r2549034 r2820106 39 39 40 40 /** 41 * @var int eger41 * @var int 42 42 * @deprecated use {Number::PRECISION} instead to read the precision. Configuring it is not supported anymore. 43 43 */ … … 82 82 83 83 /** 84 * @var int eger|float84 * @var int|float 85 85 */ 86 86 private $dimension; … … 101 101 * Initialize number 102 102 * 103 * @param int eger|float$dimension103 * @param int|float $dimension 104 104 * @param string[]|string $numeratorUnits 105 105 * @param string[] $denominatorUnits … … 148 148 149 149 /** 150 * {@inheritdoc} 151 */ 150 * @return bool 151 */ 152 #[\ReturnTypeWillChange] 152 153 public function offsetExists($offset) 153 154 { … … 173 174 174 175 /** 175 * {@inheritdoc} 176 */ 176 * @return mixed 177 */ 178 #[\ReturnTypeWillChange] 177 179 public function offsetGet($offset) 178 180 { … … 199 201 200 202 /** 201 * {@inheritdoc} 202 */ 203 * @return void 204 */ 205 #[\ReturnTypeWillChange] 203 206 public function offsetSet($offset, $value) 204 207 { … … 207 210 208 211 /** 209 * {@inheritdoc} 210 */ 212 * @return void 213 */ 214 #[\ReturnTypeWillChange] 211 215 public function offsetUnset($offset) 212 216 { … … 217 221 * Returns true if the number is unitless 218 222 * 219 * @return bool ean223 * @return bool 220 224 */ 221 225 public function unitless() -
wp-scss/trunk/scssphp/src/Parser.php
r2549034 r2820106 13 13 namespace ScssPhp\ScssPhp; 14 14 15 use ScssPhp\ScssPhp\Block\AtRootBlock; 16 use ScssPhp\ScssPhp\Block\CallableBlock; 17 use ScssPhp\ScssPhp\Block\ContentBlock; 18 use ScssPhp\ScssPhp\Block\DirectiveBlock; 19 use ScssPhp\ScssPhp\Block\EachBlock; 20 use ScssPhp\ScssPhp\Block\ElseBlock; 21 use ScssPhp\ScssPhp\Block\ElseifBlock; 22 use ScssPhp\ScssPhp\Block\ForBlock; 23 use ScssPhp\ScssPhp\Block\IfBlock; 24 use ScssPhp\ScssPhp\Block\MediaBlock; 25 use ScssPhp\ScssPhp\Block\NestedPropertyBlock; 26 use ScssPhp\ScssPhp\Block\WhileBlock; 15 27 use ScssPhp\ScssPhp\Exception\ParserException; 16 28 use ScssPhp\ScssPhp\Logger\LoggerInterface; … … 126 138 * 127 139 * @param string|null $sourceName 128 * @param int eger$sourceIndex140 * @param int $sourceIndex 129 141 * @param string|null $encoding 130 142 * @param Cache|null $cache … … 306 318 * @param string|array $out 307 319 * 308 * @return bool ean320 * @return bool 309 321 */ 310 322 public function parseValue($buffer, &$out) … … 335 347 * @param bool $shouldValidate 336 348 * 337 * @return bool ean349 * @return bool 338 350 */ 339 351 public function parseSelector($buffer, &$out, $shouldValidate = true) … … 372 384 * @param string|array $out 373 385 * 374 * @return bool ean386 * @return bool 375 387 */ 376 388 public function parseMediaQueryList($buffer, &$out) … … 429 441 * go back where we started. 430 442 * 431 * @return bool ean443 * @return bool 432 444 */ 433 445 protected function parseChunk() … … 448 460 ! $this->cssOnly || $this->assertPlainCssValid(false, $s); 449 461 450 $atRoot = $this->pushSpecialBlock(Type::T_AT_ROOT, $s); 462 $atRoot = new AtRootBlock(); 463 $this->registerPushedBlock($atRoot, $s); 451 464 $atRoot->selector = $selector; 452 465 $atRoot->with = $with; … … 462 475 $this->matchChar('{', false) 463 476 ) { 464 $media = $this->pushSpecialBlock(Type::T_MEDIA, $s); 477 $media = new MediaBlock(); 478 $this->registerPushedBlock($media, $s); 465 479 $media->queryList = $mediaQueryList[2]; 466 480 … … 478 492 ! $this->cssOnly || $this->assertPlainCssValid(false, $s); 479 493 480 $mixin = $this->pushSpecialBlock(Type::T_MIXIN, $s); 494 $mixin = new CallableBlock(Type::T_MIXIN); 495 $this->registerPushedBlock($mixin, $s); 481 496 $mixin->name = $mixinName; 482 497 $mixin->args = $args; … … 510 525 511 526 if (! empty($hasBlock)) { 512 $include = $this->pushSpecialBlock(Type::T_INCLUDE, $s); 527 $include = new ContentBlock(); 528 $this->registerPushedBlock($include, $s); 513 529 $include->child = $child; 514 530 } else { … … 600 616 ! $this->cssOnly || $this->assertPlainCssValid(false, $s); 601 617 602 $func = $this->pushSpecialBlock(Type::T_FUNCTION, $s); 618 $func = new CallableBlock(Type::T_FUNCTION); 619 $this->registerPushedBlock($func, $s); 603 620 $func->name = $fnName; 604 621 $func->args = $args; … … 632 649 ! $this->cssOnly || $this->assertPlainCssValid(false, $s); 633 650 634 $each = $this->pushSpecialBlock(Type::T_EACH, $s); 651 $each = new EachBlock(); 652 $this->registerPushedBlock($each, $s); 635 653 636 654 foreach ($varNames[2] as $varName) { … … 661 679 } 662 680 663 $while = $this->pushSpecialBlock(Type::T_WHILE, $s); 681 $while = new WhileBlock(); 682 $this->registerPushedBlock($while, $s); 664 683 $while->cond = $cond; 665 684 … … 681 700 ! $this->cssOnly || $this->assertPlainCssValid(false, $s); 682 701 683 $for = $this->pushSpecialBlock(Type::T_FOR, $s); 702 $for = new ForBlock(); 703 $this->registerPushedBlock($for, $s); 684 704 $for->var = $varName[1]; 685 705 $for->start = $start; … … 698 718 ! $this->cssOnly || $this->assertPlainCssValid(false, $s); 699 719 700 $if = $this->pushSpecialBlock(Type::T_IF, $s); 720 $if = new IfBlock(); 721 $this->registerPushedBlock($if, $s); 701 722 702 723 while ( … … 777 798 if (isset($last) && $last[0] === Type::T_IF) { 778 799 list(, $if) = $last; 800 assert($if instanceof IfBlock); 779 801 780 802 if ($this->literal('@else', 5)) { 781 803 if ($this->matchChar('{', false)) { 782 $else = $this->pushSpecialBlock(Type::T_ELSE, $s);804 $else = new ElseBlock(); 783 805 } elseif ( 784 806 $this->literal('if', 2) && 785 807 $this->functionCallArgumentsList($cond, false, '{', false) 786 808 ) { 787 $else = $this->pushSpecialBlock(Type::T_ELSEIF, $s);809 $else = new ElseifBlock(); 788 810 $else->cond = $cond; 789 811 } 790 812 791 813 if (isset($else)) { 792 $ else->dontAppend = true;814 $this->registerPushedBlock($else, $s); 793 815 $if->cases[] = $else; 794 816 … … 828 850 ($t2 = $this->matchChar('{', false)) 829 851 ) { 830 $directive = $this->pushSpecialBlock(Type::T_DIRECTIVE, $s); 852 $directive = new DirectiveBlock(); 853 $this->registerPushedBlock($directive, $s); 831 854 $directive->name = 'supports'; 832 855 $directive->value = $supportQuery; … … 849 872 } 850 873 if ($dirName === 'media') { 851 $directive = $this->pushSpecialBlock(Type::T_MEDIA, $s);874 $directive = new MediaBlock(); 852 875 } else { 853 $directive = $this->pushSpecialBlock(Type::T_DIRECTIVE, $s);876 $directive = new DirectiveBlock(); 854 877 $directive->name = $dirName; 855 878 } 879 $this->registerPushedBlock($directive, $s); 856 880 857 881 if (isset($dirValue)) { … … 1029 1053 ! $this->cssOnly || $this->assertPlainCssValid(false); 1030 1054 1031 $propBlock = $this->pushSpecialBlock(Type::T_NESTED_PROPERTY, $s); 1055 $propBlock = new NestedPropertyBlock(); 1056 $this->registerPushedBlock($propBlock, $s); 1032 1057 $propBlock->prefix = $name; 1033 1058 $propBlock->hasValue = $foundSomething; … … 1055 1080 } 1056 1081 1057 if ( isset($block->type) && $block->type === Type::T_INCLUDE) {1082 if ($block instanceof ContentBlock) { 1058 1083 $include = $block->child; 1084 assert(\is_array($include)); 1059 1085 unset($block->child); 1060 1086 $include[3] = $block; 1061 1087 $this->append($include, $s); 1062 } elseif ( empty($block->dontAppend)) {1088 } elseif (!$block instanceof ElseBlock && !$block instanceof ElseifBlock) { 1063 1089 $type = isset($block->type) ? $block->type : Type::T_BLOCK; 1064 1090 $this->append([$type, $block], $s); … … 1089 1115 * 1090 1116 * @param array|null $selectors 1091 * @param int eger$pos1117 * @param int $pos 1092 1118 * 1093 1119 * @return Block … … 1095 1121 protected function pushBlock($selectors, $pos = 0) 1096 1122 { 1123 $b = new Block(); 1124 $b->selectors = $selectors; 1125 1126 $this->registerPushedBlock($b, $pos); 1127 1128 return $b; 1129 } 1130 1131 /** 1132 * @param Block $b 1133 * @param int $pos 1134 * 1135 * @return void 1136 */ 1137 private function registerPushedBlock(Block $b, $pos) 1138 { 1097 1139 list($line, $column) = $this->getSourcePosition($pos); 1098 1140 1099 $b = new Block();1100 1141 $b->sourceName = $this->sourceName; 1101 1142 $b->sourceLine = $line; 1102 1143 $b->sourceColumn = $column; 1103 1144 $b->sourceIndex = $this->sourceIndex; 1104 $b->selectors = $selectors;1105 1145 $b->comments = []; 1106 1146 $b->parent = $this->env; … … 1127 1167 } 1128 1168 } 1129 1130 return $b;1131 1169 } 1132 1170 … … 1134 1172 * Push special (named) block onto parse tree 1135 1173 * 1174 * @deprecated 1175 * 1136 1176 * @param string $type 1137 * @param int eger$pos1177 * @param int $pos 1138 1178 * 1139 1179 * @return Block … … 1184 1224 * Peek input stream 1185 1225 * 1186 * @param string $regex1187 * @param array $out1188 * @param int eger$from1189 * 1190 * @return int eger1226 * @param string $regex 1227 * @param array $out 1228 * @param int $from 1229 * 1230 * @return int 1191 1231 */ 1192 1232 protected function peek($regex, &$out, $from = null) … … 1205 1245 * Seek to position in input stream (or return current position in input stream) 1206 1246 * 1207 * @param int eger$where1247 * @param int $where 1208 1248 */ 1209 1249 protected function seek($where) … … 1216 1256 * 1217 1257 * @param array|false $parsed 1218 * @param int $startPos 1258 * @param int $startPos 1259 * 1219 1260 * @throws ParserException 1220 1261 */ … … 1244 1285 /** 1245 1286 * Check a parsed element is plain CSS Valid 1287 * 1246 1288 * @param array $parsed 1289 * @param bool $allowExpression 1290 * 1247 1291 * @return bool|array 1248 1292 */ … … 1424 1468 * @param string $delim Delimiter 1425 1469 * 1426 * @return bool eanTrue if match; false otherwise1470 * @return bool True if match; false otherwise 1427 1471 */ 1428 1472 protected function matchString(&$m, $delim) … … 1460 1504 * Try to match something on head of buffer 1461 1505 * 1462 * @param string $regex1463 * @param array $out1464 * @param bool ean$eatWhitespace1465 * 1466 * @return bool ean1506 * @param string $regex 1507 * @param array $out 1508 * @param bool $eatWhitespace 1509 * 1510 * @return bool 1467 1511 */ 1468 1512 protected function match($regex, &$out, $eatWhitespace = null) … … 1490 1534 * Match a single string 1491 1535 * 1492 * @param string $char1493 * @param bool ean$eatWhitespace1494 * 1495 * @return bool ean1536 * @param string $char 1537 * @param bool $eatWhitespace 1538 * 1539 * @return bool 1496 1540 */ 1497 1541 protected function matchChar($char, $eatWhitespace = null) … … 1517 1561 * Match literal string 1518 1562 * 1519 * @param string $what1520 * @param int eger$len1521 * @param bool ean$eatWhitespace1522 * 1523 * @return bool ean1563 * @param string $what 1564 * @param int $len 1565 * @param bool $eatWhitespace 1566 * 1567 * @return bool 1524 1568 */ 1525 1569 protected function literal($what, $len, $eatWhitespace = null) … … 1545 1589 * Match some whitespace 1546 1590 * 1547 * @return bool ean1591 * @return bool 1548 1592 */ 1549 1593 protected function whitespace() … … 1581 1625 list($line, $column) = $this->getSourcePosition($this->count); 1582 1626 $file = $this->sourceName; 1583 $this->logger->warn("Unterminated interpolations in multiline comments are deprecated and will be removed in ScssPhp 2.0, in \"$file\", line $line, column $column.", true); 1627 if (!$this->discardComments) { 1628 $this->logger->warn("Unterminated interpolations in multiline comments are deprecated and will be removed in ScssPhp 2.0, in \"$file\", line $line, column $column.", true); 1629 } 1584 1630 $comment[] = substr($this->buffer, $this->count, 2); 1585 1631 … … 1642 1688 * 1643 1689 * @param array|null $statement 1644 * @param int eger$pos1690 * @param int $pos 1645 1691 */ 1646 1692 protected function append($statement, $pos = null) … … 1687 1733 * @param array $out 1688 1734 * 1689 * @return bool ean1735 * @return bool 1690 1736 */ 1691 1737 protected function mediaQueryList(&$out) … … 1699 1745 * @param array $out 1700 1746 * 1701 * @return bool ean1747 * @return bool 1702 1748 */ 1703 1749 protected function mediaQuery(&$out) … … 1753 1799 * @param array $out 1754 1800 * 1755 * @return bool ean1801 * @return bool 1756 1802 */ 1757 1803 protected function supportsQuery(&$out) … … 1886 1932 * @param array $out 1887 1933 * 1888 * @return bool ean1934 * @return bool 1889 1935 */ 1890 1936 protected function mediaExpression(&$out) … … 1919 1965 * @param array $out 1920 1966 * 1921 * @return bool ean1967 * @return bool 1922 1968 */ 1923 1969 protected function argValues(&$out) … … 1944 1990 * @param array $out 1945 1991 * 1946 * @return bool ean1992 * @return bool 1947 1993 */ 1948 1994 protected function argValue(&$out) … … 2024 2070 * Parse directive value list that considers $vars as keyword 2025 2071 * 2026 * @param array $out2027 * @param bool ean|string $endChar2028 * 2029 * @return bool ean2072 * @param array $out 2073 * @param bool|string $endChar 2074 * 2075 * @return bool 2030 2076 */ 2031 2077 protected function directiveValue(&$out, $endChar = false) … … 2088 2134 * @param array $out 2089 2135 * 2090 * @return bool ean2136 * @return bool 2091 2137 */ 2092 2138 protected function valueList(&$out) … … 2104 2150 * and not of the value list 2105 2151 * 2106 * @param $out2107 * @param bool $mandatoryEnclos2152 * @param array $out 2153 * @param bool $mandatoryEnclos 2108 2154 * @param null|string $charAfter 2109 * @param null|bool $eatWhiteSp 2155 * @param null|bool $eatWhiteSp 2156 * 2110 2157 * @return bool 2111 2158 */ … … 2144 2191 * @param array $out 2145 2192 * 2146 * @return bool ean2193 * @return bool 2147 2194 */ 2148 2195 protected function spaceList(&$out) … … 2154 2201 * Parse generic list 2155 2202 * 2156 * @param array $out2157 * @param string $parseItem The name of the method used to parse items2158 * @param string $delim2159 * @param bool ean$flatten2160 * 2161 * @return bool ean2203 * @param array $out 2204 * @param string $parseItem The name of the method used to parse items 2205 * @param string $delim 2206 * @param bool $flatten 2207 * 2208 * @return bool 2162 2209 */ 2163 2210 protected function genericList(&$out, $parseItem, $delim = '', $flatten = true) … … 2255 2302 * Parse expression 2256 2303 * 2257 * @param array $out2258 * @param bool ean$listOnly2259 * @param bool ean$lookForExp2260 * 2261 * @return bool ean2304 * @param array $out 2305 * @param bool $listOnly 2306 * @param bool $lookForExp 2307 * 2308 * @return bool 2262 2309 */ 2263 2310 protected function expression(&$out, $listOnly = false, $lookForExp = true) … … 2321 2368 * 2322 2369 * @param array $out 2323 * @param int eger$s2370 * @param int $s 2324 2371 * @param string $closingParen 2325 2372 * @param array $allowedTypes 2326 2373 * 2327 * @return bool ean2374 * @return bool 2328 2375 */ 2329 2376 protected function enclosedExpression(&$out, $s, $closingParen = ')', $allowedTypes = [Type::T_LIST, Type::T_MAP]) … … 2380 2427 * Parse left-hand side of subexpression 2381 2428 * 2382 * @param array $lhs2383 * @param int eger$minP2429 * @param array $lhs 2430 * @param int $minP 2384 2431 * 2385 2432 * @return array … … 2416 2463 } 2417 2464 2418 // peek and see if rhs belongs to next operator 2419 if ($this->peek($operators, $next) && static::$precedence[$next[1]] > static::$precedence[$op]) { 2420 $rhs = $this->expHelper($rhs, static::$precedence[$next[1]]); 2421 } 2465 // consume higher-precedence operators on the right-hand side 2466 $rhs = $this->expHelper($rhs, static::$precedence[$op] + 1); 2422 2467 2423 2468 $lhs = [Type::T_EXPRESSION, $op, $lhs, $rhs, $this->inParens, $whiteBefore, $whiteAfter]; … … 2438 2483 * @param array $out 2439 2484 * 2440 * @return bool ean2485 * @return bool 2441 2486 */ 2442 2487 protected function value(&$out) … … 2646 2691 * @param array $out 2647 2692 * 2648 * @return bool ean2693 * @return bool 2649 2694 */ 2650 2695 protected function parenValue(&$out) … … 2685 2730 * @param array $out 2686 2731 * 2687 * @return bool ean2732 * @return bool 2688 2733 */ 2689 2734 protected function progid(&$out) … … 2718 2763 * @param array $func 2719 2764 * 2720 * @return bool ean2765 * @return bool 2721 2766 */ 2722 2767 protected function func($name, &$func) … … 2772 2817 * @param array $out 2773 2818 * 2774 * @return bool ean2819 * @return bool 2775 2820 */ 2776 2821 protected function argumentList(&$out) … … 2817 2862 * @param array $out 2818 2863 * 2819 * @return bool ean2864 * @return bool 2820 2865 */ 2821 2866 protected function argumentDef(&$out) … … 2879 2924 * @param array $out 2880 2925 * 2881 * @return bool ean2926 * @return bool 2882 2927 */ 2883 2928 protected function map(&$out) … … 2921 2966 * @param array $out 2922 2967 * 2923 * @return bool ean2968 * @return bool 2924 2969 */ 2925 2970 protected function color(&$out) … … 2947 2992 * @param array $unit 2948 2993 * 2949 * @return bool ean2994 * @return bool 2950 2995 */ 2951 2996 protected function unit(&$unit) … … 2972 3017 * 2973 3018 * @param array $out 2974 * 2975 * @return boolean 3019 * @param bool $keepDelimWithInterpolation 3020 * 3021 * @return bool 2976 3022 */ 2977 3023 protected function string(&$out, $keepDelimWithInterpolation = false) … … 3054 3100 /** 3055 3101 * @param string $out 3056 * @param bool $inKeywords 3102 * @param bool $inKeywords 3103 * 3057 3104 * @return bool 3058 3105 */ … … 3104 3151 * Parse keyword or interpolation 3105 3152 * 3106 * @param array $out3107 * @param bool ean$restricted3108 * 3109 * @return bool ean3153 * @param array $out 3154 * @param bool $restricted 3155 * 3156 * @return bool 3110 3157 */ 3111 3158 protected function mixedKeyword(&$out, $restricted = false) … … 3148 3195 * Parse an unbounded string stopped by $end 3149 3196 * 3150 * @param string $end3151 * @param array $out3152 * @param string $nestOpen3153 * @param string $nestClose3154 * @param bool ean$rtrim3197 * @param string $end 3198 * @param array $out 3199 * @param string $nestOpen 3200 * @param string $nestClose 3201 * @param bool $rtrim 3155 3202 * @param string $disallow 3156 3203 * 3157 * @return bool ean3204 * @return bool 3158 3205 */ 3159 3206 protected function openString($end, &$out, $nestOpen = null, $nestClose = null, $rtrim = true, $disallow = null) … … 3231 3278 * 3232 3279 * @param string|array $out 3233 * @param bool ean$lookWhite save information about whitespace before and after3234 * 3235 * @return bool ean3280 * @param bool $lookWhite save information about whitespace before and after 3281 * 3282 * @return bool 3236 3283 */ 3237 3284 protected function interpolation(&$out, $lookWhite = true) … … 3288 3335 * @param array $out 3289 3336 * 3290 * @return bool ean3337 * @return bool 3291 3338 */ 3292 3339 protected function propertyName(&$out) … … 3343 3390 * @param array $out 3344 3391 * 3345 * @return bool ean3392 * @return bool 3346 3393 */ 3347 3394 protected function customProperty(&$out) … … 3401 3448 * 3402 3449 * @param array $out 3403 * @param string|bool ean$subSelector3404 * 3405 * @return bool ean3450 * @param string|bool $subSelector 3451 * 3452 * @return bool 3406 3453 */ 3407 3454 protected function selectors(&$out, $subSelector = false) … … 3437 3484 * 3438 3485 * @param array $out 3439 * @param string|bool ean$subSelector3440 * 3441 * @return bool ean3486 * @param string|bool $subSelector 3487 * 3488 * @return bool 3442 3489 */ 3443 3490 protected function selector(&$out, $subSelector = false) … … 3495 3542 * 3496 3543 * @param string $out 3497 * @param bool $keepEscapedNumber 3544 * @param bool $keepEscapedNumber 3545 * 3498 3546 * @return bool 3499 3547 */ … … 3540 3588 * 3541 3589 * @param array $out 3542 * @param string|bool ean$subSelector3543 * 3544 * @return bool ean3590 * @param string|bool $subSelector 3591 * 3592 * @return bool 3545 3593 */ 3546 3594 protected function selectorSingle(&$out, $subSelector = false) … … 3766 3814 * @param array $out 3767 3815 * 3768 * @return bool ean3816 * @return bool 3769 3817 */ 3770 3818 protected function variable(&$out) … … 3793 3841 * Parse a keyword 3794 3842 * 3795 * @param string $word3796 * @param bool ean$eatWhitespace3797 * @param bool ean$inSelector3798 * 3799 * @return bool ean3843 * @param string $word 3844 * @param bool $eatWhitespace 3845 * @param bool $inSelector 3846 * 3847 * @return bool 3800 3848 */ 3801 3849 protected function keyword(&$word, $eatWhitespace = null, $inSelector = false) … … 3860 3908 * Parse a keyword that should not start with a number 3861 3909 * 3862 * @param string $word3863 * @param bool ean$eatWhitespace3864 * @param bool ean$inSelector3865 * 3866 * @return bool ean3910 * @param string $word 3911 * @param bool $eatWhitespace 3912 * @param bool $inSelector 3913 * 3914 * @return bool 3867 3915 */ 3868 3916 protected function restrictedKeyword(&$word, $eatWhitespace = null, $inSelector = false) … … 3884 3932 * @param string|array $placeholder 3885 3933 * 3886 * @return bool ean3934 * @return bool 3887 3935 */ 3888 3936 protected function placeholder(&$placeholder) … … 3913 3961 * @param array $out 3914 3962 * 3915 * @return bool ean3963 * @return bool 3916 3964 */ 3917 3965 protected function url(&$out) … … 3948 3996 * @param bool $eatWhitespace 3949 3997 * 3950 * @return bool ean3998 * @return bool 3951 3999 */ 3952 4000 protected function end($eatWhitespace = null) … … 4066 4114 * Get source line number and column (given character position in the buffer) 4067 4115 * 4068 * @param int eger$pos4116 * @param int $pos 4069 4117 * 4070 4118 * @return array -
wp-scss/trunk/scssphp/src/SourceMap/Base64.php
r2549034 r2820106 165 165 * Convert to base64 166 166 * 167 * @param int eger$value167 * @param int $value 168 168 * 169 169 * @return string … … 179 179 * @param string $value 180 180 * 181 * @return int eger181 * @return int 182 182 */ 183 183 public static function decode($value) -
wp-scss/trunk/scssphp/src/SourceMap/Base64VLQ.php
r2549034 r2820106 52 52 * Returns the VLQ encoded value. 53 53 * 54 * @param int eger$value54 * @param int $value 55 55 * 56 56 * @return string … … 81 81 * 82 82 * @param string $str 83 * @param int eger$index83 * @param int $index 84 84 * 85 * @return int eger85 * @return int 86 86 */ 87 87 public static function decode($str, &$index) … … 108 108 * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) 109 109 * 110 * @param int eger$value110 * @param int $value 111 111 * 112 * @return int eger112 * @return int 113 113 */ 114 114 private static function toVLQSigned($value) … … 127 127 * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 128 128 * 129 * @param int eger$value129 * @param int $value 130 130 * 131 * @return int eger131 * @return int 132 132 */ 133 133 private static function fromVLQSigned($value) -
wp-scss/trunk/scssphp/src/SourceMap/SourceMapGenerator.php
r2549034 r2820106 115 115 * Adds a mapping 116 116 * 117 * @param int eger$generatedLine The line number in generated file118 * @param int eger$generatedColumn The column number in generated file119 * @param int eger$originalLine The line number in original file120 * @param int eger$originalColumn The column number in original file121 * @param string $sourceFile The original source file117 * @param int $generatedLine The line number in generated file 118 * @param int $generatedColumn The column number in generated file 119 * @param int $originalLine The line number in original file 120 * @param int $originalColumn The column number in original file 121 * @param string $sourceFile The original source file 122 122 * 123 123 * @return void … … 327 327 * @param string $filename 328 328 * 329 * @return int eger|false329 * @return int|false 330 330 */ 331 331 protected function findFileIndex($filename) … … 363 363 * Fix windows paths 364 364 * 365 * @param string $path366 * @param bool ean$addEndSlash365 * @param string $path 366 * @param bool $addEndSlash 367 367 * 368 368 * @return string -
wp-scss/trunk/scssphp/src/Type.php
r2549034 r2820106 20 20 class Type 21 21 { 22 /** 23 * @internal 24 */ 22 25 const T_ASSIGN = 'assign'; 26 /** 27 * @internal 28 */ 23 29 const T_AT_ROOT = 'at-root'; 30 /** 31 * @internal 32 */ 24 33 const T_BLOCK = 'block'; 25 /** @deprecated */ 34 /** 35 * @deprecated 36 * @internal 37 */ 26 38 const T_BREAK = 'break'; 39 /** 40 * @internal 41 */ 27 42 const T_CHARSET = 'charset'; 28 43 const T_COLOR = 'color'; 44 /** 45 * @internal 46 */ 29 47 const T_COMMENT = 'comment'; 30 /** @deprecated */ 48 /** 49 * @deprecated 50 * @internal 51 */ 31 52 const T_CONTINUE = 'continue'; 32 /** @deprecated */ 53 /** 54 * @deprecated 55 * @internal 56 */ 33 57 const T_CONTROL = 'control'; 58 /** 59 * @internal 60 */ 34 61 const T_CUSTOM_PROPERTY = 'custom'; 62 /** 63 * @internal 64 */ 35 65 const T_DEBUG = 'debug'; 66 /** 67 * @internal 68 */ 36 69 const T_DIRECTIVE = 'directive'; 70 /** 71 * @internal 72 */ 37 73 const T_EACH = 'each'; 74 /** 75 * @internal 76 */ 38 77 const T_ELSE = 'else'; 78 /** 79 * @internal 80 */ 39 81 const T_ELSEIF = 'elseif'; 82 /** 83 * @internal 84 */ 40 85 const T_ERROR = 'error'; 86 /** 87 * @internal 88 */ 41 89 const T_EXPRESSION = 'exp'; 90 /** 91 * @internal 92 */ 42 93 const T_EXTEND = 'extend'; 94 /** 95 * @internal 96 */ 43 97 const T_FOR = 'for'; 44 98 const T_FUNCTION = 'function'; 99 /** 100 * @internal 101 */ 45 102 const T_FUNCTION_REFERENCE = 'function-reference'; 103 /** 104 * @internal 105 */ 46 106 const T_FUNCTION_CALL = 'fncall'; 107 /** 108 * @internal 109 */ 47 110 const T_HSL = 'hsl'; 111 /** 112 * @internal 113 */ 48 114 const T_HWB = 'hwb'; 115 /** 116 * @internal 117 */ 49 118 const T_IF = 'if'; 119 /** 120 * @internal 121 */ 50 122 const T_IMPORT = 'import'; 123 /** 124 * @internal 125 */ 51 126 const T_INCLUDE = 'include'; 127 /** 128 * @internal 129 */ 52 130 const T_INTERPOLATE = 'interpolate'; 131 /** 132 * @internal 133 */ 53 134 const T_INTERPOLATED = 'interpolated'; 135 /** 136 * @internal 137 */ 54 138 const T_KEYWORD = 'keyword'; 55 139 const T_LIST = 'list'; 56 140 const T_MAP = 'map'; 141 /** 142 * @internal 143 */ 57 144 const T_MEDIA = 'media'; 145 /** 146 * @internal 147 */ 58 148 const T_MEDIA_EXPRESSION = 'mediaExp'; 149 /** 150 * @internal 151 */ 59 152 const T_MEDIA_TYPE = 'mediaType'; 153 /** 154 * @internal 155 */ 60 156 const T_MEDIA_VALUE = 'mediaValue'; 157 /** 158 * @internal 159 */ 61 160 const T_MIXIN = 'mixin'; 161 /** 162 * @internal 163 */ 62 164 const T_MIXIN_CONTENT = 'mixin_content'; 165 /** 166 * @internal 167 */ 63 168 const T_NESTED_PROPERTY = 'nestedprop'; 169 /** 170 * @internal 171 */ 64 172 const T_NOT = 'not'; 65 173 const T_NULL = 'null'; 66 174 const T_NUMBER = 'number'; 175 /** 176 * @internal 177 */ 67 178 const T_RETURN = 'return'; 179 /** 180 * @internal 181 */ 68 182 const T_ROOT = 'root'; 183 /** 184 * @internal 185 */ 69 186 const T_SCSSPHP_IMPORT_ONCE = 'scssphp-import-once'; 187 /** 188 * @internal 189 */ 70 190 const T_SELF = 'self'; 71 191 const T_STRING = 'string'; 192 /** 193 * @internal 194 */ 72 195 const T_UNARY = 'unary'; 196 /** 197 * @internal 198 */ 73 199 const T_VARIABLE = 'var'; 200 /** 201 * @internal 202 */ 74 203 const T_WARN = 'warn'; 204 /** 205 * @internal 206 */ 75 207 const T_WHILE = 'while'; 76 208 } -
wp-scss/trunk/scssphp/src/Util.php
r2549034 r2820106 80 80 * mb_chr() wrapper 81 81 * 82 * @param int eger$code82 * @param int $code 83 83 * 84 84 * @return string -
wp-scss/trunk/scssphp/src/Version.php
r2549034 r2820106 20 20 class Version 21 21 { 22 const VERSION = '1. 5.2';22 const VERSION = '1.10.0'; 23 23 } -
wp-scss/trunk/wp-scss.php
r2616813 r2820106 4 4 * Plugin URI: https://github.com/ConnectThink/WP-SCSS 5 5 * Description: Compiles scss files live on WordPress. 6 * Version: 2.4.06 * Version: 3.0.0 7 7 * Author: Connect Think 8 8 * Author URI: http://connectthink.com … … 45 45 46 46 if (!defined('WPSCSS_VERSION_NUM')) 47 define('WPSCSS_VERSION_NUM', ' 2.4.0');47 define('WPSCSS_VERSION_NUM', '3.0.0'); 48 48 49 49 // Add version to options table
Note: See TracChangeset
for help on using the changeset viewer.