Update composer dependencies
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 14 Dec 2021 09:24:54 +0000 (10:24 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 14 Dec 2021 09:24:54 +0000 (10:24 +0100)
wcfsetup/install/files/lib/system/api/composer.lock
wcfsetup/install/files/lib/system/api/composer/autoload_files.php
wcfsetup/install/files/lib/system/api/composer/autoload_static.php
wcfsetup/install/files/lib/system/api/composer/installed.json
wcfsetup/install/files/lib/system/api/composer/installed.php
wcfsetup/install/files/lib/system/api/scssphp/scssphp/src/Compiler.php
wcfsetup/install/files/lib/system/api/scssphp/scssphp/src/Version.php

index 0558b6e3619195342e152cf3975b7ced283e5618..ec4a2ea3c7c144baadfcaf1ef9131db3170acaea 100644 (file)
         },
         {
             "name": "scssphp/scssphp",
-            "version": "v1.8.1",
+            "version": "v1.9.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/scssphp/scssphp.git",
-                "reference": "5e37759a63caf54392a4b709358a39ac7425a69f"
+                "reference": "bc8bece4e5e176973a832f3763049ddbba16e6fd"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/scssphp/scssphp/zipball/5e37759a63caf54392a4b709358a39ac7425a69f",
-                "reference": "5e37759a63caf54392a4b709358a39ac7425a69f",
+                "url": "https://api.github.com/repos/scssphp/scssphp/zipball/bc8bece4e5e176973a832f3763049ddbba16e6fd",
+                "reference": "bc8bece4e5e176973a832f3763049ddbba16e6fd",
                 "shasum": ""
             },
             "require": {
             ],
             "support": {
                 "issues": "https://github.com/scssphp/scssphp/issues",
-                "source": "https://github.com/scssphp/scssphp/tree/v1.8.1"
+                "source": "https://github.com/scssphp/scssphp/tree/v1.9.0"
             },
-            "time": "2021-09-18T21:20:53+00:00"
+            "time": "2021-12-13T11:55:16+00:00"
         },
         {
             "name": "symfony/css-selector",
index 10fe3c682b77e9cc23333578059bd3046f0417ad..da3938bf622752cb27a42dd19ea0db094f93b17f 100644 (file)
@@ -29,7 +29,7 @@ return array(
     '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
     '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
     '2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
+    '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
     '0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
     'b686b8e46447868025a15ce5d0cb2634' => $vendorDir . '/symfony/polyfill-php74/bootstrap.php',
-    '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
 );
index fe7c1d8fdc51d152eb1fc4baba6973c14230198c..4a0a0223ba6e3626010f64d13617bb6ed0d02f48 100644 (file)
@@ -30,9 +30,9 @@ class ComposerStaticInita1f5f7c74275d47a45049a2936db1d0d
         '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
         '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
         '2cffec82183ee1cea088009cef9a6fc3' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
+        '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
         '0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php',
         'b686b8e46447868025a15ce5d0cb2634' => __DIR__ . '/..' . '/symfony/polyfill-php74/bootstrap.php',
-        '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
     );
 
     public static $prefixLengthsPsr4 = array (
index 93a9d27bf66d3d216e139f25c8c98c21f2f5b6bd..c3f8bc87f4efb257dab842352aae47b1baf9b78c 100644 (file)
         },
         {
             "name": "scssphp/scssphp",
-            "version": "v1.8.1",
-            "version_normalized": "1.8.1.0",
+            "version": "v1.9.0",
+            "version_normalized": "1.9.0.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/scssphp/scssphp.git",
-                "reference": "5e37759a63caf54392a4b709358a39ac7425a69f"
+                "reference": "bc8bece4e5e176973a832f3763049ddbba16e6fd"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/scssphp/scssphp/zipball/5e37759a63caf54392a4b709358a39ac7425a69f",
-                "reference": "5e37759a63caf54392a4b709358a39ac7425a69f",
+                "url": "https://api.github.com/repos/scssphp/scssphp/zipball/bc8bece4e5e176973a832f3763049ddbba16e6fd",
+                "reference": "bc8bece4e5e176973a832f3763049ddbba16e6fd",
                 "shasum": ""
             },
             "require": {
                 "ext-iconv": "Can be used as fallback when ext-mbstring is not available",
                 "ext-mbstring": "For best performance, mbstring should be installed as it is faster than ext-iconv"
             },
