Mercurial > hg > isophonics-drupal-site
comparison vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
| author | Chris Cannam |
|---|---|
| date | Thu, 28 Feb 2019 13:21:36 +0000 |
| parents | 4c8ae668cc8c |
| children |
comparison
equal
deleted
inserted
replaced
| 16:c2387f117808 | 17:129ea1e6d783 |
|---|---|
| 5 * @category PHP | 5 * @category PHP |
| 6 * @package PHP_CodeSniffer | 6 * @package PHP_CodeSniffer |
| 7 * @link http://pear.php.net/package/PHP_CodeSniffer | 7 * @link http://pear.php.net/package/PHP_CodeSniffer |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 namespace Drupal\Sniffs\Commenting; | |
| 11 | |
| 12 use Drupal\Sniffs\Commenting\FunctionCommentSniff; | |
| 13 use PHP_CodeSniffer\Files\File; | |
| 14 use PHP_CodeSniffer\Sniffs\AbstractVariableSniff; | |
| 15 use PHP_CodeSniffer\Util\Tokens; | |
| 16 | |
| 10 /** | 17 /** |
| 11 * Parses and verifies class property doc comments. | 18 * Parses and verifies class property doc comments. |
| 12 * | 19 * |
| 13 * Laregely copied from Squiz_Sniffs_Commenting_VariableCommentSniff. | 20 * Laregely copied from |
| 21 * \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\VariableCommentSniff. | |
| 14 * | 22 * |
| 15 * @category PHP | 23 * @category PHP |
| 16 * @package PHP_CodeSniffer | 24 * @package PHP_CodeSniffer |
| 17 * @link http://pear.php.net/package/PHP_CodeSniffer | 25 * @link http://pear.php.net/package/PHP_CodeSniffer |
| 18 */ | 26 */ |
| 19 class Drupal_Sniffs_Commenting_VariableCommentSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff | 27 class VariableCommentSniff extends AbstractVariableSniff |
| 20 { | 28 { |
| 21 | 29 |
| 22 | 30 |
| 23 /** | 31 /** |
| 24 * Called to process class member vars. | 32 * Called to process class member vars. |
| 25 * | 33 * |
| 26 * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. | 34 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
| 27 * @param int $stackPtr The position of the current token | 35 * @param int $stackPtr The position of the current token |
| 28 * in the stack passed in $tokens. | 36 * in the stack passed in $tokens. |
| 29 * | 37 * |
| 30 * @return void | 38 * @return void |
| 31 */ | 39 */ |
| 32 public function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | 40 public function processMemberVar(File $phpcsFile, $stackPtr) |
| 33 { | 41 { |
| 34 $tokens = $phpcsFile->getTokens(); | 42 $tokens = $phpcsFile->getTokens(); |
| 35 $commentToken = array( | 43 $commentToken = array( |
| 36 T_COMMENT, | 44 T_COMMENT, |
| 37 T_DOC_COMMENT_CLOSE_TAG, | 45 T_DOC_COMMENT_CLOSE_TAG, |
| 118 $varType = $tokens[($foundVar + 2)]['content']; | 126 $varType = $tokens[($foundVar + 2)]['content']; |
| 119 | 127 |
| 120 // There may be multiple types separated by pipes. | 128 // There may be multiple types separated by pipes. |
| 121 $suggestedTypes = array(); | 129 $suggestedTypes = array(); |
| 122 foreach (explode('|', $varType) as $type) { | 130 foreach (explode('|', $varType) as $type) { |
| 123 $suggestedTypes[] = Drupal_Sniffs_Commenting_FunctionCommentSniff::suggestType($type); | 131 $suggestedTypes[] = FunctionCommentSniff::suggestType($type); |
| 124 } | 132 } |
| 125 | 133 |
| 126 $suggestedType = implode('|', $suggestedTypes); | 134 $suggestedType = implode('|', $suggestedTypes); |
| 127 | 135 |
| 128 // Detect and auto-fix the common mistake that the variable name is | 136 // Detect and auto-fix the common mistake that the variable name is |
| 155 /** | 163 /** |
| 156 * Called to process a normal variable. | 164 * Called to process a normal variable. |
| 157 * | 165 * |
| 158 * Not required for this sniff. | 166 * Not required for this sniff. |
| 159 * | 167 * |
| 160 * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this token was found. | 168 * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where this token was found. |
| 161 * @param int $stackPtr The position where the double quoted | 169 * @param int $stackPtr The position where the double quoted |
| 162 * string was found. | 170 * string was found. |
| 163 * | 171 * |
| 164 * @return void | 172 * @return void |
| 165 */ | 173 */ |
| 166 protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | 174 protected function processVariable(File $phpcsFile, $stackPtr) |
| 167 { | 175 { |
| 168 | 176 |
| 169 }//end processVariable() | 177 }//end processVariable() |
| 170 | 178 |
| 171 | 179 |
| 172 /** | 180 /** |
| 173 * Called to process variables found in double quoted strings. | 181 * Called to process variables found in double quoted strings. |
| 174 * | 182 * |
| 175 * Not required for this sniff. | 183 * Not required for this sniff. |
| 176 * | 184 * |
| 177 * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this token was found. | 185 * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where this token was found. |
| 178 * @param int $stackPtr The position where the double quoted | 186 * @param int $stackPtr The position where the double quoted |
| 179 * string was found. | 187 * string was found. |
| 180 * | 188 * |
| 181 * @return void | 189 * @return void |
| 182 */ | 190 */ |
| 183 protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | 191 protected function processVariableInString(File $phpcsFile, $stackPtr) |
| 184 { | 192 { |
| 185 | 193 |
| 186 }//end processVariableInString() | 194 }//end processVariableInString() |
| 187 | 195 |
| 188 | 196 |
