Conditions | 7 |
Paths | 6 |
Total Lines | 28 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
22 | 6 | public function convert($value, string $path = ''): AbstractNode |
|
23 | { |
||
24 | 6 | $type = gettype($value); |
|
25 | |||
26 | 6 | if ($type === 'boolean') { |
|
27 | 1 | return BoolNode::create($value); |
|
28 | } |
||
29 | |||
30 | 5 | if ($type === 'double') { |
|
31 | 1 | return FloatNode::create($value); |
|
32 | } |
||
33 | |||
34 | 4 | if ($type === 'integer') { |
|
35 | 1 | return IntNode::create($value); |
|
36 | } |
||
37 | |||
38 | 3 | if ($type === 'NULL') { |
|
39 | 1 | return NullNode::create($value); |
|
|
|||
40 | } |
||
41 | |||
42 | 2 | if ($type === 'string') { |
|
43 | 1 | return StringNode::create($value); |
|
44 | } |
||
45 | |||
46 | 1 | throw new \InvalidArgumentException( |
|
47 | 1 | sprintf('Type %s is not supported, at path %s', is_object($value) ? get_class($value) : $type, $path) |
|
48 | ); |
||
49 | } |
||
50 | } |
||
51 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.