Interface_.php 1.3 KB

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