Debian Codegraph @

vendor/mck89/peast/lib/Peast/Syntax/Node/PropertyDefinition.php

raw
1 <?php
2 /**
3 * This file is part of the Peast package
4 *
5 * (c) Marco Marchiò <[email protected]>
6 *
7 * For the full copyright and license information refer to the LICENSE file
8 * distributed with this source code
9 */
10 namespace Peast\Syntax\Node;
11
12 /**
13 * A node that represents a property definition in class body.
14 *
15 * @author Marco Marchiò <[email protected]>
16 */
17 class PropertyDefinition extends Node
18 {
19 /**
20 * Map of node properties
21 *
22 * @var array
23 */
24 protected $propertiesMap = array(
25 "key" => true,
26 "value" => true,
27 "computed" => false,
28 "static" => false
29 );
30
31 /**
32 * Property key
33 *
34 * @var Expression|PrivateIdentifier
35 */
36 protected $key;
37
38 /**
39 * Optional property value
40 *
41 * @var Expression|null
42 */
43 protected $value;
44
45 /**
46 * Property computed flag that is true when the property is declared using
47 * the square brackets syntax
48 *
49 * @var bool
50 */
51 protected $computed = false;
52
53 /**
54 * Property static flag that is true when the property is declared static
55 *
56 * @var bool
57 */
58 protected $static = false;
59
60 /**
61 * Returns the property key
62 *
63 * @return Expression|PrivateIdentifier
64 */
65 public function getKey()
66 {
67 return $this->key;
68 }
69
70 /**
71 * Sets the property key
72 *
73 * @param Expression|PrivateIdentifier $key Property key
74 *
75 * @return $this
76 */
77 public function setKey($key)
78 {
79 $this->assertType($key, array("Expression", "PrivateIdentifier"));
80 $this->key = $key;
81 return $this;
82 }
83
84 /**
85 * Returns the property value
86 *
87 * @return Expression|null
88 */
89 public function getValue()
90 {
91 return $this->value;
92 }
93
94 /**
95 * Sets the property value
96 *
97 * @param Expression|null $value Property value
98 *
99 * @return $this
100 */
101 public function setValue($value)
102 {
103 $this->assertType($value, "Expression", true);
104 $this->value = $value;
105 return $this;
106 }
107
108 /**
109 * Returns the property computed flag that is true when the property is
110 * declared using the square brackets syntax
111 *
112 * @return bool
113 */
114 public function getComputed()
115 {
116 return $this->computed;
117 }
118
119 /**
120 * Sets the property computed flag that is true when the property is
121 * declared using the square brackets syntax
122 *
123 * @param bool $computed Property computed flag
124 *
125 * @return $this
126 */
127 public function setComputed($computed)
128 {
129 $this->computed = (bool) $computed;
130 return $this;
131 }
132
133 /**
134 * Returns the property static flag that is true when the property is
135 * declared static
136 *
137 * @return bool
138 */
139 public function getStatic()
140 {
141 return $this->static;
142 }
143
144 /**
145 * Sets the property static flag that is true when the property is
146 * declared static
147 *
148 * @param bool $static Property static flag
149 *
150 * @return $this
151 */
152 public function setStatic($static)
153 {
154 $this->static = (bool) $static;
155 return $this;
156 }
157 }