No Description

Param.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace PhpParser\Node;
  3. use PhpParser\Error;
  4. use PhpParser\NodeAbstract;
  5. /**
  6. * @property null|string|Name $type Typehint
  7. * @property bool $byRef Whether is passed by reference
  8. * @property bool $variadic Whether this is a variadic argument
  9. * @property string $name Name
  10. * @property null|Expr $default Default value
  11. */
  12. class Param extends NodeAbstract
  13. {
  14. /**
  15. * Constructs a parameter node.
  16. *
  17. * @param string $name Name
  18. * @param null|Expr $default Default value
  19. * @param null|string|Name $type Typehint
  20. * @param bool $byRef Whether is passed by reference
  21. * @param bool $variadic Whether this is a variadic argument
  22. * @param array $attributes Additional attributes
  23. */
  24. public function __construct($name, $default = null, $type = null, $byRef = false, $variadic = false, array $attributes = array()) {
  25. parent::__construct(
  26. array(
  27. 'type' => $type,
  28. 'byRef' => $byRef,
  29. 'variadic' => $variadic,
  30. 'name' => $name,
  31. 'default' => $default,
  32. ),
  33. $attributes
  34. );
  35. if ($variadic && null !== $default) {
  36. throw new Error('Variadic parameter cannot have a default value');
  37. }
  38. }
  39. }