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 / Trait_.php

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

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