No Description

If_.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Stmt;
  3. use PhpParser\Node;
  4. class If_ extends Node\Stmt
  5. {
  6. /** @var Node\Expr Condition expression */
  7. public $cond;
  8. /** @var Node\Stmt[] Statements */
  9. public $stmts;
  10. /** @var ElseIf_[] Elseif clauses */
  11. public $elseifs;
  12. /** @var null|Else_ Else clause */
  13. public $else;
  14. /**
  15. * Constructs an if node.
  16. *
  17. * @param Node\Expr $cond Condition
  18. * @param array $subNodes Array of the following optional subnodes:
  19. * 'stmts' => array(): Statements
  20. * 'elseifs' => array(): Elseif clauses
  21. * 'else' => null : Else clause
  22. * @param array $attributes Additional attributes
  23. */
  24. public function __construct(Node\Expr $cond, array $subNodes = [], array $attributes = []) {
  25. $this->attributes = $attributes;
  26. $this->cond = $cond;
  27. $this->stmts = $subNodes['stmts'] ?? [];
  28. $this->elseifs = $subNodes['elseifs'] ?? [];
  29. $this->else = $subNodes['else'] ?? null;
  30. }
  31. public function getSubNodeNames() : array {
  32. return ['cond', 'stmts', 'elseifs', 'else'];
  33. }
  34. public function getType() : string {
  35. return 'Stmt_If';
  36. }
  37. }