-            "time": "2021-09-18T21:20:53+00:00",
+            "time": "2021-12-13T11:55:16+00:00",
             "bin": [
                 "bin/pscss"
             ],
             ],
             "support": {
                 "issues": "https://github.com/scssphp/scssphp/issues",
-                "source": "https://github.com/scssphp/scssphp/tree/v1.8.1"
+                "source": "https://github.com/scssphp/scssphp/tree/v1.9.0"
             },
             "install-path": "../scssphp/scssphp"
         },
index 41a66f1aecf9d28d60c769d6e9fc9a1aed73dadc..9f696f660e6d52a06ea8278ca8ae1b849d47e3e1 100644 (file)
             'dev_requirement' => false,
         ),
         'scssphp/scssphp' => array(
-            'pretty_version' => 'v1.8.1',
-            'version' => '1.8.1.0',
+            'pretty_version' => 'v1.9.0',
+            'version' => '1.9.0.0',
             'type' => 'library',
             'install_path' => __DIR__ . '/../scssphp/scssphp',
             'aliases' => array(),
-            'reference' => '5e37759a63caf54392a4b709358a39ac7425a69f',
+            'reference' => 'bc8bece4e5e176973a832f3763049ddbba16e6fd',
             'dev_requirement' => false,
         ),
         'symfony/css-selector' => array(
index 58ba795ab8da97d83790a380954f620634cef021..d17d9f261ed0e13ea3a1d0b31da85da5de87a7c0 100644 (file)
@@ -137,6 +137,7 @@ class Compiler
     public static $emptyString  = [Type::T_STRING, '"', []];
     public static $with         = [Type::T_KEYWORD, 'with'];
     public static $without      = [Type::T_KEYWORD, 'without'];
+    private static $emptyArgumentList = [Type::T_LIST, '', [], []];
 
     /**
      * @var array<int, string|callable>
@@ -1587,6 +1588,8 @@ class Compiler
      * @param array $withCondition
      *
      * @return array
+     *
+     * @phpstan-return array{array<string, bool>, array<string, bool>}
      */
     protected function compileWith($withCondition)
     {
@@ -1606,9 +1609,10 @@ class Compiler
                 }
             }
 
