Mercurial > hg > cmmr2012-drupal-site
comparison vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/HookCommentSniff.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
109 $warn = 'Hook implementations should not duplicate @return documentation'; | 109 $warn = 'Hook implementations should not duplicate @return documentation'; |
110 $phpcsFile->addWarning($warn, $tag, 'HookReturnDoc'); | 110 $phpcsFile->addWarning($warn, $tag, 'HookReturnDoc'); |
111 } | 111 } |
112 } | 112 } |
113 }//end if | 113 }//end if |
114 | |
115 return; | |
114 }//end if | 116 }//end if |
117 | |
118 // Check if the doc block just repeats the function name with | |
119 // "Implements example_hook_name()". | |
120 $functionName = $phpcsFile->getDeclarationName($stackPtr); | |
121 if ($functionName !== null && preg_match("/^[\s]*Implements $functionName\(\)\.$/i", $shortContent) === 1) { | |
122 $error = 'Hook implementations must be documented with "Implements hook_example()."'; | |
123 $fix = $phpcsFile->addFixableError($error, $short, 'HookRepeat'); | |
124 if ($fix === true) { | |
125 $newComment = preg_replace('/Implements [^_]+/', 'Implements hook', $shortContent); | |
126 $phpcsFile->fixer->replaceToken($short, $newComment); | |
127 } | |
128 } | |
115 | 129 |
116 }//end process() | 130 }//end process() |
117 | 131 |
118 | 132 |
119 }//end class | 133 }//end class |