1 | <?php |
||
13 | final class ClassSortingSniff implements Sniff |
||
14 | { |
||
15 | /** |
||
16 | * Error code. |
||
17 | */ |
||
18 | CONST CODE_WRONG_SORTING_FOUND = 'WrongSortingFound'; |
||
19 | |||
20 | /** |
||
21 | * Error message. |
||
22 | */ |
||
23 | CONST ERROR_WRONG_CLASS_SORTING = 'Wrong sorting'; |
||
24 | |||
25 | private $orderTypes = ['T_CONST', 'T_VARIABLE', 'T_FUNCTION-CONSTRUCT', 'T_FUNCTION-DESTRUCT', 'T_FUNCTION']; |
||
26 | |||
27 | private $orderVisibility = ['T_PRIVATE', 'T_PROTECTED', 'T_PUBLIC']; |
||
28 | |||
29 | /** |
||
30 | * @param $file |
||
31 | * @param $position |
||
32 | * |
||
33 | * @return mixed |
||
34 | */ |
||
35 | private static function throwError($file, $position) |
||
43 | |||
44 | /** |
||
45 | * @return array |
||
46 | */ |
||
47 | public function register(): array |
||
53 | |||
54 | /** |
||
55 | * Sort. |
||
56 | * |
||
57 | * @param $a |
||
58 | * @param $b |
||
59 | * |
||
60 | * @return int |
||
61 | */ |
||
62 | private function sort($a, $b): int |
||
73 | |||
74 | /** |
||
75 | * Type sort. |
||
76 | * |
||
77 | * @param $a |
||
78 | * @param $b |
||
79 | * |
||
80 | * @return int |
||
81 | */ |
||
82 | private function typeSort($a, $b): int |
||
86 | |||
87 | /** |
||
88 | * Visibility sort. |
||
89 | * |
||
90 | * @param $a |
||
91 | * @param $b |
||
92 | * |
||
93 | * @return int |
||
94 | */ |
||
95 | private function visibilitySort($a, $b): int |
||
99 | |||
100 | /** |
||
101 | * @param File $file |
||
102 | * @param int $position |
||
103 | * |
||
104 | * @return int|void |
||
105 | */ |
||
106 | public function process(File $file, $position) |
||
161 | } |
||
162 |