Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
13 | public function casesArgs() { |
||
14 | return [ |
||
15 | 'no arguments' => [ |
||
16 | ' ', |
||
17 | ' ', |
||
18 | [], |
||
19 | ], |
||
20 | 'empty string' => [ |
||
21 | " ''", |
||
22 | ' ""', |
||
23 | [''], |
||
24 | ], |
||
25 | 'space' => [ |
||
26 | " ' '", |
||
27 | ' " "', |
||
28 | [' '], |
||
29 | ], |
||
30 | 'no escape - a' => [ |
||
31 | " a", |
||
32 | " a", |
||
33 | ['a'], |
||
34 | ], |
||
35 | 'no escape - A' => [ |
||
36 | " A", |
||
37 | " A", |
||
38 | ['A'], |
||
39 | ], |
||
40 | 'no escape - 0' => [ |
||
41 | " 0", |
||
42 | " 0", |
||
43 | ['0'], |
||
44 | ], |
||
45 | 'no escape - --' => [ |
||
46 | " --", |
||
47 | " --", |
||
48 | ['--'], |
||
49 | ], |
||
50 | 'no escape - @_~.' => [ |
||
51 | " @_~.", |
||
52 | " @_~.", |
||
53 | ['@_~.'], |
||
54 | ], |
||
55 | '$' => [ |
||
56 | " 'a\$b'", |
||
57 | ' "a$b"', |
||
58 | ['a$b'], |
||
59 | ], |
||
60 | '*' => [ |
||
61 | " 'a*b'", |
||
62 | ' "a*b"', |
||
63 | ['a*b'], |
||
64 | ], |
||
65 | 'multi' => [ |
||
66 | " '' a '\$PATH'", |
||
67 | ' "" a "$PATH"', |
||
68 | ['', 'a', '$PATH'], |
||
69 | ], |
||
70 | ]; |
||
71 | } |
||
72 | |||
95 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.