Skip to content

Commit 5cbef5e

Browse files
author
Marius
committed
Fix AjaxNullComparisonSniff to ignore files with no doc comments
1 parent bff45d9 commit 5cbef5e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ public function process(File $phpcsFile, $stackPtr)
4747
// Make sure it is an API function. We know this by the doc comment.
4848
$commentEnd = $phpcsFile->findPrevious(T_DOC_COMMENT_CLOSE_TAG, $stackPtr);
4949
$commentStart = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, ($commentEnd - 1));
50-
$comment = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart));
50+
// If function doesn't contain any doc comments - skip it.
51+
if ($commentEnd === false || $commentStart === false) {
52+
return;
53+
}
54+
55+
$comment = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart));
5156
if (strpos($comment, '* @api') === false) {
5257
return;
5358
}

0 commit comments

Comments
 (0)