-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp_const.v
More file actions
49 lines (39 loc) · 1004 Bytes
/
php_const.v
File metadata and controls
49 lines (39 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module vphp
pub struct PhpConst {
name string
}
pub fn PhpConst.named(name string) PhpConst {
return PhpConst{
name: name
}
}
pub fn PhpConst.find(name string) ?PhpConst {
constant := PhpConst.named(name)
if !constant.exists() {
return none
}
return constant
}
pub fn (constant PhpConst) name() string {
return constant.name
}
pub fn (constant PhpConst) exists() bool {
return PhpFunction.named('defined').result_bool(PhpString.of(constant.name))
}
pub fn (constant PhpConst) value() ZVal {
mut result := PhpFunction.named('constant').request_owned(PhpString.of(constant.name))
return result.take_zval()
}
pub fn (constant PhpConst) to_zval() ZVal {
return constant.value()
}
pub fn (constant PhpConst) value_v[T]() !T {
return constant.value().to_v[T]()
}
// PHP constant entry. Return the constant value itself.
pub fn php_const(name string) ZVal {
return PhpConst.named(name).value()
}
pub fn global_const_exists(name string) bool {
return PhpConst.named(name).exists()
}