Conditions | 15 |
Paths | 64 |
Total Lines | 37 |
Code Lines | 23 |
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 | public function compile(Context $context, $arguments = null, $important = null) |
||
74 | { |
||
75 | $inParenthesis = $this->parens && !$this->parensInOp; |
||
76 | $doubleParen = false; |
||
77 | |||
78 | if ($inParenthesis) { |
||
79 | $context->inParenthesis(); |
||
80 | } |
||
81 | $count = count($this->value); |
||
82 | if ($count > 1) { |
||
83 | $compiled = []; |
||
84 | foreach ($this->value as $v) { |
||
85 | /* @var $v Node */ |
||
86 | $compiled[] = $v->compile($context); |
||
87 | } |
||
88 | $return = new self($compiled); |
||
89 | } elseif ($count === 1) { |
||
90 | if (property_exists($this->value[0], 'parens') && $this->value[0]->parens |
||
91 | && property_exists($this->value[0], 'parensInOp') && !$this->value[0]->parensInOp |
||
92 | ) { |
||
93 | $doubleParen = true; |
||
94 | } |
||
95 | $return = $this->value[0]->compile($context); |
||
96 | } else { |
||
97 | $return = $this; |
||
98 | } |
||
99 | |||
100 | if ($inParenthesis) { |
||
101 | $context->outOfParenthesis(); |
||
102 | } |
||
103 | |||
104 | if ($this->parens && $this->parensInOp && !($context->isMathOn()) && !$doubleParen) { |
||
105 | $return = new ParenNode($return); |
||
106 | } |
||
107 | |||
108 | return $return; |
||
109 | } |
||
110 | |||
150 |
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: