1 | <?php |
||
17 | class EmptyLinesDocSniff extends AbstractSniff |
||
18 | { |
||
19 | /** |
||
20 | * There MUST be no redundant lines in your doc block. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | public const CODE_EMPTY_LINES_FOUND = 'EmptyLinesFound'; |
||
25 | |||
26 | /** |
||
27 | * Error message when empty line is detected. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | private const ERROR_EMPTY_LINES_FOUND = 'There are too many empty lines in your doc-block!'; |
||
32 | |||
33 | /** |
||
34 | * Process token within scope. |
||
35 | * |
||
36 | * @return void |
||
37 | */ |
||
38 | protected function processToken(): void |
||
42 | |||
43 | /** |
||
44 | * Registers the tokens that this sniff wants to listen for. |
||
45 | * |
||
46 | * An example return value for a sniff that wants to listen for whitespace |
||
47 | * and any comments would be: |
||
48 | * |
||
49 | * <code> |
||
50 | * return array( |
||
51 | * T_WHITESPACE, |
||
52 | * T_DOC_COMMENT, |
||
53 | * T_COMMENT, |
||
54 | * ); |
||
55 | * </code> |
||
56 | * |
||
57 | * @see Tokens.php |
||
58 | * |
||
59 | * @return int[] |
||
60 | */ |
||
61 | public function register(): array |
||
65 | |||
66 | /** |
||
67 | * Remove unnecessary lines from doc block. |
||
68 | * |
||
69 | * @param File $phpcsFile |
||
70 | * @param array $nextToken |
||
71 | * @param array $currentToken |
||
72 | * |
||
73 | * @return void |
||
74 | */ |
||
75 | private function removeUnnecessaryLines(File $phpcsFile, array $nextToken, array $currentToken): void |
||
92 | |||
93 | /** |
||
94 | * Process method for tokens within scope and also outside scope. |
||
95 | * |
||
96 | * @param File $phpcsFile The sniffed file. |
||
97 | * @param int $searchPosition |
||
98 | * |
||
99 | * @return void |
||
100 | */ |
||
101 | private function searchEmptyLines(File $phpcsFile, int $searchPosition): void |
||
140 | } |
||
141 |