Do not crash if comment is missing completely
This commit is contained in:
parent
51ef90ecac
commit
2478c0f3ff
2 changed files with 13 additions and 2 deletions
|
@ -22,8 +22,15 @@ class VariableCommentSniff extends \PHP_CodeSniffer\Standards\Squiz\Sniffs\Comme
|
|||
];
|
||||
|
||||
$commentEnd = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
|
||||
|
||||
|
||||
// this error is copied from above, as it comes with a needed early return
|
||||
if (
|
||||
$commentEnd === false
|
||||
|| ($tokens[$commentEnd]['code'] !== \T_DOC_COMMENT_CLOSE_TAG
|
||||
&& $tokens[$commentEnd]['code'] !== \T_COMMENT)
|
||||
) {
|
||||
$phpcsFile->addError('Missing member variable doc comment', $stackPtr, 'Missing');
|
||||
return;
|
||||
}
|
||||
$commentStart = $tokens[$commentEnd]['comment_opener'];
|
||||
|
||||
$foundVar = null;
|
||||
|
|
|
@ -20,3 +20,7 @@ class C extends A {
|
|||
*/
|
||||
protected $var;
|
||||
}
|
||||
|
||||
class D extends a {
|
||||
protected $var;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue