Mercurial > hg > isophonics-drupal-site
diff vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/HookCommentSniff.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 129ea1e6d783 |
children |
line wrap: on
line diff
--- a/vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/HookCommentSniff.php Thu Feb 28 13:21:36 2019 +0000 +++ b/vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/HookCommentSniff.php Thu May 09 15:33:08 2019 +0100 @@ -111,8 +111,22 @@ } } }//end if + + return; }//end if + // Check if the doc block just repeats the function name with + // "Implements example_hook_name()". + $functionName = $phpcsFile->getDeclarationName($stackPtr); + if ($functionName !== null && preg_match("/^[\s]*Implements $functionName\(\)\.$/i", $shortContent) === 1) { + $error = 'Hook implementations must be documented with "Implements hook_example()."'; + $fix = $phpcsFile->addFixableError($error, $short, 'HookRepeat'); + if ($fix === true) { + $newComment = preg_replace('/Implements [^_]+/', 'Implements hook', $shortContent); + $phpcsFile->fixer->replaceToken($short, $newComment); + } + } + }//end process()