Skip to content

Commit daa7ae4

Browse files
committed
SlevomatCodingStandard.Commenting.DocCommentSpacing: Fixed internal error for invalid doccomment
1 parent 83fb531 commit daa7ae4

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

SlevomatCodingStandard/Sniffs/Commenting/DocCommentSpacingSniff.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ public function process(File $phpcsFile, $docCommentOpenerPointer): void
112112

113113
$parsedDocComment = DocCommentHelper::parseDocComment($phpcsFile, $docCommentOpenerPointer);
114114

115+
if ($parsedDocComment === null) {
116+
return;
117+
}
118+
115119
$firstContentStartPointer = $parsedDocComment->getNodeStartPointer($phpcsFile, $parsedDocComment->getNode()->children[0]);
116120
$firstContentEndPointer = $parsedDocComment->getNodeEndPointer(
117121
$phpcsFile,

tests/Sniffs/Commenting/DocCommentSpacingSniffTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ public function testEmptyDocComment(): void
1313
self::assertNoSniffErrorInFile($report);
1414
}
1515

16+
public function testInvalidDocComment(): void
17+
{
18+
$report = self::checkFile(__DIR__ . '/data/docCommentSpacingInvalidDocComment.php');
19+
self::assertNoSniffErrorInFile($report);
20+
}
21+
1622
public function testInlineDocComment(): void
1723
{
1824
$report = self::checkFile(__DIR__ . '/data/docCommentSpacingInlineDocComment.php');
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
/*********
4+
* Invalid
5+
*/

0 commit comments

Comments
 (0)