Skip to content

Commit 805b97c

Browse files
committed
Added @phpstan-throws support
1 parent 81642ab commit 805b97c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

SlevomatCodingStandard/Helpers/Annotation/ThrowsAnnotation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
99
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
1010
use SlevomatCodingStandard\Helpers\AnnotationTypeHelper;
11+
use function in_array;
1112
use function sprintf;
1213

1314
/**
@@ -21,7 +22,7 @@ class ThrowsAnnotation extends Annotation
2122

2223
public function __construct(string $name, int $startPointer, int $endPointer, ?string $content, ?ThrowsTagValueNode $contentNode)
2324
{
24-
if ($name !== '@throws') {
25+
if (!in_array($name, ['@throws', '@phpstan-throws'], true)) {
2526
throw new InvalidArgumentException(sprintf('Unsupported annotation %s.', $name));
2627
}
2728

SlevomatCodingStandard/Helpers/AnnotationHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ public static function getAnnotations(File $phpcsFile, int $pointer): array
297297
'@psalm-var' => VariableAnnotation::class,
298298
'@phpstan-var' => VariableAnnotation::class,
299299
'@throws' => ThrowsAnnotation::class,
300+
'@phpstan-throws' => ThrowsAnnotation::class,
300301
'@property' => PropertyAnnotation::class,
301302
'@psalm-property' => PropertyAnnotation::class,
302303
'@phpstan-property' => PropertyAnnotation::class,

0 commit comments

Comments
 (0)