sop /
jwx
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types = 1); |
||
| 4 | |||
| 5 | namespace Sop\JWX\Parameter\Feature; |
||
| 6 | |||
| 7 | use Sop\JWX\Parameter\Parameter; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Trait for parameters having an array value. |
||
| 11 | */ |
||
| 12 | trait ArrayParameterValue |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * Initialize from a JSON value. |
||
| 16 | * |
||
| 17 | * @param array $value |
||
| 18 | * |
||
| 19 | * @return static |
||
| 20 | */ |
||
| 21 | 12 | public static function fromJSONValue($value): Parameter |
|
| 22 | { |
||
| 23 | 12 | if (!is_array($value)) { |
|
| 24 | 4 | throw new \UnexpectedValueException( |
|
| 25 | 4 | get_called_class() . ' expects an array parameter.'); |
|
| 26 | } |
||
| 27 | 8 | return new static(...$value); |
|
|
0 ignored issues
–
show
|
|||
| 28 | } |
||
| 29 | } |
||
| 30 |
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. Please note the @ignore annotation hint above.