Const_.php 985 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node;
  3. use PhpParser\NodeAbstract;
  4. /**
  5. * @property Name $namespacedName Namespaced name (for class constants, if using NameResolver)
  6. */
  7. class Const_ extends NodeAbstract
  8. {
  9. /** @var Identifier Name */
  10. public $name;
  11. /** @var Expr Value */
  12. public $value;
  13. /**
  14. * Constructs a const node for use in class const and const statements.
  15. *
  16. * @param string|Identifier $name Name
  17. * @param Expr $value Value
  18. * @param array $attributes Additional attributes
  19. */
  20. public function __construct($name, Expr $value, array $attributes = []) {
  21. parent::__construct($attributes);
  22. $this->name = \is_string($name) ? new Identifier($name) : $name;
  23. $this->value = $value;
  24. }
  25. public function getSubNodeNames() : array {
  26. return ['name', 'value'];
  27. }
  28. public function getType() : string {
  29. return 'Const';
  30. }
  31. }