Enum_.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Stmt;
  3. use PhpParser\Node;
  4. class Enum_ extends ClassLike {
  5. /** @var null|Node\Identifier Scalar Type */
  6. public ?Node $scalarType;
  7. /** @var Node\Name[] Names of implemented interfaces */
  8. public array $implements;
  9. /**
  10. * @param string|Node\Identifier|null $name Name
  11. * @param array{
  12. * scalarType?: Node\Identifier|null,
  13. * implements?: Node\Name[],
  14. * stmts?: Node\Stmt[],
  15. * attrGroups?: Node\AttributeGroup[],
  16. * } $subNodes Array of the following optional subnodes:
  17. * 'scalarType' => null : Scalar type
  18. * 'implements' => array() : Names of implemented interfaces
  19. * 'stmts' => array() : Statements
  20. * 'attrGroups' => array() : PHP attribute groups
  21. * @param array<string, mixed> $attributes Additional attributes
  22. */
  23. public function __construct($name, array $subNodes = [], array $attributes = []) {
  24. $this->name = \is_string($name) ? new Node\Identifier($name) : $name;
  25. $this->scalarType = $subNodes['scalarType'] ?? null;
  26. $this->implements = $subNodes['implements'] ?? [];
  27. $this->stmts = $subNodes['stmts'] ?? [];
  28. $this->attrGroups = $subNodes['attrGroups'] ?? [];
  29. parent::__construct($attributes);
  30. }
  31. public function getSubNodeNames(): array {
  32. return ['attrGroups', 'name', 'scalarType', 'implements', 'stmts'];
  33. }
  34. public function getType(): string {
  35. return 'Stmt_Enum';
  36. }
  37. }