| Conditions | 19 |
| Paths | 29 |
| Total Lines | 68 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 170 | public function __invoke($target=null) |
||
| 171 | { |
||
| 172 | $out = $this->checkTarget($target); |
||
| 173 | |||
| 174 | foreach ($this->stack as $i => $call) { |
||
| 175 | $is_called = false; |
||
| 176 | try { |
||
| 177 | if (isset($call['method'])) { |
||
| 178 | if (is_callable([$out, $call['method']])) { |
||
| 179 | $is_called = true; |
||
| 180 | try { |
||
| 181 | $out = call_user_func_array([$out, $call['method']], $call['arguments']); |
||
| 182 | } |
||
| 183 | catch (\BadMethodCallException $e) { |
||
| 184 | // Calling a method coded inside a magic __call |
||
| 185 | // can produce a BadMethodCallException and thus |
||
| 186 | // not be a callable |
||
| 187 | if ( |
||
| 188 | ( |
||
| 189 | ( PHP_VERSION_ID < 70000 |
||
| 190 | && $e->getTrace()[2]['file'] == __FILE__ |
||
| 191 | && $e->getTrace()[2]['function'] == 'call_user_func_array' |
||
| 192 | && $e->getTrace()[1]['function'] == $call['method'] |
||
| 193 | && $e->getTrace()[1]['class'] == get_class($out) |
||
| 194 | ) |
||
| 195 | || |
||
| 196 | ( PHP_VERSION_ID >= 70000 |
||
| 197 | && $e->getTrace()[1]['file'] == __FILE__ |
||
| 198 | && $e->getTrace()[1]['function'] == 'call_user_func_array' |
||
| 199 | // The magic method call doesn't exist in the stack with PHP 7 |
||
| 200 | ) |
||
| 201 | ) |
||
| 202 | && $e->getTrace()[0]['function'] == '__call' |
||
| 203 | && $e->getTrace()[0]['class'] == get_class($out) |
||
| 204 | ) { |
||
| 205 | $is_called = false; |
||
| 206 | } |
||
| 207 | else { |
||
| 208 | throw $e; |
||
| 209 | } |
||
| 210 | } |
||
| 211 | } |
||
| 212 | |||
| 213 | if (! $is_called && is_callable($call['method'])) { |
||
| 214 | $arguments = $this->prepareArgs($call['arguments'], $out); |
||
| 215 | |||
| 216 | $out = call_user_func_array($call['method'], $arguments); |
||
| 217 | $is_called = true; |
||
| 218 | } |
||
| 219 | |||
| 220 | if (! $is_called) { |
||
| 221 | throw new \BadMethodCallException( |
||
| 222 | $call['method'] . "() is neither a method of " . get_class($out) |
||
| 223 | . " nor a function" |
||
| 224 | ); |
||
| 225 | } |
||
| 226 | } |
||
| 227 | else { |
||
| 228 | $out = $out[ $call['entry'] ]; |
||
| 229 | } |
||
| 230 | } |
||
| 231 | catch (\Exception $e) { |
||
| 232 | // Throw $e with the good stack (usage exception) |
||
| 233 | throw $e; |
||
| 234 | } |
||
| 235 | } |
||
| 236 | |||
| 237 | return $out; |
||
| 238 | } |
||
| 282 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths