1 | <?php |
||
7 | class ParameterMetadata |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | private $name; |
||
13 | |||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | private $type; |
||
18 | |||
19 | /** |
||
20 | * @var bool |
||
21 | */ |
||
22 | private $byRef; |
||
23 | |||
24 | /** |
||
25 | * @var bool |
||
26 | */ |
||
27 | private $variadic; |
||
28 | |||
29 | /** |
||
30 | * @var mixed |
||
31 | */ |
||
32 | private $default; |
||
33 | |||
34 | /** |
||
35 | * ParameterMetadata constructor. |
||
36 | * |
||
37 | * @param string $name |
||
38 | * @param string $type |
||
39 | * @param bool $byRef |
||
40 | * @param bool $variadic |
||
41 | * @param mixed $default |
||
42 | */ |
||
43 | public function __construct($name, $type, $byRef, $variadic, $default) |
||
51 | |||
52 | /** |
||
53 | * @return string |
||
54 | */ |
||
55 | public function getName() |
||
59 | |||
60 | /** |
||
61 | * @return string |
||
62 | */ |
||
63 | public function getType() |
||
67 | |||
68 | /** |
||
69 | * @return bool |
||
70 | */ |
||
71 | public function byReference() |
||
75 | |||
76 | /** |
||
77 | * @return bool |
||
78 | */ |
||
79 | public function isVariadic() |
||
83 | |||
84 | /** |
||
85 | * @return mixed |
||
86 | */ |
||
87 | public function getDefault() |
||
91 | |||
92 | /** |
||
93 | * Creates parameter metadata instance from \PhpParser\Node\Param |
||
94 | * |
||
95 | * @param Param $param |
||
96 | * @return ParameterMetadata|static |
||
97 | */ |
||
98 | public static function fromParameter(Param $param) |
||
108 | } |
||
109 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.