Conditions | 1 |
Paths | 1 |
Total Lines | 73 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
68 | public function predefinedSchemaProvider() |
||
69 | { |
||
70 | return [ |
||
71 | [ |
||
72 | '{ |
||
73 | test : __schema { |
||
74 | queryType { |
||
75 | kind, |
||
76 | name, |
||
77 | fields { |
||
78 | name, |
||
79 | isDeprecated, |
||
80 | deprecationReason, |
||
81 | description, |
||
82 | type { |
||
83 | name |
||
84 | } |
||
85 | } |
||
86 | } |
||
87 | } |
||
88 | }', |
||
89 | ['data' => [ |
||
90 | 'test' => [ |
||
91 | 'queryType' => [ |
||
92 | 'name' => 'TestSchema', |
||
93 | 'kind' => 'OBJECT', |
||
94 | 'fields' => [ |
||
95 | ['name' => 'latest', 'isDeprecated' => true, 'deprecationReason' => 'for test', 'description' => 'for test', 'type' => ['name' => 'latest']], |
||
96 | ['name' => '__schema', 'isDeprecated' => false, 'deprecationReason' => '', 'description' => '', 'type' => ['name' => '__Schema']], |
||
97 | ['name' => '__type', 'isDeprecated' => false, 'deprecationReason' => '', 'description' => '', 'type' => ['name' => '__Type']] |
||
98 | ] |
||
99 | ] |
||
100 | ] |
||
101 | ]] |
||
102 | ], |
||
103 | [ |
||
104 | '{ |
||
105 | __schema { |
||
106 | queryType { |
||
107 | kind, |
||
108 | name, |
||
109 | description, |
||
110 | interfaces { |
||
111 | name |
||
112 | }, |
||
113 | possibleTypes { |
||
114 | name |
||
115 | }, |
||
116 | inputFields { |
||
117 | name |
||
118 | }, |
||
119 | ofType{ |
||
120 | name |
||
121 | } |
||
122 | } |
||
123 | } |
||
124 | }', |
||
125 | ['data' => [ |
||
126 | '__schema' => [ |
||
127 | 'queryType' => [ |
||
128 | 'kind' => 'OBJECT', |
||
129 | 'name' => 'TestSchema', |
||
130 | 'description' => 'Root of TestSchema', |
||
131 | 'interfaces' => [], |
||
132 | 'possibleTypes' => [], |
||
133 | 'inputFields' => [], |
||
134 | 'ofType' => [] |
||
135 | ] |
||
136 | ] |
||
137 | ]] |
||
138 | ] |
||
139 | ]; |
||
140 | } |
||
141 | |||
198 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.