Skip to content

Commit

Permalink
If __construct has no doc block then return early
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan1055 committed Nov 10, 2023
1 parent ea46008 commit 4261827
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ public function process(File $phpcsFile, $stackPtr)
break;
}

// Constructor methods are exempt from requiring a docblock.
// @see https://www.drupal.org/project/coder/issues/3400560
$methodName = $phpcsFile->getDeclarationName($stackPtr);
if ($methodName === '__construct'
&& $tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG
&& $tokens[$commentEnd]['code'] !== T_COMMENT
) {
return;
}

$beforeCommentEnd = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($commentEnd - 1), null, true);
if (($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG
&& $tokens[$commentEnd]['code'] !== T_COMMENT)
Expand Down

0 comments on commit 4261827

Please sign in to comment.