Conditions | 1 |
Paths | 1 |
Total Lines | 37 |
Code Lines | 0 |
Lines | 0 |
Ratio | 0 % |
Tests | 1 |
CRAP Score | 1 |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.
There are several approaches to avoid long parameter lists:
1 | <?php |
||
14 | 13 | public function __construct( |
|
15 | /** |
||
16 | * Whether it's config for a class (`false` value) or an interface (`true` value). |
||
17 | */ |
||
18 | public bool $isInterface, |
||
19 | /** |
||
20 | * @var string Namespace, for example: `Yiisoft\Proxy\Tests\Stub`. |
||
21 | * |
||
22 | * @link https://www.php.net/manual/en/language.namespaces.php |
||
23 | */ |
||
24 | public string $namespace, |
||
25 | /** |
||
26 | * @var string[] A list of modifiers, for example: `['final']`. |
||
27 | */ |
||
28 | public array $modifiers, |
||
29 | /** |
||
30 | * @var string Full name including namespace, for example: `Yiisoft\Proxy\Tests\Stub\GraphInterface`. |
||
31 | */ |
||
32 | public string $name, |
||
33 | /** |
||
34 | * @var string Short name without namespace, for example: `GraphInterface`. |
||
35 | */ |
||
36 | public string $shortName, |
||
37 | /** |
||
38 | * @var string Full parent class name including namespace. Empty string means class have no parent class. |
||
39 | */ |
||
40 | public string $parent, |
||
41 | /** |
||
42 | * @var string[] A list of interfaces this class implements or interface extends from. |
||
43 | */ |
||
44 | public array $interfaces, |
||
45 | /** |
||
46 | * @var MethodConfig[] A map where key is a {@see $name} and value is {@see MethodConfig} instance. |
||
47 | * @psalm-var array<string, MethodConfig> |
||
48 | */ |
||
49 | public array $methods, |
||
50 | ) { |
||
51 | 13 | } |
|
53 |