PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.3
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.3
4.9.3 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 All 201 releases
betterdocs / includes / Dependencies / PhpParser / Builder / Interface_.php

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

82 lines 2.2 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\Name;
8 use WPDeveloper\BetterDocs\Dependencies\PhpParser\Node\Stmt;
9
10 class Interface_ extends Declaration
11 {
12 protected $name;
13 protected $extends = array();
14 protected $constants = array();
15 protected $methods = array();
16
17 /**
18 * Creates an interface builder.
19 *
20 * @param string $name Name of the interface
21 */
22 public function __construct($name) {
23 $this->name = $name;
24 }
25
26 /**
27 * Extends one or more interfaces.
28 *
29 * @param Name|string ...$interfaces Names of interfaces to extend
30 *
31 * @return $this The builder instance (for fluid interface)
32 */
33 public function extend() {
34 foreach (func_get_args() as $interface) {
35 $this->extends[] = $this->normalizeName($interface);
36 }
37
38 return $this;
39 }
40
41 /**
42 * Adds a statement.
43 *
44 * @param Stmt|WPDeveloper\BetterDocs\Dependencies\PhpParser\Builder $stmt The statement to add
45 *
46 * @return $this The builder instance (for fluid interface)
47 */
48 public function addStmt($stmt) {
49 $stmt = $this->normalizeNode($stmt);
50
51 $type = $stmt->getType();
52 switch ($type) {
53 case 'Stmt_ClassConst':
54 $this->constants[] = $stmt;
55 break;
56
57 case 'Stmt_ClassMethod':
58 // we erase all statements in the body of an interface method
59 $stmt->stmts = null;
60 $this->methods[] = $stmt;
61 break;
62
63 default:
64 throw new \LogicException(sprintf('Unexpected node of type "%s"', $type));
65 }
66
67 return $this;
68 }
69
70 /**
71 * Returns the built interface node.
72 *
73 * @return Stmt\Interface_ The built interface node
74 */
75 public function getNode() {
76 return new Stmt\Interface_($this->name, array(
77 'extends' => $this->extends,
78 'stmts' => array_merge($this->constants, $this->methods),
79 ), $this->attributes);
80 }
81 }
82