| Conditions | 3 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 30 | public function getNode(): BaseToken |
|
| 19 | { |
||
| 20 | 30 | $current = $this->ast->getStack()->current(); |
|
| 21 | 30 | $function = $this->resolveFunctionName($current); |
|
| 22 | 30 | $class = $this->resolveClassName($function); |
|
| 23 | |||
| 24 | 30 | if (!class_exists($class)) { |
|
| 25 | 6 | return $this->ast->parser->getFunction($function)->call($this, ...$this->getArguments()); |
|
| 26 | } |
||
| 27 | |||
| 28 | /** @var CallableFunction $instance */ |
||
| 29 | 24 | $instance = new $class($current); |
|
| 30 | |||
| 31 | 24 | if ($instance->getName() !== $function) { |
|
| 32 | 2 | throw new ParserException(sprintf( |
|
| 33 | 2 | '%s is not defined', |
|
| 34 | 2 | $function |
|
| 35 | )); |
||
| 36 | } |
||
| 37 | |||
| 38 | 22 | return $instance->call(...$this->getArguments()); |
|
|
|
|||
| 39 | } |
||
| 40 | |||
| 51 |
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: