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

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

111 lines 2.7 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 Property extends WPDeveloper\BetterDocs\Dependencies\PhpParser\BuilderAbstract
9 {
10 protected $name;
11
12 protected $flags = 0;
13 protected $default = null;
14 protected $attributes = array();
15
16 /**
17 * Creates a property builder.
18 *
19 * @param string $name Name of the property
20 */
21 public function __construct($name) {
22 $this->name = $name;
23 }
24
25 /**
26 * Makes the property public.
27 *
28 * @return $this The builder instance (for fluid interface)
29 */
30 public function makePublic() {
31 $this->setModifier(Stmt\Class_::MODIFIER_PUBLIC);
32
33 return $this;
34 }
35
36 /**
37 * Makes the property protected.
38 *
39 * @return $this The builder instance (for fluid interface)
40 */
41 public function makeProtected() {
42 $this->setModifier(Stmt\Class_::MODIFIER_PROTECTED);
43
44 return $this;
45 }
46
47 /**
48 * Makes the property private.
49 *
50 * @return $this The builder instance (for fluid interface)
51 */
52 public function makePrivate() {
53 $this->setModifier(Stmt\Class_::MODIFIER_PRIVATE);
54
55 return $this;
56 }
57
58 /**
59 * Makes the property static.
60 *
61 * @return $this The builder instance (for fluid interface)
62 */
63 public function makeStatic() {
64 $this->setModifier(Stmt\Class_::MODIFIER_STATIC);
65
66 return $this;
67 }
68
69 /**
70 * Sets default value for the property.
71 *
72 * @param mixed $value Default value to use
73 *
74 * @return $this The builder instance (for fluid interface)
75 */
76 public function setDefault($value) {
77 $this->default = $this->normalizeValue($value);
78
79 return $this;
80 }
81
82 /**
83 * Sets doc comment for the property.
84 *
85 * @param WPDeveloper\BetterDocs\Dependencies\PhpParser\Comment\Doc|string $docComment Doc comment to set
86 *
87 * @return $this The builder instance (for fluid interface)
88 */
89 public function setDocComment($docComment) {
90 $this->attributes = array(
91 'comments' => array($this->normalizeDocComment($docComment))
92 );
93
94 return $this;
95 }
96
97 /**
98 * Returns the built class node.
99 *
100 * @return Stmt\Property The built property node
101 */
102 public function getNode() {
103 return new Stmt\Property(
104 $this->flags !== 0 ? $this->flags : Stmt\Class_::MODIFIER_PUBLIC,
105 array(
106 new Stmt\PropertyProperty($this->name, $this->default)
107 ),
108 $this->attributes
109 );
110 }
111 }