3 declare(strict_types=1);
5 namespace CuyZ\Valinor\Type\Parser\Exception\Generic;
7 use CuyZ\Valinor\Type\Parser\Exception\InvalidType;
8 use CuyZ\Valinor\Type\Type;
11 use function array_fill;
12 use function array_map;
17 final class MissingGenerics extends RuntimeException implements InvalidType
20 * @param class-string $className
21 * @param Type[] $generics
22 * @param Type[] $templates
24 public function __construct(string $className, array $generics, array $templates)
26 /** @var positive-int $missing */
27 $missing = count($templates) - count($generics);
28 $generics = array_map(fn (Type $type) => $type->toString(), $generics);
29 $generics += array_fill(count($generics), $missing, '?');
31 $signature = $className . '<' . implode(', ', $generics) . '>';
34 "There are $missing missing generics for `$signature`.",