| Conditions | 34 |
| Paths | 41 |
| Total Lines | 78 |
| Code Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 3 |
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 |
||
| 25 | public function enterNode(Node $node) { |
||
| 26 | if ($node instanceof Stmt\Namespace_) { |
||
| 27 | $this->resetState($node->name); |
||
|
|
|||
| 28 | } elseif ($node instanceof Stmt\Use_) { |
||
| 29 | foreach ($node->uses as $use) { |
||
| 30 | $this->addAlias($use, $node->type, null); |
||
| 31 | } |
||
| 32 | } elseif ($node instanceof Stmt\GroupUse) { |
||
| 33 | foreach ($node->uses as $use) { |
||
| 34 | $this->addAlias($use, $node->type, $node->prefix); |
||
| 35 | } |
||
| 36 | } elseif ($node instanceof Stmt\Class_) { |
||
| 37 | if (null !== $node->extends) { |
||
| 38 | $node->extends = $this->resolveClassName($node->extends); |
||
| 39 | } |
||
| 40 | |||
| 41 | foreach ($node->implements as &$interface) { |
||
| 42 | $interface = $this->resolveClassName($interface); |
||
| 43 | } |
||
| 44 | |||
| 45 | if (null !== $node->name) { |
||
| 46 | $this->addNamespacedName($node); |
||
| 47 | } |
||
| 48 | } elseif ($node instanceof Stmt\Interface_) { |
||
| 49 | foreach ($node->extends as &$interface) { |
||
| 50 | $interface = $this->resolveClassName($interface); |
||
| 51 | } |
||
| 52 | |||
| 53 | $this->addNamespacedName($node); |
||
| 54 | } elseif ($node instanceof Stmt\Trait_) { |
||
| 55 | $this->addNamespacedName($node); |
||
| 56 | } elseif ($node instanceof Stmt\Function_) { |
||
| 57 | $this->addNamespacedName($node); |
||
| 58 | $this->resolveSignature($node); |
||
| 59 | } elseif ($node instanceof Stmt\ClassMethod |
||
| 60 | || $node instanceof Expr\Closure |
||
| 61 | ) { |
||
| 62 | $this->resolveSignature($node); |
||
| 63 | } elseif ($node instanceof Stmt\Const_) { |
||
| 64 | foreach ($node->consts as $const) { |
||
| 65 | $this->addNamespacedName($const); |
||
| 66 | } |
||
| 67 | } elseif ($node instanceof Expr\StaticCall |
||
| 68 | || $node instanceof Expr\StaticPropertyFetch |
||
| 69 | || $node instanceof Expr\ClassConstFetch |
||
| 70 | || $node instanceof Expr\New_ |
||
| 71 | || $node instanceof Expr\Instanceof_ |
||
| 72 | ) { |
||
| 73 | if ($node->class instanceof Name) { |
||
| 74 | $node->class = $this->resolveClassName($node->class); |
||
| 75 | } |
||
| 76 | } elseif ($node instanceof Stmt\Catch_) { |
||
| 77 | $node->type = $this->resolveClassName($node->type); |
||
| 78 | } elseif ($node instanceof Expr\FuncCall) { |
||
| 79 | if ($node->name instanceof Name) { |
||
| 80 | $node->name = $this->resolveOtherName($node->name, Stmt\Use_::TYPE_FUNCTION); |
||
| 81 | } |
||
| 82 | } elseif ($node instanceof Expr\ConstFetch) { |
||
| 83 | $node->name = $this->resolveOtherName($node->name, Stmt\Use_::TYPE_CONSTANT); |
||
| 84 | } elseif ($node instanceof Stmt\TraitUse) { |
||
| 85 | foreach ($node->traits as &$trait) { |
||
| 86 | $trait = $this->resolveClassName($trait); |
||
| 87 | } |
||
| 88 | |||
| 89 | foreach ($node->adaptations as $adaptation) { |
||
| 90 | if (null !== $adaptation->trait) { |
||
| 91 | $adaptation->trait = $this->resolveClassName($adaptation->trait); |
||
| 92 | } |
||
| 93 | |||
| 94 | if ($adaptation instanceof Stmt\TraitUseAdaptation\Precedence) { |
||
| 95 | foreach ($adaptation->insteadof as &$insteadof) { |
||
| 96 | $insteadof = $this->resolveClassName($insteadof); |
||
| 97 | } |
||
| 98 | } |
||
| 99 | } |
||
| 100 | |||
| 101 | } |
||
| 102 | } |
||
| 103 | |||
| 234 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: