1 | <?php |
||
27 | class EmptyArrayForComparisonSniff extends AbstractSniff |
||
28 | { |
||
29 | /** |
||
30 | * You MUST not create an empty array, to check for an empty array. |
||
31 | */ |
||
32 | public const CODE_EMPTY_ARRAY = 'EmptyArray'; |
||
33 | |||
34 | /** |
||
35 | * Used message to display the error. |
||
36 | */ |
||
37 | private const MESSAGE_EMPTY_ARRAY = 'Please do not initalize an empty array to check for an empty array!'; |
||
38 | |||
39 | /** |
||
40 | * The check must not contain just an empty array. |
||
41 | * |
||
42 | * @var array|null Is filled by the setup method. |
||
43 | */ |
||
44 | private $invalidStructure; |
||
45 | |||
46 | /** |
||
47 | * Search starting with the given search pos for the invalid codes in consecutive order. |
||
48 | * |
||
49 | * @throws CodeError Contains the error message if there is an invalid array check. |
||
50 | * |
||
51 | * @param array $invalidCodes |
||
52 | * @param int $searchPos |
||
53 | * |
||
54 | * @return void |
||
55 | */ |
||
56 | private function checkArrayStructure(array $invalidCodes, int $searchPos): void |
||
88 | |||
89 | /** |
||
90 | * Processes the token. |
||
91 | * |
||
92 | * @throws CodeError Contains the error message if there is an invalid array check. |
||
93 | * |
||
94 | * @return void |
||
95 | */ |
||
96 | protected function processToken(): void |
||
114 | |||
115 | /** |
||
116 | * Registers the tokens that this sniff wants to listen for. |
||
117 | * |
||
118 | * An example return value for a sniff that wants to listen for whitespace |
||
119 | * and any comments would be: |
||
120 | * |
||
121 | * <code> |
||
122 | * return array( |
||
123 | * T_WHITESPACE, |
||
124 | * T_DOC_COMMENT, |
||
125 | * T_COMMENT, |
||
126 | * ); |
||
127 | * </code> |
||
128 | * |
||
129 | * @return int[] |
||
130 | * @see Tokens.php |
||
131 | */ |
||
132 | public function register(): array |
||
136 | |||
137 | /** |
||
138 | * Declares the forbidden array structure. |
||
139 | * |
||
140 | * @return void |
||
141 | */ |
||
142 | protected function setUp(): void |
||
151 | } |
||
152 |