No Description

Closure.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace PhpParser\Node\Expr;
  3. use PhpParser\Node;
  4. use PhpParser\Node\Expr;
  5. /**
  6. * @property Node[] $stmts Statements
  7. * @property Node\Param[] $params Parameters
  8. * @property ClosureUse[] $uses use()s
  9. * @property bool $byRef Whether to return by reference
  10. * @property bool $static Whether the closure is static
  11. */
  12. class Closure extends Expr
  13. {
  14. /**
  15. * Constructs a lambda function node.
  16. *
  17. * @param array $subNodes Array of the following optional subnodes:
  18. * 'static' => false : Whether the closure is static
  19. * 'byRef' => false : Whether to return by reference
  20. * 'params' => array(): Parameters
  21. * 'uses' => array(): use()s
  22. * 'stmts' => array(): Statements
  23. * @param array $attributes Additional attributes
  24. */
  25. public function __construct(array $subNodes = array(), array $attributes = array()) {
  26. parent::__construct(
  27. array(
  28. 'static' => isset($subNodes['static']) ? $subNodes['static'] : false,
  29. 'byRef' => isset($subNodes['byRef']) ? $subNodes['byRef'] : false,
  30. 'params' => isset($subNodes['params']) ? $subNodes['params'] : array(),
  31. 'uses' => isset($subNodes['uses']) ? $subNodes['uses'] : array(),
  32. 'stmts' => isset($subNodes['stmts']) ? $subNodes['stmts'] : array(),
  33. ),
  34. $attributes
  35. );
  36. }
  37. }