Update composer dependencies
authorAlexander Ebert <ebert@woltlab.com>
Wed, 11 Oct 2023 10:11:37 +0000 (12:11 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 11 Oct 2023 10:11:37 +0000 (12:11 +0200)
wcfsetup/install/files/lib/system/api/composer.json
wcfsetup/install/files/lib/system/api/composer.lock
wcfsetup/install/files/lib/system/api/composer/installed.json
wcfsetup/install/files/lib/system/api/composer/installed.php
wcfsetup/install/files/lib/system/api/cuyz/valinor/composer.json
wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Exception/InvalidTypeAliasImportClass.php
wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Definition/Repository/Reflection/ReflectionTypeResolver.php
wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/Modifier/Mapping.php
wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/Modifier/PathMapping.php
wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Mapper/Source/Source.php
wcfsetup/install/files/lib/system/api/cuyz/valinor/src/Utility/Reflection/DocParser.php

index c751338e72908cf23432bd264381b8603b413026..493e4b43a55ac2f475e88444798caebe1e169985 100644 (file)
@@ -10,7 +10,7 @@
         }
     },
     "require": {
-        "cuyz/valinor": "^1.6.0",
+        "cuyz/valinor": "^1.6.1",
         "dragonmantank/cron-expression": "^3.3.3",
         "erusev/parsedown": "^1.7.4",
         "ezyang/htmlpurifier": "^4.16",
index 7f4039f6df06e43fe337cf2cf2e2ce2d5d148181..f658e6e4ce4e4c478f97bd2401ad7add66706864 100644 (file)
@@ -4,20 +4,20 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "d1b286c6264e2d8bf1223ce6243ae1a9",
+    "content-hash": "3bcdf9c6922a05444493ea682a6bce01",
     "packages": [
         {
             "name": "cuyz/valinor",
-            "version": "1.6.0",
+            "version": "1.6.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/CuyZ/Valinor.git",
-                "reference": "f3f3429d90be77f59903923f9bb5ce93c484dfd7"
+                "reference": "88c6b0f9299088de632d17610efffb54d55adba6"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/CuyZ/Valinor/zipball/f3f3429d90be77f59903923f9bb5ce93c484dfd7",
-                "reference": "f3f3429d90be77f59903923f9bb5ce93c484dfd7",
+                "url": "https://api.github.com/repos/CuyZ/Valinor/zipball/88c6b0f9299088de632d17610efffb54d55adba6",
+                "reference": "88c6b0f9299088de632d17610efffb54d55adba6",
                 "shasum": ""
             },
             "require": {
@@ -69,7 +69,7 @@
             ],
             "support": {
                 "issues": "https://github.com/CuyZ/Valinor/issues",
-                "source": "https://github.com/CuyZ/Valinor/tree/1.6.0"
+                "source": "https://github.com/CuyZ/Valinor/tree/1.6.1"
             },
             "funding": [
                 {
@@ -77,7 +77,7 @@
                     "type": "github"
                 }
             ],
-            "time": "2023-08-25T10:26:38+00:00"
+            "time": "2023-10-11T08:40:51+00:00"
         },
         {
             "name": "dragonmantank/cron-expression",
index cc67eba0437929af20332a0b2c58adfea1b6b5ec..be042169e59ed209010e94055faa1fceb1294f4f 100644 (file)
@@ -2,17 +2,17 @@
     "packages": [
         {
             "name": "cuyz/valinor",
-            "version": "1.6.0",
-            "version_normalized": "1.6.0.0",
+            "version": "1.6.1",
+            "version_normalized": "1.6.1.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/CuyZ/Valinor.git",
-                "reference": "f3f3429d90be77f59903923f9bb5ce93c484dfd7"
+                "reference": "88c6b0f9299088de632d17610efffb54d55adba6"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/CuyZ/Valinor/zipball/f3f3429d90be77f59903923f9bb5ce93c484dfd7",
-                "reference": "f3f3429d90be77f59903923f9bb5ce93c484dfd7",
+                "url": "https://api.github.com/repos/CuyZ/Valinor/zipball/88c6b0f9299088de632d17610efffb54d55adba6",
+                "reference": "88c6b0f9299088de632d17610efffb54d55adba6",
                 "shasum": ""
             },
             "require": {
@@ -32,7 +32,7 @@
                 "rector/rector": "~0.17.0",
                 "vimeo/psalm": "^5.0"
             },
-            "time": "2023-08-25T10:26:38+00:00",
+            "time": "2023-10-11T08:40:51+00:00",
             "type": "library",
             "installation-source": "dist",
             "autoload": {
@@ -66,7 +66,7 @@
             ],
             "support": {
                 "issues": "https://github.com/CuyZ/Valinor/issues",
-                "source": "https://github.com/CuyZ/Valinor/tree/1.6.0"
+                "source": "https://github.com/CuyZ/Valinor/tree/1.6.1"
             },
             "funding": [
                 {
index 1dac5164cd0b709a2cfdb3082163afa8326b8fe1..618062f92ebea26e318a03e9f876395883361736 100644 (file)
@@ -1,9 +1,9 @@
 <?php return array(
     'root' => array(
         'name' => '__root__',
-        'pretty_version' => '1.0.0+no-version-set',
-        'version' => '1.0.0.0',
-        'reference' => NULL,
+        'pretty_version' => '6.0.x-dev',
+        'version' => '6.0.9999999.9999999-dev',
+        'reference' => 'ac5b81de7a0ce3346688fb80f203204aee5390e6',
         'type' => 'project',
         'install_path' => __DIR__ . '/../',
         'aliases' => array(),
     ),
     'versions' => array(
         '__root__' => array(
-            'pretty_version' => '1.0.0+no-version-set',
-            'version' => '1.0.0.0',
-            'reference' => NULL,
+            'pretty_version' => '6.0.x-dev',
+            'version' => '6.0.9999999.9999999-dev',
+            'reference' => 'ac5b81de7a0ce3346688fb80f203204aee5390e6',
             'type' => 'project',
             'install_path' => __DIR__ . '/../',
             'aliases' => array(),
             'dev_requirement' => false,
         ),
         'cuyz/valinor' => array(
-            'pretty_version' => '1.6.0',
-            'version' => '1.6.0.0',
-            'reference' => 'f3f3429d90be77f59903923f9bb5ce93c484dfd7',
+            'pretty_version' => '1.6.1',
+            'version' => '1.6.1.0',
+            'reference' => '88c6b0f9299088de632d17610efffb54d55adba6',
             'type' => 'library',
             'install_path' => __DIR__ . '/../cuyz/valinor',
             'aliases' => array(),
index c699d5646576d187e55212c8312bd22459b44ae8..e1d6b495bc42eeaf23189c95cfa4ecc22f9dba7b 100644 (file)
@@ -69,8 +69,8 @@
         ],
         "doc": [
             "Composer\\Config::disableProcessTimeout",
-            "pip install -r docs/requirements.txt",
-            "mkdocs serve --config-file docs/mkdocs.yml"
+            "docker build -t valinor-doc ./docs",
+            "docker run --name valinor-doc --rm -it -p 8000:8000 -v ${PWD}/docs:/docs valinor-doc"
         ]
     },
     "config": {
index 8eb9f495510e1aad94259cff42f6070ac8c6595d..6175086ea6da8693cdd1ff080dd3f27417499526 100644 (file)
@@ -10,9 +10,6 @@ use LogicException;
 /** @internal */
 final class InvalidTypeAliasImportClass extends LogicException
 {
-    /**
-     * @param class-string $className
-     */
     public function __construct(ClassType $type, string $className)
     {
         parent::__construct(
index b2e5391030cc51fc99770e00c8f89e79a9a8eb3c..ef8f3568ed294e998fcc48fa5cbd881d76dfd99f 100644 (file)
@@ -8,6 +8,8 @@ use CuyZ\Valinor\Definition\Exception\TypesDoNotMatch;
 use CuyZ\Valinor\Type\Parser\Exception\InvalidType;
 use CuyZ\Valinor\Type\Parser\TypeParser;
 use CuyZ\Valinor\Type\Type;
+use CuyZ\Valinor\Type\Types\ArrayKeyType;
+use CuyZ\Valinor\Type\Types\ArrayType;
 use CuyZ\Valinor\Type\Types\MixedType;
 use CuyZ\Valinor\Type\Types\UnresolvableType;
 use CuyZ\Valinor\Utility\Reflection\DocParser;
@@ -75,7 +77,9 @@ final class ReflectionTypeResolver
             return null;
         }
 
-        return $this->parseType($type, $reflection, $this->advancedParser);
+        $type = $this->parseType($type, $reflection, $this->advancedParser);
+
+        return $this->handleVariadicType($reflection, $type);
     }
 
     private function nativeType(ReflectionProperty|ReflectionParameter|ReflectionFunctionAbstract $reflection): ?Type
@@ -89,12 +93,9 @@ final class ReflectionTypeResolver
         }
 
         $type = Reflection::flattenType($reflectionType);
+        $type = $this->parseType($type, $reflection, $this->nativeParser);
 
-        if ($reflection instanceof ReflectionParameter && $reflection->isVariadic()) {
-            $type .= '[]';
-        }
-
-        return $this->parseType($type, $reflection, $this->nativeParser);
+        return $this->handleVariadicType($reflection, $type);
     }
 
     private function parseType(string $raw, ReflectionProperty|ReflectionParameter|ReflectionFunctionAbstract $reflection, TypeParser $parser): Type
@@ -116,4 +117,13 @@ final class ReflectionTypeResolver
             return UnresolvableType::forMethodReturnType($raw, $signature, $exception);
         }
     }
+
+    private function handleVariadicType(ReflectionProperty|ReflectionParameter|ReflectionFunctionAbstract $reflection, Type $type): Type
+    {
+        if (! $reflection instanceof ReflectionParameter || ! $reflection->isVariadic()) {
+            return $type;
+        }
+
+        return new ArrayType(ArrayKeyType::default(), $type);
+    }
 }
index f3ce08cc9887dcb6afff5ae3c745b8d23e30309e..aa90a9047f072c8f874a2868e3764a30248c1479 100644 (file)
@@ -28,7 +28,7 @@ final class Mapping
     {
         $from = $this->keys[$atDepth] ?? null;
 
-        return $from === $key || $from === '*';
+        return $from === (string)$key || $from === '*';
     }
 
     public function findMappedKey(int|string $key, int $atDepth): ?string
index f487b4098de275e35e395246c0188603d129a224..71eb36d962fbb038245d432e1b0c3676c5c28d65 100644 (file)
@@ -22,7 +22,7 @@ final class PathMapping implements IteratorAggregate
 
     /**
      * @param iterable<mixed> $source
-     * @param array<string, string> $map
+     * @param array<string> $map
      */
     public function __construct(iterable $source, array $map)
     {
@@ -62,7 +62,7 @@ final class PathMapping implements IteratorAggregate
     }
 
     /**
-     * @param array<string, string> $map
+     * @param array<string> $map
      * @return array<Mapping>
      */
     private function prepareMappings(array $map): array
@@ -70,7 +70,7 @@ final class PathMapping implements IteratorAggregate
         $mappings = [];
 
         foreach ($map as $from => $to) {
-            $mappings[] = new Mapping(explode('.', $from), $to);
+            $mappings[] = new Mapping(explode('.', (string)$from), $to);
         }
 
         return $mappings;
index eb71f0f290355bae7c32b4786468a953049eed00..e327a40510d57fed158f802ac4e1a2de92f31b79 100644 (file)
@@ -66,7 +66,7 @@ final class Source implements IteratorAggregate
     }
 
     /**
-     * @param array<string, string> $map
+     * @param array<string> $map
      */
     public function map(array $map): Source
     {
index 4acc47ddc7f84ad186ae639b8dc240614a1f763f..7057e4bc325a4eb37c3c5cca3a1dc9f85a2fc145 100644 (file)
@@ -8,13 +8,16 @@ use ReflectionFunctionAbstract;
 use ReflectionParameter;
 use ReflectionProperty;
 
+use function array_merge;
 use function end;
+use function explode;
 use function preg_match;
 use function preg_match_all;
 use function str_replace;
 use function str_split;
 use function strrpos;
 use function substr;
+use function trim;
 
 /** @internal */
 final class DocParser
@@ -68,13 +71,16 @@ final class DocParser
             return [];
         }
 
+        $cases = self::splitStringBy($doc, '@phpstan-type', '@psalm-type');
+
         $types = [];
 
-        preg_match_all('/@(phpstan|psalm)-type\s+(?<name>[a-zA-Z]\w*)\s*=?\s*(?<type>.*)/', $doc, $matches);
+        foreach ($cases as $case) {
+            if (! preg_match('/\s*(?<name>[a-zA-Z]\w*)\s*=?\s*(?<type>.*)/s', $case, $matches)) {
+                continue;
+            }
 
-        foreach ($matches['name'] as $key => $name) {
-            /** @var string $name */
-            $types[$name] = self::findType($matches['type'][$key]);
+            $types[$matches['name']] = self::findType($matches['type']);
         }
 
         return $types;
@@ -82,7 +88,7 @@ final class DocParser
 
     /**
      * @param ReflectionClass<object> $reflection
-     * @return array<class-string, string[]>
+     * @return array<string, string[]>
      */
     public static function importedTypeAliases(ReflectionClass $reflection): array
     {
@@ -92,15 +98,16 @@ final class DocParser
             return [];
         }
 
-        $types = [];
+        $cases = self::splitStringBy($doc, '@phpstan-import-type', '@psalm-import-type');
 
-        preg_match_all('/@(phpstan|psalm)-import-type\s+(?<name>[a-zA-Z]\w*)\s*from\s*(?<class>\w+)/', $doc, $matches);
+        $types = [];
 
-        foreach ($matches['name'] as $key => $name) {
-            /** @var class-string $class */
-            $class = $matches['class'][$key];
+        foreach ($cases as $case) {
+            if (! preg_match('/\s*(?<name>[a-zA-Z]\w*)\s*from\s*(?<class>\w+)/', $case, $matches)) {
+                continue;
+            }
 
-            $types[$class][] = $name;
+            $types[$matches['class']][] = $matches['name'];
         }
 
         return $types;
@@ -214,4 +221,21 @@ final class DocParser
 
         return preg_replace('/^\s*\*\s*(\S*)/m', '$1', $doc); // @phpstan-ignore-line
     }
+
+    /**
+     * @param non-empty-string ...$cases
+     * @return list<string>
+     */
+    private static function splitStringBy(string $string, string ...$cases): array
+    {
+        $result = [$string];
+
+        foreach ($cases as $case) {
+            foreach ($result as $value) {
+                $result = array_merge($result, explode($case, $value));
+            }
+        }
+
+        return $result;
+    }
 }