1 | <?php |
||
19 | class ParameterMetadata |
||
20 | { |
||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $name; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $type; |
||
30 | |||
31 | /** |
||
32 | * @var bool |
||
33 | */ |
||
34 | private $byRef; |
||
35 | |||
36 | /** |
||
37 | * @var bool |
||
38 | */ |
||
39 | private $variadic; |
||
40 | |||
41 | /** |
||
42 | * @var mixed |
||
43 | */ |
||
44 | private $default; |
||
45 | |||
46 | /** |
||
47 | * @var Param |
||
48 | */ |
||
49 | private $ast; |
||
50 | |||
51 | /** |
||
52 | * ParameterMetadata constructor. |
||
53 | * |
||
54 | * @param string $name |
||
55 | * @param string $type |
||
56 | * @param bool $byRef |
||
57 | * @param bool $variadic |
||
58 | * @param mixed $default |
||
59 | */ |
||
60 | 1 | public function __construct($name, $type = null, $byRef = false, $variadic = false, $default = null, Param $ast = null) |
|
69 | |||
70 | /** |
||
71 | * @return string |
||
72 | */ |
||
73 | public function getName() |
||
77 | |||
78 | /** |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getType() |
||
85 | |||
86 | /** |
||
87 | * @return bool |
||
88 | */ |
||
89 | public function byReference() |
||
93 | |||
94 | /** |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function isVariadic() |
||
101 | |||
102 | /** |
||
103 | * @return mixed |
||
104 | */ |
||
105 | public function getDefault() |
||
109 | |||
110 | /** |
||
111 | * @return Param |
||
112 | */ |
||
113 | public function getAst() |
||
117 | |||
118 | /** |
||
119 | * Creates parameter metadata instance from \PhpParser\Node\Param |
||
120 | * |
||
121 | * @param Param $param |
||
122 | * @return ParameterMetadata|static |
||
123 | */ |
||
124 | public static function fromParameter(Param $param) |
||
135 | } |
||
136 |
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.