Automattic /
jetpack
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase |
||
| 2 | |||
| 3 | namespace Automattic\Jetpack\Sniffs\Constants; |
||
| 4 | |||
| 5 | use PHP_CodeSniffer\Files\File; |
||
| 6 | use PHP_CodeSniffer\Sniffs\Sniff; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Sniffer that looks for JETPACK_MASTER_USER constant usage |
||
| 10 | */ |
||
| 11 | class MasterUserConstantSniff implements Sniff { |
||
| 12 | /** |
||
| 13 | * Returns the token types that this sniff is interested in. |
||
| 14 | * |
||
| 15 | * @return array(int) |
||
|
0 ignored issues
–
show
|
|||
| 16 | */ |
||
| 17 | public function register() { |
||
| 18 | return array( T_STRING ); |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Processes the tokens that this sniff is interested in. |
||
| 23 | * |
||
| 24 | * @param File $phpcs_file The file where the token was found. |
||
| 25 | * @param int $stack_ptr The position in the stack where the token was found. |
||
| 26 | */ |
||
| 27 | public function process( File $phpcs_file, $stack_ptr ) { |
||
| 28 | |||
| 29 | $tokens = $phpcs_file->getTokens(); |
||
| 30 | |||
| 31 | if ( 'JETPACK_MASTER_USER' === $tokens[ $stack_ptr ]['content'] ) { |
||
| 32 | $phpcs_file->addWarning( |
||
| 33 | 'JETPACK_MASTER_USER constant should not be used. Use the blog token to make requests instead, or use the current user token when needed.', |
||
| 34 | $stack_ptr, |
||
| 35 | 'ShouldNotBeUsed' |
||
| 36 | ); |
||
| 37 | } |
||
| 38 | |||
| 39 | } |
||
| 40 | |||
| 41 | } |
||
| 42 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.