Conditions | 3 |
Paths | 2 |
Total Lines | 179 |
Code Lines | 122 |
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 |
||
109 | public function getCalleeInfoProvider() |
||
110 | { |
||
111 | $basetrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
||
112 | $dumpframe = array( |
||
113 | 'class' => 'Kint', |
||
114 | 'function' => 'dump', |
||
115 | ); |
||
116 | |||
117 | $data['empty trace'] = array( |
||
118 | 'trace' => array( |
||
119 | ), |
||
120 | 'param_count' => 1234, |
||
121 | 'expect' => array( |
||
122 | null, |
||
123 | array(), |
||
124 | null, |
||
125 | null, |
||
126 | array(), |
||
127 | ), |
||
128 | ); |
||
129 | |||
130 | $data['full trace'] = array( |
||
131 | 'trace' => array_merge(array($dumpframe), $basetrace), |
||
132 | 'param_count' => 1234, |
||
133 | 'expect' => array( |
||
134 | null, |
||
135 | array(), |
||
136 | $dumpframe, |
||
137 | array( |
||
138 | 'function' => __FUNCTION__, |
||
139 | 'class' => __CLASS__, |
||
140 | 'type' => '->', |
||
141 | ), |
||
142 | ), |
||
143 | ); |
||
144 | |||
145 | $data['trace with params'] = array( |
||
146 | 'trace' => array_merge( |
||
147 | array( |
||
148 | $dumpframe + array( |
||
149 | 'file' => TestClass::DUMP_FILE, |
||
150 | 'line' => TestClass::DUMP_LINE, |
||
151 | ), |
||
152 | ), |
||
153 | $basetrace |
||
154 | ), |
||
155 | 'param_count' => 3, |
||
156 | 'expect' => array( |
||
157 | array( |
||
158 | array('name' => '$x', 'path' => '$x', 'expression' => false), |
||
159 | array('name' => '$y', 'path' => '$y', 'expression' => false), |
||
160 | array('name' => '$z', 'path' => '$z', 'expression' => false), |
||
161 | ), |
||
162 | array(), |
||
163 | $dumpframe + array( |
||
164 | 'file' => TestClass::DUMP_FILE, |
||
165 | 'line' => TestClass::DUMP_LINE, |
||
166 | ), |
||
167 | ), |
||
168 | ); |
||
169 | |||
170 | $data['trace with modifiers'] = array( |
||
171 | 'trace' => array_merge( |
||
172 | array( |
||
173 | $dumpframe + array( |
||
174 | 'file' => TestClass::DUMP_FILE, |
||
175 | 'line' => TestClass::DUMP_LINE + 1, |
||
176 | ), |
||
177 | ), |
||
178 | $basetrace |
||
179 | ), |
||
180 | 'param_count' => 0, |
||
181 | 'expect' => array( |
||
182 | array(), |
||
183 | array('!', '+'), |
||
184 | $dumpframe + array( |
||
185 | 'file' => TestClass::DUMP_FILE, |
||
186 | 'line' => TestClass::DUMP_LINE + 1, |
||
187 | ), |
||
188 | ), |
||
189 | ); |
||
190 | |||
191 | $data['trace function with modifier'] = array( |
||
192 | 'trace' => array_merge( |
||
193 | array( |
||
194 | array( |
||
195 | 'function' => 'd', |
||
196 | 'file' => TestClass::DUMP_FILE, |
||
197 | 'line' => TestClass::DUMP_LINE + 2, |
||
198 | ), |
||
199 | ), |
||
200 | $basetrace |
||
201 | ), |
||
202 | 'param_count' => 1, |
||
203 | 'expect' => array( |
||
204 | array( |
||
205 | array( |
||
206 | 'name' => '$x', |
||
207 | 'path' => '$x', |
||
208 | 'expression' => false, |
||
209 | ), |
||
210 | ), |
||
211 | array('~'), |
||
212 | array( |
||
213 | 'function' => 'd', |
||
214 | 'file' => TestClass::DUMP_FILE, |
||
215 | 'line' => TestClass::DUMP_LINE + 2, |
||
216 | ), |
||
217 | ), |
||
218 | ); |
||
219 | |||
220 | // HHVM doesn't support multiple unpack parameters |
||
221 | if (KINT_PHP56 && !defined('HHVM_VERSION')) { |
||
222 | $data['trace with unpack'] = array( |
||
223 | 'trace' => array_merge( |
||
224 | array( |
||
225 | $dumpframe + array( |
||
226 | 'file' => Php56TestClass::DUMP_FILE, |
||
227 | 'line' => Php56TestClass::DUMP_LINE, |
||
228 | ), |
||
229 | ), |
||
230 | $basetrace |
||
231 | ), |
||
232 | 'param_count' => 4, |
||
233 | 'expect' => array( |
||
234 | array( |
||
235 | array( |
||
236 | 'name' => '$x', |
||
237 | 'path' => '$x', |
||
238 | 'expression' => false, |
||
239 | ), |
||
240 | array( |
||
241 | 'name' => '$y', |
||
242 | 'path' => '$y', |
||
243 | 'expression' => false, |
||
244 | ), |
||
245 | array( |
||
246 | 'name' => 'reset($z)', |
||
247 | 'path' => 'reset($z)', |
||
248 | 'expression' => false, |
||
249 | ), |
||
250 | array( |
||
251 | 'name' => 'array_values($z)[1]', |
||
252 | 'path' => 'array_values($z)[1]', |
||
253 | 'expression' => false, |
||
254 | ), |
||
255 | ), |
||
256 | array(), |
||
257 | $dumpframe + array( |
||
258 | 'file' => Php56TestClass::DUMP_FILE, |
||
259 | 'line' => Php56TestClass::DUMP_LINE, |
||
260 | ), |
||
261 | ), |
||
262 | ); |
||
263 | |||
264 | $data['trace with double unpack'] = array( |
||
265 | 'trace' => array_merge( |
||
266 | array( |
||
267 | $dumpframe + array( |
||
268 | 'file' => Php56TestClass::DUMP_FILE, |
||
269 | 'line' => Php56TestClass::DUMP_LINE + 1, |
||
270 | ), |
||
271 | ), |
||
272 | $basetrace |
||
273 | ), |
||
274 | 'param_count' => 10, |
||
275 | 'expect' => array( |
||
276 | array(), |
||
277 | array(), |
||
278 | $dumpframe + array( |
||
279 | 'file' => Php56TestClass::DUMP_FILE, |
||
280 | 'line' => Php56TestClass::DUMP_LINE + 1, |
||
281 | ), |
||
282 | ), |
||
283 | ); |
||
284 | } |
||
285 | |||
286 | return $data; |
||
287 | } |
||
288 | |||
305 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.