Skip to content

Commit

Permalink
SlevomatCodingStandard.Commenting.DocCommentSpacing: Fixed internal e…
Browse files Browse the repository at this point in the history
…rror for invalid doccomment
  • Loading branch information
kukulich committed Jul 24, 2023
1 parent 83fb531 commit daa7ae4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ public function process(File $phpcsFile, $docCommentOpenerPointer): void

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

if ($parsedDocComment === null) {
return;
}

$firstContentStartPointer = $parsedDocComment->getNodeStartPointer($phpcsFile, $parsedDocComment->getNode()->children[0]);
$firstContentEndPointer = $parsedDocComment->getNodeEndPointer(
$phpcsFile,
Expand Down
6 changes: 6 additions & 0 deletions tests/Sniffs/Commenting/DocCommentSpacingSniffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ public function testEmptyDocComment(): void
self::assertNoSniffErrorInFile($report);
}

public function testInvalidDocComment(): void
{
$report = self::checkFile(__DIR__ . '/data/docCommentSpacingInvalidDocComment.php');
self::assertNoSniffErrorInFile($report);
}

public function testInlineDocComment(): void
{
$report = self::checkFile(__DIR__ . '/data/docCommentSpacingInlineDocComment.php');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

/*********
* Invalid
*/

0 comments on commit daa7ae4

Please sign in to comment.