Trait_.php 1001 B

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