PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.2
4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 All 200 releases
betterdocs / includes / Dependencies / PhpParser / Builder / FunctionLike.php

FunctionLike.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.9.2, at includes/Dependencies/PhpParser/Builder/FunctionLike.php

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