|
112 | 112 | * |
113 | 113 | * @link https://www.php.net/manual/en/language.attributes.overview.php |
114 | 114 | * |
115 | | - * @psalm-type RulesCache = array<int,array{0:RuleInterface,1:Attribute::TARGET_*}>|array<string,list<array{0:RuleInterface,1:Attribute::TARGET_*}>> |
| 115 | + * @psalm-type RulesCacheItem = array{0:RuleInterface,1:Attribute::TARGET_*} |
116 | 116 | */ |
117 | 117 | final class ObjectParser |
118 | 118 | { |
@@ -152,6 +152,7 @@ public function __construct( |
152 | 152 | * @var int Visibility levels the parsed properties must have. For example: public and protected only, this |
153 | 153 | * means that the rest (private ones) will be skipped. Defaults to all visibility levels (public, protected and |
154 | 154 | * private). |
| 155 | + * @psalm-var int-mask-of<ReflectionProperty::IS_*> |
155 | 156 | */ |
156 | 157 | private int $propertyVisibility = ReflectionProperty::IS_PRIVATE | |
157 | 158 | ReflectionProperty::IS_PROTECTED | |
@@ -197,7 +198,7 @@ public function __construct( |
197 | 198 | public function getRules(): array |
198 | 199 | { |
199 | 200 | if ($this->hasCacheItem('rules')) { |
200 | | - /** @psalm-var RulesCache */ |
| 201 | + /** @var array $rules */ |
201 | 202 | $rules = $this->getCacheItem('rules'); |
202 | 203 | return $this->prepareRules($rules); |
203 | 204 | } |
@@ -317,6 +318,7 @@ public function getReflectionProperties(): array |
317 | 318 | } |
318 | 319 |
|
319 | 320 | if (PHP_VERSION_ID < 80100) { |
| 321 | + /** @psalm-suppress UnusedMethodCall Need for pslam with PHP 8.1+ */ |
320 | 322 | $property->setAccessible(true); |
321 | 323 | } |
322 | 324 |
|
@@ -351,21 +353,24 @@ private function getReflectionSource(): ReflectionObject|ReflectionClass |
351 | 353 | } |
352 | 354 |
|
353 | 355 | /** |
354 | | - * @psalm-param RulesCache $source Raw rules containing additional metadata besides rule instances. |
| 356 | + * @psalm-param array $source Raw rules containing additional metadata besides rule instances. |
355 | 357 | * |
356 | 358 | * @return array<int, RuleInterface>|array<string, list<RuleInterface>> An array of rules ready to use for the |
357 | 359 | * validation. |
358 | 360 | */ |
359 | 361 | private function prepareRules(array $source): array |
360 | 362 | { |
361 | 363 | $rules = []; |
| 364 | + /** |
| 365 | + * @var mixed $data |
| 366 | + */ |
362 | 367 | foreach ($source as $key => $data) { |
363 | 368 | if (is_int($key)) { |
364 | | - /** @psalm-var array{0:RuleInterface,1:Attribute::TARGET_*} $data */ |
| 369 | + /** @psalm-var RulesCacheItem $data */ |
365 | 370 | $rules[$key] = $this->prepareRule($data[0], $data[1]); |
366 | 371 | } else { |
367 | 372 | /** |
368 | | - * @psalm-var list<array{0:RuleInterface,1:Attribute::TARGET_*}> $data |
| 373 | + * @psalm-var list<RulesCacheItem> $data |
369 | 374 | * @psalm-suppress UndefinedInterfaceMethod |
370 | 375 | */ |
371 | 376 | foreach ($data as $rule) { |
|
0 commit comments