-            if ($this->mapHasKey($withCondition, static::$with)) {
+            $withConfig = $this->mapGet($withCondition, static::$with);
+            if ($withConfig !== null) {
                 $without = []; // cancel the default
-                $list = $this->coerceList($this->libMapGet([$withCondition, static::$with]));
+                $list = $this->coerceList($withConfig);
 
                 foreach ($list[2] as $item) {
                     $keyword = $this->compileStringContent($this->coerceString($item));
@@ -1617,9 +1621,10 @@ class Compiler
                 }
             }
 
-            if ($this->mapHasKey($withCondition, static::$without)) {
+            $withoutConfig = $this->mapGet($withCondition, static::$without);
+            if ($withoutConfig !== null) {
                 $without = []; // cancel the default
-                $list = $this->coerceList($this->libMapGet([$withCondition, static::$without]));
+                $list = $this->coerceList($withoutConfig);
 
                 foreach ($list[2] as $item) {
                     $keyword = $this->compileStringContent($this->coerceString($item));
@@ -6929,14 +6934,18 @@ EOL;
     }
 
     /**
-     * Coerce something to map
+     * Tries to convert an item to a Sass map
      *
-     * @param array|Number $item
+     * @param Number|array $item
      *
-     * @return array|Number
+     * @return array|null
      */
-    protected function coerceMap($item)
+    private function tryMap($item)
     {
+        if ($item instanceof Number) {
+            return null;
+        }
+
         if ($item[0] === Type::T_MAP) {
             return $item;
         }
@@ -6948,6 +6957,24 @@ EOL;
             return static::$emptyMap;
         }
 
+        return null;
+    }
+
+    /**
+     * Coerce something to map
+     *
+     * @param array|Number $item
+     *
+     * @return array|Number
+     */
+    protected function coerceMap($item)
+    {
+        $map = $this->tryMap($item);
+
+        if ($map !== null) {
+            return $map;
+        }
+
         return $item;
     }
 
@@ -6984,18 +7011,6 @@ EOL;
                 $key = $keys[$i];
                 $value = $values[$i];
 
-                switch ($key[0]) {
-                    case Type::T_LIST:
-                    case Type::T_MAP:
-                    case Type::T_STRING:
-                    case Type::T_NULL:
-                        break;
-
-                    default:
-                        $key = [Type::T_KEYWORD, $this->compileStringContent($this->coerceString($key))];
-                        break;
-                }
-
                 $list[] = [
                     Type::T_LIST,
                     '',
@@ -7294,15 +7309,15 @@ EOL;
      */
     public function assertMap($value, $varName = null)
     {
-        $value = $this->coerceMap($value);
+        $map = $this->tryMap($value);
 
-        if ($value[0] !== Type::T_MAP) {
+        if ($map === null) {
             $value = $this->compileValue($value);
 
             throw SassScriptException::forArgument("$value is not a map.", $varName);
         }
 
-        return $value;
+        return $map;
     }
 
     /**
@@ -8696,23 +8711,72 @@ will be an error in future versions of Sass.\n         on line $line of $fname";
         return $list;
     }
 
-    protected static $libMapGet = ['map', 'key'];
+    protected static $libMapGet = ['map', 'key', 'keys...'];
     protected function libMapGet($args)
     {
         $map = $this->assertMap($args[0], 'map');
-        $key = $args[1];
+        if (!isset($args[2])) {
+            // BC layer for usages of the function from PHP code rather than from the Sass function
+            $args[2] = self::$emptyArgumentList;
+        }
+        $keys = array_merge([$args[1]], $args[2][2]);
+        $value = static::$null;
+
+        foreach ($keys as $key) {
+            if (!\is_array($map) || $map[0] !== Type::T_MAP) {
+                return static::$null;
+            }
 
-        if (! \is_null($key)) {
-            $key = $this->compileStringContent($this->coerceString($key));
+            $map = $this->mapGet($map, $key);
 
-            for ($i = \count($map[1]) - 1; $i >= 0; $i--) {
-                if ($key === $this->compileStringContent($this->coerceString($map[1][$i]))) {
-                    return $map[2][$i];
-                }
+            if ($map === null) {
+                return static::$null;
             }
+
+            $value = $map;
         }
 
-        return static::$null;
+        return $value;
+    }
+
+    /**
+     * Gets the value corresponding to that key in the map
+     *
+     * @param array        $map
+     * @param Number|array $key
+     *
+     * @return Number|array|null
+     */
+    private function mapGet(array $map, $key)
+    {
+        $index = $this->mapGetEntryIndex($map, $key);
+
+        if ($index !== null) {
+            return $map[2][$index];
+        }
+
+        return null;
+    }
+
+    /**
+     * Gets the index corresponding to that key in the map entries
+     *
+     * @param array        $map
+     * @param Number|array $key
+     *
+     * @return int|null
+     */
+    private function mapGetEntryIndex(array $map, $key)
+    {
+        $key = $this->compileStringContent($this->coerceString($key));
+
+        for ($i = \count($map[1]) - 1; $i >= 0; $i--) {
+            if ($key === $this->compileStringContent($this->coerceString($map[1][$i]))) {
+                return $i;
+            }
+        }
+
+        return null;
     }
 
     protected static $libMapKeys = ['map'];
@@ -8762,12 +8826,28 @@ will be an error in future versions of Sass.\n         on line $line of $fname";
         return $map;
     }
 
-    protected static $libMapHasKey = ['map', 'key'];
+    protected static $libMapHasKey = ['map', 'key', 'keys...'];
     protected function libMapHasKey($args)
     {
         $map = $this->assertMap($args[0], 'map');
+        if (!isset($args[2])) {
+            // BC layer for usages of the function from PHP code rather than from the Sass function
+            $args[2] = self::$emptyArgumentList;
+        }
+        $keys = array_merge([$args[1]], $args[2][2]);
+        $lastKey = array_pop($keys);
+
+        foreach ($keys as $key) {
+            $value = $this->mapGet($map, $key);
+
+            if ($value === null || $value instanceof Number || $value[0] !== Type::T_MAP) {
+                return self::$false;
+            }
 
-        return $this->toBool($this->mapHasKey($map, $args[1]));
+            $map = $value;
+        }
+
+        return $this->toBool($this->mapHasKey($map, $lastKey));
     }
 
     /**
@@ -8790,24 +8870,127 @@ will be an error in future versions of Sass.\n         on line $line of $fname";
 
     protected static $libMapMerge = [
         ['map1', 'map2'],
-        ['map-1', 'map-2']
+        ['map-1', 'map-2'],
+        ['map1', 'args...']
     ];
     protected function libMapMerge($args)
     {
         $map1 = $this->assertMap($args[0], 'map1');
-        $map2 = $this->assertMap($args[1], 'map2');
+        $map2 = $args[1];
+        $keys = [];
+        if ($map2[0] === Type::T_LIST && isset($map2[3]) && \is_array($map2[3])) {
+            // This is an argument list for the variadic signature
+            if (\count($map2[2]) === 0) {
+                throw new SassScriptException('Expected $args to contain a key.');
+            }
+            if (\count($map2[2]) === 1) {
+                throw new SassScriptException('Expected $args to contain a value.');
+            }
+            $keys = $map2[2];
+            $map2 = array_pop($keys);
+        }
+        $map2 = $this->assertMap($map2, 'map2');
+
+        return $this->modifyMap($map1, $keys, function ($oldValue) use ($map2) {
+            $nestedMap = $this->tryMap($oldValue);
+
+            if ($nestedMap === null) {
+                return $map2;
+            }
+
+            return $this->mergeMaps($nestedMap, $map2);
+        });
+    }
+
+    /**
+     * @param array    $map
+     * @param array    $keys
+     * @param callable $modify
+     * @param bool     $addNesting
+     *
+     * @return Number|array
+     *
+     * @phpstan-param array<Number|array> $keys
+     * @phpstan-param callable(Number|array): (Number|array) $modify
+     */
+    private function modifyMap(array $map, array $keys, callable $modify, $addNesting = true)
+    {
+        if ($keys === []) {
+            return $modify($map);
+        }
+
+        return $this->modifyNestedMap($map, $keys, $modify, $addNesting);
+    }
+
+    /**
+     * @param array    $map
+     * @param array    $keys
+     * @param callable $modify
+     * @param bool     $addNesting
+     *
+     * @return array
+     *
+     * @phpstan-param non-empty-array<Number|array> $keys
+     * @phpstan-param callable(Number|array): (Number|array) $modify
+     */
+    private function modifyNestedMap(array $map, array $keys, callable $modify, $addNesting)
+    {
+        $key = array_shift($keys);
+
+        $nestedValueIndex = $this->mapGetEntryIndex($map, $key);
+
+        if ($keys === []) {
+            if ($nestedValueIndex !== null) {
+                $map[2][$nestedValueIndex] = $modify($map[2][$nestedValueIndex]);
+            } else {
+                $map[1][] = $key;
+                $map[2][] = $modify(self::$null);
+            }
+
+            return $map;
+        }
+
+        $nestedMap = $nestedValueIndex !== null ? $this->tryMap($map[2][$nestedValueIndex]) : null;
+
+        if ($nestedMap === null && !$addNesting) {
+            return $map;
+        }
+
+        if ($nestedMap === null) {
+            $nestedMap = self::$emptyMap;
+        }
+
+        $newNestedMap = $this->modifyNestedMap($nestedMap, $keys, $modify, $addNesting);
+
+        if ($nestedValueIndex !== null) {
+            $map[2][$nestedValueIndex] = $newNestedMap;
+        } else {
+            $map[1][] = $key;
+            $map[2][] = $newNestedMap;
+        }
+
+        return $map;
+    }
 
+    /**
+     * Merges 2 Sass maps together
+     *
+     * @param array $map1
+     * @param array $map2
+     *
+     * @return array
+     */
+    private function mergeMaps(array $map1, array $map2)
+    {
         foreach ($map2[1] as $i2 => $key2) {
-            $key = $this->compileStringContent($this->coerceString($key2));
+            $map1EntryIndex = $this->mapGetEntryIndex($map1, $key2);
 
-            foreach ($map1[1] as $i1 => $key1) {
-                if ($key === $this->compileStringContent($this->coerceString($key1))) {
-                    $map1[2][$i1] = $map2[2][$i2];
-                    continue 2;
-                }
+            if ($map1EntryIndex !== null) {
+                $map1[2][$map1EntryIndex] = $map2[2][$i2];
+                continue;
             }
 
-            $map1[1][] = $map2[1][$i2];
+            $map1[1][] = $key2;
             $map1[2][] = $map2[2][$i2];
         }
 
index 62c8006a124a6f11004fa64ea833b66b82ddcff8..be6a31037af7029ec7157ce4ff35160ad115d85c 100644 (file)
@@ -19,5 +19,5 @@ namespace ScssPhp\ScssPhp;
  */
 class Version
 {
-    const VERSION = '1.8.1';
+    const VERSION = '1.9.0';
 }