1 | <?php |
||
12 | class CompiledExpression |
||
13 | { |
||
14 | /** |
||
15 | * Unknown type |
||
16 | */ |
||
17 | const UNKNOWN = Types::UNKNOWN_TYPE; |
||
18 | |||
19 | /** |
||
20 | * It's not unknown, It's unimplemented |
||
21 | */ |
||
22 | const UNIMPLEMENTED = -100; |
||
23 | |||
24 | /** |
||
25 | * Void type |
||
26 | */ |
||
27 | const VOID = Types::VOID_TYPE; |
||
28 | |||
29 | const INTEGER = Types::INT_TYPE; |
||
30 | |||
31 | /** |
||
32 | * Double/Float |
||
33 | */ |
||
34 | const DOUBLE = Types::DOUBLE_TYPE; |
||
35 | |||
36 | /** |
||
37 | * Double/Float |
||
38 | */ |
||
39 | const NUMBER = Types::NUMBER; |
||
40 | |||
41 | /** |
||
42 | * String |
||
43 | */ |
||
44 | const STRING = Types::STRING_TYPE; |
||
45 | |||
46 | /** |
||
47 | * Boolean |
||
48 | * true or false |
||
49 | */ |
||
50 | const BOOLEAN = Types::BOOLEAN_TYPE; |
||
51 | |||
52 | /** |
||
53 | * Array |
||
54 | */ |
||
55 | const ARR = Types::ARRAY_TYPE; |
||
56 | |||
57 | /** |
||
58 | * Object |
||
59 | */ |
||
60 | const OBJECT = Types::OBJECT_TYPE; |
||
61 | |||
62 | /** |
||
63 | * Resource handler |
||
64 | */ |
||
65 | const RESOURCE = Types::RESOURCE_TYPE; |
||
66 | |||
67 | /** |
||
68 | * Callable type |
||
69 | */ |
||
70 | const CALLABLE_TYPE = Types::CALLABLE_TYPE; |
||
71 | |||
72 | /** |
||
73 | * Value is handled in variable |
||
74 | */ |
||
75 | const VARIABLE = 512; |
||
76 | |||
77 | /** |
||
78 | * Resource handler |
||
79 | */ |
||
80 | const NULL = Types::NULL_TYPE; |
||
81 | |||
82 | /** |
||
83 | * self::INT_TYPE | self::DOUBLE_TYPE | self::STRING_TYPE | self::BOOLEAN_TYPE | self::ARRAY_TYPE | self::RESOURCE_TYPE | self::OBJECT_TYPE | self::NULL_TYPE |
||
84 | */ |
||
85 | const MIXED = Types::MIXED; |
||
86 | |||
87 | /** |
||
88 | * I can't explain what it's :D |
||
89 | */ |
||
90 | const DYNAMIC = 10000; |
||
91 | |||
92 | /** |
||
93 | * By default we don't know what it is |
||
94 | * |
||
95 | * @var int |
||
96 | */ |
||
97 | protected $type; |
||
98 | |||
99 | /** |
||
100 | * Possible value |
||
101 | * |
||
102 | * @var mixed |
||
103 | */ |
||
104 | protected $value; |
||
105 | |||
106 | /** |
||
107 | * @var Variable|null |
||
108 | */ |
||
109 | protected $variable; |
||
110 | |||
111 | /** |
||
112 | * Construct new CompiledExpression to pass result |
||
113 | * |
||
114 | * @param int $type |
||
115 | * @param mixed $value |
||
116 | * @param Variable|null $variable |
||
117 | */ |
||
118 | 380 | public function __construct($type = self::UNKNOWN, $value = null, Variable $variable = null) |
|
124 | |||
125 | /** |
||
126 | * @return mixed |
||
127 | */ |
||
128 | 380 | public function getValue() |
|
132 | |||
133 | /** |
||
134 | * @param integer $value |
||
135 | * @return boolean |
||
136 | */ |
||
137 | 72 | public function isEquals($value) |
|
141 | |||
142 | /** |
||
143 | * @return int |
||
144 | */ |
||
145 | 380 | public function getType() |
|
149 | |||
150 | /** |
||
151 | * @return string |
||
152 | */ |
||
153 | public function getTypeName() |
||
157 | |||
158 | /** |
||
159 | * @param string $name Name of the Variable |
||
160 | * @return Variable |
||
161 | */ |
||
162 | 1 | public function toVariable($name) |
|
166 | |||
167 | /** |
||
168 | * If we don't know $type but know $value |
||
169 | * |
||
170 | * @param $value |
||
171 | * @throws RuntimeException |
||
172 | * @return CompiledExpression |
||
173 | */ |
||
174 | 144 | public static function fromZvalValue($value) |
|
178 | |||
179 | /** |
||
180 | * This is needed via in feature $this->type can store multiple type(s) by bitmask |
||
181 | * |
||
182 | * @return bool |
||
183 | */ |
||
184 | public function canBeObject() |
||
188 | |||
189 | /** |
||
190 | * @return bool |
||
191 | */ |
||
192 | 5 | public function isString() |
|
193 | { |
||
194 | 5 | return $this->type == self::STRING; |
|
195 | } |
||
196 | |||
197 | /** |
||
198 | * @return bool |
||
199 | */ |
||
200 | public function isObject() |
||
204 | |||
205 | 4 | public function __debugInfo() |
|
212 | |||
213 | //@codeCoverageIgnoreStart |
||
214 | /** |
||
215 | * Check that $this->value is correct for $this->type |
||
216 | * |
||
217 | * @todo Implement it ;) |
||
218 | * @return boolean |
||
219 | */ |
||
220 | public function isCorrectValue() |
||
239 | //@codeCoverageIgnoreEnd |
||
240 | |||
241 | /** |
||
242 | * @return Variable|null |
||
243 | */ |
||
244 | public function getVariable() |
||
248 | } |
||
249 |