PluginProbe
WPIDE – File Manager & Code Editor / 3.5.9
WPIDE – File Manager & Code Editor v3.5.9
3.5.9 3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 All 55 releases
wpide / vendor / nikic / php-parser / lib / PhpParser / Builder / FunctionLike.php

FunctionLike.php in WPIDE – File Manager & Code Editor 3.5.9, at vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php

74 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace PhpParser\Builder;
4
5 use PhpParser\BuilderHelpers;
6 use PhpParser\Node;
7
8 abstract class FunctionLike extends Declaration
9 {
10 protected $returnByRef = false;
11 protected $params = [];
12
13 /** @var string|Node\Name|Node\NullableType|null */
14 protected $returnType = null;
15
16 /**
17 * Make the function return by reference.
18 *
19 * @return $this The builder instance (for fluid interface)
20 */
21 public function makeReturnByRef() {
22 $this->returnByRef = true;
23
24 return $this;
25 }
26
27 /**
28 * Adds a parameter.
29 *
30 * @param Node\Param|Param $param The parameter to add
31 *
32 * @return $this The builder instance (for fluid interface)
33 */
34 public function addParam($param) {
35 $param = BuilderHelpers::normalizeNode($param);
36
37 if (!$param instanceof Node\Param) {
38 throw new \LogicException(sprintf('Expected parameter node, got "%s"', $param->getType()));
39 }
40
41 $this->params[] = $param;
42
43 return $this;
44 }
45
46 /**
47 * Adds multiple parameters.
48 *
49 * @param array $params The parameters to add
50 *
51 * @return $this The builder instance (for fluid interface)
52 */
53 public function addParams(array $params) {
54 foreach ($params as $param) {
55 $this->addParam($param);
56 }
57
58 return $this;
59 }
60
61 /**
62 * Sets the return type for PHP 7.
63 *
64 * @param string|Node\Name|Node\Identifier|Node\ComplexType $type
65 *
66 * @return $this The builder instance (for fluid interface)
67 */
68 public function setReturnType($type) {
69 $this->returnType = BuilderHelpers::normalizeType($type);
70
71 return $this;
72 }
73 }
74