| 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 | * ParameterMetadata constructor. |
||
| 48 | * |
||
| 49 | * @param string $name |
||
| 50 | * @param string $type |
||
| 51 | * @param bool $byRef |
||
| 52 | * @param bool $variadic |
||
| 53 | * @param mixed $default |
||
| 54 | */ |
||
| 55 | public function __construct($name, $type = null, $byRef = false, $variadic = false, $default = null) |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | public function getName() |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @return string |
||
| 74 | */ |
||
| 75 | public function getType() |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @return bool |
||
| 82 | */ |
||
| 83 | public function byReference() |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @return bool |
||
| 90 | */ |
||
| 91 | public function isVariadic() |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @return mixed |
||
| 98 | */ |
||
| 99 | public function getDefault() |
||
| 103 | |||
| 104 | /** |
||
| 105 | * Creates parameter metadata instance from \PhpParser\Node\Param |
||
| 106 | * |
||
| 107 | * @param Param $param |
||
| 108 | * @return ParameterMetadata|static |
||
| 109 | */ |
||
| 110 | public static function fromParameter(Param $param) |
||
| 120 | } |
||
| 121 |
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.