1 | <?php |
||
17 | class SpaceAfterDeclareSniff implements PHP_CodeSniffer_Sniff |
||
18 | { |
||
19 | /** |
||
20 | * Error message when no whitespace is found. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | const MESSAGE_NO_WHITESPACE_FOUND = 'There is no whitespace after declare-statement.'; |
||
25 | |||
26 | /** |
||
27 | * Code when no whitespace is found. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | const CODE_NO_WHITESPACE_FOUND = 'NoWhitespaceFound'; |
||
32 | |||
33 | /** |
||
34 | * Error message when more than one whitespaces are found. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | const MESSAGE_MUCH_WHITESPACE_FOUND = 'There are more than one whitespaces after declare-statement.'; |
||
39 | |||
40 | /** |
||
41 | * Code when more than one whitespaces are found. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | const CODE_MUCH_WHITESPACE_FOUND = 'MuchWhitespaceFound'; |
||
46 | |||
47 | /** |
||
48 | * Registers the tokens that this sniff wants to listen for. |
||
49 | * |
||
50 | * @return int[] |
||
51 | */ |
||
52 | 5 | public function register() |
|
58 | |||
59 | /** |
||
60 | * Called when one of the token types that this sniff is listening for |
||
61 | * is found. |
||
62 | * |
||
63 | * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the token was found. |
||
64 | * @param int $stackPtr The position in the PHP_CodeSniffer file's token stack where the token was found. |
||
65 | * |
||
66 | * @return void|int Optionally returns a stack pointer. |
||
67 | */ |
||
68 | 5 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
97 | |||
98 | /** |
||
99 | * Handles when no whitespace is found. |
||
100 | * |
||
101 | * @param PHP_CodeSniffer_File $phpcsFile |
||
102 | * @param int $semicolonPtr |
||
103 | * |
||
104 | * @return void |
||
105 | */ |
||
106 | 3 | private function handleNoWhitespaceFound(PHP_CodeSniffer_File $phpcsFile, $semicolonPtr) |
|
120 | |||
121 | /** |
||
122 | * Handles when more than one whitespaces are found. |
||
123 | * |
||
124 | * @param PHP_CodeSniffer_File $phpcsFile |
||
125 | * @param int $semicolonPtr |
||
126 | * @param int $secondSpacePtr |
||
127 | * @param int $nextNonSpacePtr |
||
128 | * |
||
129 | * @return void |
||
130 | */ |
||
131 | 1 | private function handleMuchWhitespacesFound( |
|
151 | } |
||
152 |