|
28 | 28 | use PHPStan\PhpDoc\Tag\UsesTag; |
29 | 29 | use PHPStan\PhpDoc\Tag\VarTag; |
30 | 30 | use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNullNode; |
31 | | -use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode; |
32 | 31 | use PHPStan\PhpDocParser\Ast\PhpDoc\MixinTagValueNode; |
33 | 32 | use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode; |
34 | 33 | use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode; |
|
48 | 47 | use function array_reverse; |
49 | 48 | use function count; |
50 | 49 | use function in_array; |
51 | | -use function ltrim; |
52 | 50 | use function method_exists; |
53 | 51 | use function str_starts_with; |
54 | | -use function strpos; |
55 | 52 | use function substr; |
56 | 53 |
|
57 | 54 | #[AutowiredService] |
@@ -412,33 +409,9 @@ public function resolveParamPureUnlessCallableIsImpure(PhpDocNode $phpDocNode): |
412 | 409 | public function resolveParamPureUnlessParameterPassed(PhpDocNode $phpDocNode): array |
413 | 410 | { |
414 | 411 | $parameters = []; |
415 | | - // TODO: replace this generic-tag parsing with |
416 | | - // $phpDocNode->getPureUnlessParameterIsPassedTagValues() once |
417 | | - // phpstan/phpdoc-parser#259 is merged and the parser understands the tag. |
418 | 412 | foreach (['@pure-unless-parameter-passed', '@phpstan-pure-unless-parameter-passed'] as $tagName) { |
419 | | - foreach ($phpDocNode->getTags() as $tag) { |
420 | | - if ($tag->name !== $tagName) { |
421 | | - continue; |
422 | | - } |
423 | | - if (!$tag->value instanceof GenericTagValueNode) { |
424 | | - continue; |
425 | | - } |
426 | | - |
427 | | - $value = ltrim($tag->value->value); |
428 | | - if ($value === '' || $value[0] !== '$') { |
429 | | - continue; |
430 | | - } |
431 | | - |
432 | | - $parameterName = substr($value, 1); |
433 | | - $spacePosition = strpos($parameterName, ' '); |
434 | | - if ($spacePosition !== false) { |
435 | | - $parameterName = substr($parameterName, 0, $spacePosition); |
436 | | - } |
437 | | - |
438 | | - if ($parameterName === '') { |
439 | | - continue; |
440 | | - } |
441 | | - |
| 413 | + foreach ($phpDocNode->getPureUnlessParameterIsPassedTagValues($tagName) as $tag) { |
| 414 | + $parameterName = substr($tag->parameterName, 1); |
442 | 415 | $parameters[$parameterName] = true; |
443 | 416 | } |
444 | 417 | } |
|
0 commit comments