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