菜谱项目

If_.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  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[] 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(), array $attributes = array()) {
  25. parent::__construct($attributes);
  26. $this->cond = $cond;
  27. $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
  28. $this->elseifs = isset($subNodes['elseifs']) ? $subNodes['elseifs'] : array();
  29. $this->else = isset($subNodes['else']) ? $subNodes['else'] : null;
  30. }
  31. public function getSubNodeNames() {
  32. return array('cond', 'stmts', 'elseifs', 'else');
  33. }
  34. }