PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.8.9
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.8.9
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 / Trait_.php

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

60 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPDeveloper\BetterDocs\Dependencies\PhpParser\Builder;
4
5 use WPDeveloper\BetterDocs\Dependencies\PhpParser;
6 use WPDeveloper\BetterDocs\Dependencies\PhpParser\Node\Stmt;
7
8 class Trait_ extends Declaration
9 {
10 protected $name;
11 protected $uses = array();
12 protected $properties = array();
13 protected $methods = array();
14
15 /**
16 * Creates an interface builder.
17 *
18 * @param string $name Name of the interface
19 */
20 public function __construct($name) {
21 $this->name = $name;
22 }
23
24 /**
25 * Adds a statement.
26 *
27 * @param Stmt|WPDeveloper\BetterDocs\Dependencies\PhpParser\Builder $stmt The statement to add
28 *
29 * @return $this The builder instance (for fluid interface)
30 */
31 public function addStmt($stmt) {
32 $stmt = $this->normalizeNode($stmt);
33
34 if ($stmt instanceof Stmt\Property) {
35 $this->properties[] = $stmt;
36 } else if ($stmt instanceof Stmt\ClassMethod) {
37 $this->methods[] = $stmt;
38 } else if ($stmt instanceof Stmt\TraitUse) {
39 $this->uses[] = $stmt;
40 } else {
41 throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType()));
42 }
43
44 return $this;
45 }
46
47 /**
48 * Returns the built trait node.
49 *
50 * @return Stmt\Trait_ The built interface node
51 */
52 public function getNode() {
53 return new Stmt\Trait_(
54 $this->name, array(
55 'stmts' => array_merge($this->uses, $this->properties, $this->methods)
56 ), $this->attributes
57 );
58 }
59 }
60