| Conditions | 13 |
| Paths | 1 |
| Total Lines | 29 |
| Code Lines | 26 |
| 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 namespace Tarsana\Functional; |
||
| 30 | function type() { |
||
| 31 | $type = function($data) { |
||
| 32 | if ($data instanceof Error) return 'Error'; |
||
| 33 | if ($data instanceof Stream) return "Stream({$data->type})"; |
||
| 34 | if (is_callable($data)) return 'Function'; |
||
| 35 | switch (gettype($data)) { |
||
| 36 | case 'boolean': |
||
| 37 | return 'Boolean'; |
||
| 38 | case 'NULL': |
||
| 39 | return 'Null'; |
||
| 40 | case 'integer': |
||
| 41 | case 'double': |
||
| 42 | return 'Number'; |
||
| 43 | case 'string': |
||
| 44 | return 'String'; |
||
| 45 | case 'resource': |
||
| 46 | return 'Resource'; |
||
| 47 | case 'array': |
||
| 48 | if (allSatisfies('is_numeric', keys($data))) |
||
| 49 | return 'List'; |
||
| 50 | return 'Array'; |
||
| 51 | case 'object': |
||
| 52 | return 'Object'; |
||
| 53 | default: |
||
| 54 | return 'Unknown'; |
||
| 55 | } |
||
| 56 | }; |
||
| 57 | return apply(curry($type), func_get_args()); |
||
| 58 | } |
||
| 59 | |||
| 135 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.