Const_.php 971 B

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