Trait_.php 849 B

123456789101112131415161718192021222324252627282930
  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. * @param array $attributes Additional attributes
  13. */
  14. public function __construct($name, array $subNodes = [], array $attributes = []) {
  15. parent::__construct($attributes);
  16. $this->name = \is_string($name) ? new Node\Identifier($name) : $name;
  17. $this->stmts = $subNodes['stmts'] ?? [];
  18. }
  19. public function getSubNodeNames() : array {
  20. return ['name', 'stmts'];
  21. }
  22. public function getType() : string {
  23. return 'Stmt_Trait';
  24. }
  25. }