Repository: CuyZ/Valinor (php)

Issue:
Issue with variadic parameter contains generics
After upgrade from 1.7 to 1.12, my code broke even though I didn't make any changes. I was using [`ramsey/collection`](https://github.com/ramsey/collection/) for my DTO. `UnresolvableType` was thrown, but there was no specific error message provided. After further debugging, I believe this is the cause of the error.

![image](https://github.com/CuyZ/Valinor/assets/1808758/2e244374-d7bf-4225-b9c5-b2413e36cf64)

This is the docblock of `merge` method which I'm not use anyway.

```php
/**
 * @param CollectionInterface<T> ...$collections The collections to merge.
 *
 * @return CollectionInterface<T>
 *
 * @throws CollectionMismatchException if unable to merge any of the given
 *     collections or items within the given collections due to type
 *     mismatch errors.
 */
public function merge(CollectionInterface ...$collections): CollectionInterface
```

Pull request description:
fix: do not override invalid variadic parameter type
Fixes #533 

Patch:
diff --git a/src/Definition/Repository/Reflection/TypeResolver/ParameterTypeResolver.php b/src/Definition/Repository/Reflection/TypeResolver/ParameterTypeResolver.php
index bab24b0..0a73282 100644
--- a/src/Definition/Repository/Reflection/TypeResolver/ParameterTypeResolver.php
+++ b/src/Definition/Repository/Reflection/TypeResolver/ParameterTypeResolver.php
@@ -8,6 +8,7 @@ use CuyZ\Valinor\Type\Parser\Lexer\Annotations;
 use CuyZ\Valinor\Type\Type;
 use CuyZ\Valinor\Type\Types\ArrayKeyType;
 use CuyZ\Valinor\Type\Types\ArrayType;
+use CuyZ\Valinor\Type\Types\UnresolvableType;
 use ReflectionParameter;
 
 /** @internal */
@@ -32,7 +33,7 @@ final class ParameterTypeResolver
 
         $type = $this->typeResolver->resolveType($reflection->getType(), $docBlockType);
 
-        if ($reflection->isVariadic()) {
+        if ($reflection->isVariadic() && ! $type instanceof UnresolvableType) {
             return new ArrayType(ArrayKeyType::default(), $type);
         }
 


Test patch:
diff --git a/tests/Functional/Definition/Repository/Reflection/TypeResolver/ParameterTypeResolverTest.php b/tests/Functional/Definition/Repository/Reflection/TypeResolver/ParameterTypeResolverTest.php
index aad55e8..7284965 100644
--- a/tests/Functional/Definition/Repository/Reflection/TypeResolver/ParameterTypeResolverTest.php
+++ b/tests/Functional/Definition/Repository/Reflection/TypeResolver/ParameterTypeResolverTest.php
@@ -154,4 +154,19 @@ final class ParameterTypeResolverTest extends TestCase
             'string',
         ];
     }
+
+    public function test_invalid_parameter_type_stays_invalid_when_variadic(): void
+    {
+        $reflection = new ReflectionParameter(
+            /**
+             * @param InvalidValue $value
+             */
+            static function (...$value): void {},
+            'value',
+        );
+
+        $type = $this->resolver->resolveTypeFor($reflection);
+
+        self::assertInstanceOf(UnresolvableType::class, $type);
+    }
 }