1 | <?php |
||
10 | class Variable |
||
11 | { |
||
12 | const BRANCH_ROOT = 0; |
||
13 | |||
14 | const BRANCH_CONDITIONAL_TRUE = 1; |
||
15 | |||
16 | const BRANCH_CONDITIONAL_FALSE = 2; |
||
17 | |||
18 | const BRANCH_CONDITIONAL_EXTERNAL = 3; |
||
19 | |||
20 | const BRANCH_UNKNOWN = 4; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $name; |
||
26 | |||
27 | /** |
||
28 | * @var mixed |
||
29 | */ |
||
30 | protected $value; |
||
31 | |||
32 | /** |
||
33 | * @var integer|string |
||
34 | */ |
||
35 | protected $branch; |
||
36 | |||
37 | /** |
||
38 | * @var int |
||
39 | */ |
||
40 | protected $gets = 0; |
||
41 | |||
42 | /** |
||
43 | * @var int |
||
44 | */ |
||
45 | protected $sets = 0; |
||
46 | |||
47 | /** |
||
48 | * @var bool |
||
49 | */ |
||
50 | protected $referenced = false; |
||
51 | |||
52 | /** |
||
53 | * @var Variable|null |
||
54 | */ |
||
55 | protected $referencedTo; |
||
56 | |||
57 | /** |
||
58 | * @var int |
||
59 | */ |
||
60 | protected $type; |
||
61 | |||
62 | /** |
||
63 | * @param string $name |
||
64 | * @param mixed $defaultValue |
||
65 | * @param int $type |
||
66 | * @param int|string $branch |
||
67 | */ |
||
68 | 399 | public function __construct($name, $defaultValue = null, $type = CompiledExpression::UNKNOWN, $branch = self::BRANCH_ROOT) |
|
80 | |||
81 | /** |
||
82 | * @return int |
||
83 | */ |
||
84 | 24 | public function incGets() |
|
88 | |||
89 | /** |
||
90 | * @return int |
||
91 | */ |
||
92 | 18 | public function incSets() |
|
96 | |||
97 | /** |
||
98 | * @return int |
||
99 | */ |
||
100 | 3 | public function getGets() |
|
104 | |||
105 | /** |
||
106 | * @return int |
||
107 | */ |
||
108 | 3 | public function getSets() |
|
112 | |||
113 | /** |
||
114 | * @return mixed |
||
115 | */ |
||
116 | 386 | public function getName() |
|
120 | |||
121 | /** |
||
122 | * @return mixed |
||
123 | */ |
||
124 | 17 | public function getType() |
|
128 | |||
129 | /** |
||
130 | * @return string |
||
131 | */ |
||
132 | public function getTypeName() |
||
136 | |||
137 | /** |
||
138 | * @return null |
||
139 | */ |
||
140 | 18 | public function getValue() |
|
144 | |||
145 | /** |
||
146 | * @param int $type |
||
147 | */ |
||
148 | 1 | public function modifyType($type) |
|
152 | |||
153 | /** |
||
154 | * @param int $type |
||
155 | * @param mixed $value |
||
156 | */ |
||
157 | 4 | public function modify($type, $value) |
|
166 | |||
167 | /** |
||
168 | * Increment uses for gets and sets |
||
169 | */ |
||
170 | 10 | public function incUse() |
|
171 | { |
||
172 | 10 | $this->incGets(); |
|
173 | 10 | $this->incSets(); |
|
174 | 10 | } |
|
175 | |||
176 | /** |
||
177 | * Increment value of the variable |
||
178 | */ |
||
179 | 5 | public function inc() |
|
180 | { |
||
181 | 5 | $this->value++; |
|
182 | 5 | } |
|
183 | |||
184 | /** |
||
185 | * Decrement value of the variable |
||
186 | */ |
||
187 | 5 | public function dec() |
|
188 | { |
||
189 | 5 | $this->value--; |
|
190 | 5 | } |
|
191 | |||
192 | /** |
||
193 | * @return boolean |
||
194 | */ |
||
195 | 1 | public function isReferenced() |
|
199 | |||
200 | /** |
||
201 | * @return bool |
||
202 | */ |
||
203 | 3 | public function isNumeric() |
|
211 | |||
212 | /** |
||
213 | * Check if you are setting values to variable but didn't use it (mean get) |
||
214 | * |
||
215 | * @return bool |
||
216 | */ |
||
217 | 14 | public function isUnused() |
|
221 | |||
222 | /** |
||
223 | * @return null|Variable |
||
224 | */ |
||
225 | 4 | public function getReferencedTo() |
|
229 | |||
230 | /** |
||
231 | * @param null|Variable $referencedTo |
||
232 | */ |
||
233 | 3 | public function setReferencedTo(Variable $referencedTo = null) |
|
238 | |||
239 | /** |
||
240 | * @return string |
||
241 | */ |
||
242 | 1 | public function getSymbolType() |
|
243 | { |
||
244 | 1 | return 'variable'; |
|
245 | } |
||
246 | |||
247 | /** |
||
248 | * @return array |
||
249 | */ |
||
250 | public function __debugInfo() |
||
276 | } |
||
277 |