菜谱项目

Function_.php 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace PhpParser\Node\Stmt;
  3. use PhpParser\Node;
  4. use PhpParser\Node\FunctionLike;
  5. class Function_ extends Node\Stmt implements FunctionLike
  6. {
  7. /** @var bool Whether function returns by reference */
  8. public $byRef;
  9. /** @var string Name */
  10. public $name;
  11. /** @var Node\Param[] Parameters */
  12. public $params;
  13. /** @var null|string|Node\Name|Node\NullableType Return type */
  14. public $returnType;
  15. /** @var Node[] Statements */
  16. public $stmts;
  17. /**
  18. * Constructs a function node.
  19. *
  20. * @param string $name Name
  21. * @param array $subNodes Array of the following optional subnodes:
  22. * 'byRef' => false : Whether to return by reference
  23. * 'params' => array(): Parameters
  24. * 'returnType' => null : Return type
  25. * 'stmts' => array(): Statements
  26. * @param array $attributes Additional attributes
  27. */
  28. public function __construct($name, array $subNodes = array(), array $attributes = array()) {
  29. parent::__construct($attributes);
  30. $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false;
  31. $this->name = $name;
  32. $this->params = isset($subNodes['params']) ? $subNodes['params'] : array();
  33. $this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null;
  34. $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
  35. }
  36. public function getSubNodeNames() {
  37. return array('byRef', 'name', 'params', 'returnType', 'stmts');
  38. }
  39. public function returnsByRef() {
  40. return $this->byRef;
  41. }
  42. public function getParams() {
  43. return $this->params;
  44. }
  45. public function getReturnType() {
  46. return $this->returnType;
  47. }
  48. public function getStmts() {
  49. return $this->stmts;
  50. }
  51. }