Conditions | 3 |
Paths | 2 |
Total Lines | 28 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
20 | 4 | public function __construct(MapInterface $map) |
|
21 | { |
||
22 | if ( |
||
23 | 4 | (string) $map->keyType() !== 'string' || |
|
24 | 4 | (string) $map->valueType() !== Value::class |
|
25 | ) { |
||
26 | 1 | throw new \TypeError(sprintf( |
|
1 ignored issue
–
show
|
|||
27 | 1 | 'Argument 1 must be of type MapInterface<string, %s>', |
|
28 | 1 | Value::class |
|
29 | )); |
||
30 | } |
||
31 | |||
32 | $data = $map |
||
33 | 3 | ->reduce( |
|
34 | 3 | new Seq, |
|
35 | 3 | static function(Seq $sequence, string $key, Value $value): Seq { |
|
36 | return $sequence |
||
37 | 2 | ->add(new ShortString(new Str($key))) |
|
38 | 2 | ->add($value); |
|
39 | 3 | } |
|
40 | ) |
||
41 | 3 | ->join(''); |
|
42 | |||
43 | 3 | $this->value = (string) new UnsignedLongInteger( |
|
44 | 3 | $data->toEncoding('ASCII')->length() |
|
45 | ); |
||
46 | 3 | $this->value .= $data; |
|
47 | 3 | } |
|
48 | |||
54 |
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.