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