|
4 | 4 | namespace Spaze\PHPStan\Rules\Disallowed\Allowed; |
5 | 5 |
|
6 | 6 | use PHPStan\PhpDoc\TypeStringResolver; |
| 7 | +use PHPStan\PhpDocParser\Parser\ParserException; |
7 | 8 | use PHPStan\Type\Constant\ConstantBooleanType; |
8 | 9 | use PHPStan\Type\Constant\ConstantIntegerType; |
9 | 10 | use PHPStan\Type\Constant\ConstantStringType; |
10 | 11 | use PHPStan\Type\NullType; |
11 | 12 | use PHPStan\Type\VerbosityLevel; |
| 13 | +use Spaze\PHPStan\Rules\Disallowed\Exceptions\InvalidConfigException; |
| 14 | +use Spaze\PHPStan\Rules\Disallowed\Exceptions\InvalidTypeStringInConfigException; |
12 | 15 | use Spaze\PHPStan\Rules\Disallowed\Exceptions\UnsupportedParamTypeInConfigException; |
13 | 16 | use Spaze\PHPStan\Rules\Disallowed\Normalizer\Normalizer; |
14 | 17 | use Spaze\PHPStan\Rules\Disallowed\Params\ParamValue; |
@@ -42,7 +45,7 @@ public function __construct( |
42 | 45 | * @param array $allowed |
43 | 46 | * @phpstan-param AllowDirectivesConfig $allowed |
44 | 47 | * @return AllowedConfig |
45 | | - * @throws UnsupportedParamTypeInConfigException |
| 48 | + * @throws InvalidConfigException |
46 | 49 | */ |
47 | 50 | public function getConfig(array $allowed): AllowedConfig |
48 | 51 | { |
@@ -147,7 +150,7 @@ public function getConfig(array $allowed): AllowedConfig |
147 | 150 | * @param int|string $key |
148 | 151 | * @param int|bool|string|null|array{position:int, value?:int|bool|string, typeString?:string, name?:string} $value |
149 | 152 | * @return T |
150 | | - * @throws UnsupportedParamTypeInConfigException |
| 153 | + * @throws InvalidConfigException |
151 | 154 | */ |
152 | 155 | private function paramFactory(string $class, $key, $value): ParamValue |
153 | 156 | { |
@@ -180,7 +183,12 @@ private function paramFactory(string $class, $key, $value): ParamValue |
180 | 183 | } |
181 | 184 |
|
182 | 185 | if ($typeString) { |
183 | | - $type = $this->typeStringResolver->resolve($typeString); |
| 186 | + try { |
| 187 | + $type = $this->typeStringResolver->resolve($typeString); |
| 188 | + } catch (ParserException $e) { |
| 189 | + $hint = str_contains($typeString, '*') ? ' Wildcards are not supported in typeString.' : ''; |
| 190 | + throw new InvalidTypeStringInConfigException($typeString, $e->getMessage() . $hint, $e); |
| 191 | + } |
184 | 192 | } elseif (is_int($paramValue)) { |
185 | 193 | $type = new ConstantIntegerType($paramValue); |
186 | 194 | } elseif (is_bool($paramValue)) { |
|
0 commit comments