You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.2 KiB

3 years ago
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node;
  3. use PhpParser\NodeAbstract;
  4. class Param extends NodeAbstract
  5. {
  6. /** @var null|Identifier|Name|NullableType|UnionType Type declaration */
  7. public $type;
  8. /** @var bool Whether parameter is passed by reference */
  9. public $byRef;
  10. /** @var bool Whether this is a variadic argument */
  11. public $variadic;
  12. /** @var Expr\Variable|Expr\Error Parameter variable */
  13. public $var;
  14. /** @var null|Expr Default value */
  15. public $default;
  16. /** @var int */
  17. public $flags;
  18. /** @var AttributeGroup[] PHP attribute groups */
  19. public $attrGroups;
  20. /**
  21. * Constructs a parameter node.
  22. *
  23. * @param Expr\Variable|Expr\Error $var Parameter variable
  24. * @param null|Expr $default Default value
  25. * @param null|string|Identifier|Name|NullableType|UnionType $type Type declaration
  26. * @param bool $byRef Whether is passed by reference
  27. * @param bool $variadic Whether this is a variadic argument
  28. * @param array $attributes Additional attributes
  29. * @param int $flags Optional visibility flags
  30. * @param AttributeGroup[] $attrGroups PHP attribute groups
  31. */
  32. public function __construct(
  33. $var, Expr $default = null, $type = null,
  34. bool $byRef = false, bool $variadic = false,
  35. array $attributes = [],
  36. int $flags = 0,
  37. array $attrGroups = []
  38. ) {
  39. $this->attributes = $attributes;
  40. $this->type = \is_string($type) ? new Identifier($type) : $type;
  41. $this->byRef = $byRef;
  42. $this->variadic = $variadic;
  43. $this->var = $var;
  44. $this->default = $default;
  45. $this->flags = $flags;
  46. $this->attrGroups = $attrGroups;
  47. }
  48. public function getSubNodeNames() : array {
  49. return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default'];
  50. }
  51. public function getType() : string {
  52. return 'Param';
  53. }
  54. }