Mercurial > hg > isophonics-drupal-site
comparison vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/FunctionDefinition.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 |
---|---|
1 <?php | 1 <?php |
2 /** | 2 /** |
3 * Drupal_Sniffs_Semantics_FunctionDefinition. | 3 * \Drupal\Sniffs\Semantics\FunctionDefinition. |
4 * | 4 * |
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 | |
10 namespace Drupal\Sniffs\Semantics; | |
11 | |
12 use PHP_CodeSniffer\Files\File; | |
13 use PHP_CodeSniffer\Sniffs\Sniff; | |
14 use PHP_CodeSniffer\Util\Tokens; | |
9 | 15 |
10 /** | 16 /** |
11 * Helper class to sniff for function definitions. | 17 * Helper class to sniff for function definitions. |
12 * | 18 * |
13 * @category PHP | 19 * @category PHP |
14 * @package PHP_CodeSniffer | 20 * @package PHP_CodeSniffer |
15 * @link http://pear.php.net/package/PHP_CodeSniffer | 21 * @link http://pear.php.net/package/PHP_CodeSniffer |
16 */ | 22 */ |
17 abstract class Drupal_Sniffs_Semantics_FunctionDefinition implements PHP_CodeSniffer_Sniff | 23 abstract class FunctionDefinition implements Sniff |
18 { | 24 { |
19 | 25 |
20 | 26 |
21 /** | 27 /** |
22 * Returns an array of tokens this test wants to listen for. | 28 * Returns an array of tokens this test wants to listen for. |
31 | 37 |
32 | 38 |
33 /** | 39 /** |
34 * Processes this test, when one of its tokens is encountered. | 40 * Processes this test, when one of its tokens is encountered. |
35 * | 41 * |
36 * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. | 42 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
37 * @param int $stackPtr The position of the current token | 43 * @param int $stackPtr The position of the current token |
38 * in the stack passed in $tokens. | 44 * in the stack passed in $tokens. |
39 * | 45 * |
40 * @return void | 46 * @return void |
41 */ | 47 */ |
42 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | 48 public function process(File $phpcsFile, $stackPtr) |
43 { | 49 { |
44 $tokens = $phpcsFile->getTokens(); | 50 $tokens = $phpcsFile->getTokens(); |
45 // Check if this is a function definition. | 51 // Check if this is a function definition. |
46 $functionPtr = $phpcsFile->findPrevious( | 52 $functionPtr = $phpcsFile->findPrevious( |
47 PHP_CodeSniffer_Tokens::$emptyTokens, | 53 Tokens::$emptyTokens, |
48 ($stackPtr - 1), | 54 ($stackPtr - 1), |
49 null, | 55 null, |
50 true | 56 true |
51 ); | 57 ); |
52 if ($tokens[$functionPtr]['code'] === T_FUNCTION) { | 58 if ($tokens[$functionPtr]['code'] === T_FUNCTION) { |
57 | 63 |
58 | 64 |
59 /** | 65 /** |
60 * Process this function definition. | 66 * Process this function definition. |
61 * | 67 * |
62 * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. | 68 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
63 * @param int $stackPtr The position of the function name in the stack. | 69 * @param int $stackPtr The position of the function name in the stack. |
64 * name in the stack. | 70 * name in the stack. |
65 * @param int $functionPtr The position of the function keyword in the stack. | 71 * @param int $functionPtr The position of the function keyword in the stack. |
66 * keyword in the stack. | 72 * keyword in the stack. |
67 * | 73 * |
68 * @return void | 74 * @return void |
69 */ | 75 */ |
70 public abstract function processFunction(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionPtr); | 76 public abstract function processFunction(File $phpcsFile, $stackPtr, $functionPtr); |
71 | 77 |
72 | 78 |
73 }//end class | 79 }//end class |