Conditions | 10 |
Paths | 61 |
Total Lines | 27 |
Code Lines | 17 |
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 |
||
73 | private function setChronology() |
||
74 | { |
||
75 | foreach ($this->backtrace as $trace) { |
||
76 | $line = new Trace\DataStructures\Chronology($trace); |
||
77 | |||
78 | if (isset($trace[ 'class' ]) AND isset($trace[ 'type' ])) { |
||
79 | $line->call = $trace[ 'class' ] . $trace[ 'type' ] . $trace[ 'function' ] . '()'; |
||
80 | $line->type = $trace[ 'type' ] === '->' ? 'non-static' : 'static'; |
||
81 | } else { |
||
82 | $line->call = $trace[ 'function' ] . '()'; |
||
83 | $line->type = 'non-static'; |
||
84 | } |
||
85 | |||
86 | if ( ! isset($trace[ 'file' ])) { |
||
87 | $currentTrace = current($this->backtrace); |
||
88 | $line->file = isset($currentTrace[ 'file' ]) ? $currentTrace[ 'file' ] : null; |
||
89 | $line->line = isset($currentTrace[ 'line' ]) ? $currentTrace[ 'line' ] : null; |
||
90 | } |
||
91 | |||
92 | if (defined('PATH_ROOT')) { |
||
93 | $line->file = str_replace(PATH_ROOT, '', $line->file); |
||
94 | } |
||
95 | |||
96 | $this->chronology[] = $line; |
||
97 | |||
98 | if (in_array($line->call, ['print_out()', 'print_line()', 'O2System\Core\Gear\Debug::stop()'])) { |
||
99 | break; |
||
100 | } |
||
123 | } |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..