Foreach.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * @property PHPParser_Node_Expr $expr Expression to iterate
  4. * @property null|PHPParser_Node_Expr $keyVar Variable to assign key to
  5. * @property bool $byRef Whether to assign value by reference
  6. * @property PHPParser_Node_Expr $valueVar Variable to assign value to
  7. * @property PHPParser_Node[] $stmts Statements
  8. */
  9. class PHPParser_Node_Stmt_Foreach extends PHPParser_Node_Stmt
  10. {
  11. /**
  12. * Constructs a foreach node.
  13. *
  14. * @param PHPParser_Node_Expr $expr Expression to iterate
  15. * @param PHPParser_Node_Expr $valueVar Variable to assign value to
  16. * @param array $subNodes Array of the following optional subnodes:
  17. * 'keyVar' => null : Variable to assign key to
  18. * 'byRef' => false : Whether to assign value by reference
  19. * 'stmts' => array(): Statements
  20. * @param array $attributes Additional attributes
  21. */
  22. public function __construct(PHPParser_Node_Expr $expr, PHPParser_Node_Expr $valueVar, array $subNodes = array(), array $attributes = array()) {
  23. parent::__construct(
  24. $subNodes + array(
  25. 'keyVar' => null,
  26. 'byRef' => false,
  27. 'stmts' => array(),
  28. ),
  29. $attributes
  30. );
  31. $this->expr = $expr;
  32. $this->valueVar = $valueVar;
  33. }
  34. }