No Description

Param.php 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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|ComplexType 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|ComplexType $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. }