EnumCase.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Stmt;
  3. use PhpParser\Node;
  4. use PhpParser\Node\AttributeGroup;
  5. class EnumCase extends Node\Stmt {
  6. /** @var Node\Identifier Enum case name */
  7. public Node\Identifier $name;
  8. /** @var Node\Expr|null Enum case expression */
  9. public ?Node\Expr $expr;
  10. /** @var Node\AttributeGroup[] PHP attribute groups */
  11. public array $attrGroups;
  12. /**
  13. * @param string|Node\Identifier $name Enum case name
  14. * @param Node\Expr|null $expr Enum case expression
  15. * @param list<AttributeGroup> $attrGroups PHP attribute groups
  16. * @param array<string, mixed> $attributes Additional attributes
  17. */
  18. public function __construct($name, ?Node\Expr $expr = null, array $attrGroups = [], array $attributes = []) {
  19. parent::__construct($attributes);
  20. $this->name = \is_string($name) ? new Node\Identifier($name) : $name;
  21. $this->expr = $expr;
  22. $this->attrGroups = $attrGroups;
  23. }
  24. public function getSubNodeNames(): array {
  25. return ['attrGroups', 'name', 'expr'];
  26. }
  27. public function getType(): string {
  28. return 'Stmt_EnumCase';
  29. }
  30. }