Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
46 | public function classesToBeTested() : array |
||
47 | { |
||
48 | $locator = (new BetterReflection())->astLocator(); |
||
49 | $fromReflector = new ClassReflector(new StringSourceLocator( |
||
50 | <<<'PHP' |
||
51 | <?php |
||
52 | |||
53 | class A {} |
||
54 | class B {} |
||
55 | /** @internal */ |
||
56 | class C {} |
||
57 | /** @internal */ |
||
58 | class D {} |
||
59 | PHP |
||
60 | , |
||
61 | $locator |
||
62 | )); |
||
63 | $toReflector = new ClassReflector(new StringSourceLocator( |
||
64 | <<<'PHP' |
||
65 | <?php |
||
66 | |||
67 | class A {} |
||
68 | /** @internal */ |
||
69 | class B {} |
||
70 | /** @internal */ |
||
71 | class C {} |
||
72 | class D {} |
||
73 | PHP |
||
74 | , |
||
75 | $locator |
||
76 | )); |
||
77 | |||
78 | return [ |
||
79 | 'A' => [ |
||
80 | $fromReflector->reflect('A'), |
||
81 | $toReflector->reflect('A'), |
||
82 | [], |
||
83 | ], |
||
84 | 'B' => [ |
||
85 | $fromReflector->reflect('B'), |
||
86 | $toReflector->reflect('B'), |
||
87 | ['[BC] CHANGED: B was marked "@internal"'], |
||
88 | ], |
||
89 | 'C' => [ |
||
90 | $fromReflector->reflect('C'), |
||
91 | $toReflector->reflect('C'), |
||
92 | [], |
||
93 | ], |
||
94 | 'D' => [ |
||
95 | $fromReflector->reflect('D'), |
||
96 | $toReflector->reflect('D'), |
||
97 | [], |
||
98 | ], |
||
102 |