Complex classes like EnumSet66Bench often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EnumSet66Bench, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
14 | class EnumSet66Bench |
||
15 | { |
||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | private static $constants; |
||
20 | |||
21 | /** |
||
22 | * @var string[] |
||
23 | */ |
||
24 | private static $names; |
||
25 | |||
26 | /** |
||
27 | * @var mixed[] |
||
28 | */ |
||
29 | private static $values; |
||
30 | |||
31 | /** |
||
32 | * @var int[] |
||
33 | */ |
||
34 | private static $ordinals; |
||
35 | |||
36 | /** |
||
37 | * @var Enum66[] |
||
38 | */ |
||
39 | private static $enumerators; |
||
40 | |||
41 | /** |
||
42 | * @var EnumSet |
||
43 | */ |
||
44 | private $emptySet; |
||
45 | |||
46 | /** |
||
47 | * @var EnumSet |
||
48 | */ |
||
49 | private $fullSet; |
||
50 | |||
51 | /** |
||
52 | * Initiliaze class |
||
53 | */ |
||
54 | public static function initClass() |
||
64 | |||
65 | /** |
||
66 | * Initialize object |
||
67 | */ |
||
68 | public function init() |
||
76 | |||
77 | public function benchAttachEnumeratorOnEmpty() |
||
83 | |||
84 | public function benchAttachValueOnEmpty() |
||
90 | |||
91 | public function benchAttachEnumeratorOnFull() |
||
97 | |||
98 | public function benchAttachValueOnFull() |
||
104 | |||
105 | public function benchDetachEnumeratorOnEmpty() |
||
111 | |||
112 | public function benchDetachValueOnEmpty() |
||
118 | |||
119 | public function benchDetachEnumeratorOnFull() |
||
125 | |||
126 | public function benchDetachValueOnFull() |
||
132 | |||
133 | public function benchContainsEnumeratorTrue() |
||
139 | |||
140 | public function benchContainsValueTrue() |
||
146 | |||
147 | public function benchContainsEnumeratorFalse() |
||
153 | |||
154 | public function benchContainsValueFalse() |
||
160 | |||
161 | public function benchIterateFull() |
||
167 | |||
168 | public function benchIterateEmpty() |
||
174 | |||
175 | public function benchCountFull() |
||
179 | |||
180 | public function benchCountEmpty() |
||
184 | |||
185 | public function benchIsEqual() |
||
189 | |||
190 | public function benchIsSubset() |
||
194 | |||
195 | public function benchIsSuperset() |
||
199 | |||
200 | public function benchUnion() |
||
204 | |||
205 | public function benchIntersect() |
||
209 | |||
210 | public function benchDiff() |
||
214 | |||
215 | public function benchSymDiff() |
||
219 | |||
220 | public function benchGetOrdinals() |
||
224 | |||
225 | public function benchGetValues() |
||
229 | |||
230 | public function benchGetNames() |
||
234 | |||
235 | public function benchGetEnumerators() |
||
239 | } |
||
240 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..