For_.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Stmt;
  3. use PhpParser\Node;
  4. class For_ extends Node\Stmt {
  5. /** @var Node\Expr[] Init expressions */
  6. public array $init;
  7. /** @var Node\Expr[] Loop conditions */
  8. public array $cond;
  9. /** @var Node\Expr[] Loop expressions */
  10. public array $loop;
  11. /** @var Node\Stmt[] Statements */
  12. public array $stmts;
  13. /**
  14. * Constructs a for loop node.
  15. *
  16. * @param array{
  17. * init?: Node\Expr[],
  18. * cond?: Node\Expr[],
  19. * loop?: Node\Expr[],
  20. * stmts?: Node\Stmt[],
  21. * } $subNodes Array of the following optional subnodes:
  22. * 'init' => array(): Init expressions
  23. * 'cond' => array(): Loop conditions
  24. * 'loop' => array(): Loop expressions
  25. * 'stmts' => array(): Statements
  26. * @param array<string, mixed> $attributes Additional attributes
  27. */
  28. public function __construct(array $subNodes = [], array $attributes = []) {
  29. $this->attributes = $attributes;
  30. $this->init = $subNodes['init'] ?? [];
  31. $this->cond = $subNodes['cond'] ?? [];
  32. $this->loop = $subNodes['loop'] ?? [];
  33. $this->stmts = $subNodes['stmts'] ?? [];
  34. }
  35. public function getSubNodeNames(): array {
  36. return ['init', 'cond', 'loop', 'stmts'];
  37. }
  38. public function getType(): string {
  39. return 'Stmt_For';
  40. }
  41. }