diff --git a/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php b/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php index f86fa9aef2..3914b7b8ec 100644 --- a/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php @@ -47,7 +47,12 @@ public function process(File $phpcsFile, $stackPtr) // Make sure it is an API function. We know this by the doc comment. $commentEnd = $phpcsFile->findPrevious(T_DOC_COMMENT_CLOSE_TAG, $stackPtr); $commentStart = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, ($commentEnd - 1)); - $comment = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart)); + // If function doesn't contain any doc comments - skip it. + if ($commentEnd === false || $commentStart === false) { + return; + } + + $comment = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart)); if (strpos($comment, '* @api') === false) { return; }