Skip to content

Commit c503d73

Browse files
committed
ignore // and # comments
1 parent 5a932e3 commit c503d73

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Rules/Playground/PhpdocCommentRule.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ public function processNode(Node $node, Scope $scope): array
4141
continue;
4242
}
4343

44-
if (str_starts_with($comment->getText(), '/**')) {
45-
continue;
44+
foreach(['/**', '//', '#'] as $startTag) {
45+
if (str_starts_with($comment->getText(), $startTag)) {
46+
continue 2;
47+
}
4648
}
4749

4850
$errors[] = RuleErrorBuilder::message('Comment contains phpdoc-tag but does not start with /** tag.')

tests/PHPStan/Rules/Playground/data/comments.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ public function getBar(): FooInterface
3232
{
3333
return $this->foo;
3434
}
35+
36+
// this should not error: @var
37+
# this should not error: @var
3538
}

0 commit comments

Comments
 (0)