1 | <?php |
||
22 | class TraitUseDeclarationSniff extends AbstractSniff |
||
23 | { |
||
24 | use ClassRegistrationTrait; |
||
25 | |||
26 | /** |
||
27 | * You MUST provide only one "use" per Line for importing traits etc. in classes. |
||
28 | */ |
||
29 | public const CODE_MULTIPLE_TRAITS_PER_DECLARATION = 'MultipleTraitsPerDeclaration'; |
||
30 | |||
31 | /** |
||
32 | * Readable error message. |
||
33 | */ |
||
34 | private const MESSAGE_MULTIPLE_TRAITS_PER_DECLARATION = 'Multiple traits per use statement are forbidden.'; |
||
35 | |||
36 | /** |
||
37 | * The use declarations positions of this "class". |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | private $uses; |
||
42 | |||
43 | /** |
||
44 | * Returns false if there are no uses. |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | protected function areRequirementsMet(): bool |
||
52 | |||
53 | /** |
||
54 | * Checks the declaration of the given use position and registers and error if needed. |
||
55 | * |
||
56 | * @param int $usePos |
||
57 | * |
||
58 | * @return void |
||
59 | */ |
||
60 | private function checkDeclaration(int $usePos): void |
||
87 | |||
88 | /** |
||
89 | * Fixes the given use position. |
||
90 | * |
||
91 | * @param int $endPos The end of the checked position. |
||
92 | * @param int $usePos |
||
93 | * |
||
94 | * @return void |
||
95 | */ |
||
96 | protected function fixeUse(int $endPos, int $usePos): void |
||
115 | |||
116 | /** |
||
117 | * Returns the needed indentation whitespace for fhe fixing of the uses. |
||
118 | * |
||
119 | * @param int $usePos |
||
120 | * |
||
121 | * @return string |
||
122 | */ |
||
123 | private function getIndentationForFix(int $usePos): string |
||
138 | |||
139 | /** |
||
140 | * Processes the token. |
||
141 | * |
||
142 | * @return void |
||
143 | */ |
||
144 | protected function processToken(): void |
||
150 | } |
||
151 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: