| Conditions | 11 |
| Paths | 61 |
| Total Lines | 41 |
| Code Lines | 23 |
| Lines | 7 |
| Ratio | 17.07 % |
| 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 |
||
| 132 | protected function runTask(Task $task) |
||
| 133 | { |
||
| 134 | if ($this->running) { |
||
| 135 | return parent::runTask($task); |
||
| 136 | } |
||
| 137 | |||
| 138 | $this->running = true; |
||
| 139 | |||
| 140 | $as = $this->getAs(); |
||
| 141 | |||
| 142 | foreach ($this->getArray() as $key => $value) { |
||
| 143 | foreach ($as as $type => $name) { |
||
| 144 | $this->set($name, $$type); |
||
| 145 | } |
||
| 146 | try { |
||
| 147 | parent::runTask($task); |
||
| 148 | } catch (\Exception $exception) { |
||
| 149 | break; |
||
| 150 | } |
||
| 151 | } |
||
| 152 | |||
| 153 | View Code Duplication | if (isset($exception) && $exception instanceof Exception\BreakException) { |
|
| 154 | $message = $exception->getMessage(); |
||
| 155 | if ($message) { |
||
| 156 | $this->console->output($task->expand($message)); |
||
| 157 | } |
||
| 158 | unset($exception); |
||
| 159 | } |
||
| 160 | |||
| 161 | if (isset($key)) { |
||
| 162 | foreach ($as as $name) { |
||
| 163 | $this->remove($name); |
||
| 164 | } |
||
| 165 | } |
||
| 166 | |||
| 167 | $this->running = false; |
||
| 168 | |||
| 169 | if (isset($exception)) { |
||
| 170 | throw $exception; |
||
| 171 | } |
||
| 172 | } |
||
| 173 | } |
||
| 175 |
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..