-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp_attribute_type.v
More file actions
186 lines (161 loc) · 3.4 KB
/
php_attribute_type.v
File metadata and controls
186 lines (161 loc) · 3.4 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
module vphp
pub enum PhpAttributeTarget {
unknown
class_
function_
method
property
class_constant
parameter
constant
all
}
pub struct PhpAttributeItem {
pub:
kind string
name string
value string
}
pub struct PhpAttribute {
pub:
name string
target PhpAttributeTarget
pub mut:
items []PhpAttributeItem
}
pub fn PhpAttribute.named(name string) PhpAttribute {
return PhpAttribute{
name: name
}
}
pub fn (attr PhpAttribute) for_target(target PhpAttributeTarget) PhpAttribute {
return PhpAttribute{
name: attr.name
target: target
items: attr.items.clone()
}
}
pub fn (attr PhpAttribute) for_class() PhpAttribute {
return attr.for_target(.class_)
}
pub fn (attr PhpAttribute) for_function() PhpAttribute {
return attr.for_target(.function_)
}
pub fn (attr PhpAttribute) for_method() PhpAttribute {
return attr.for_target(.method)
}
pub fn (attr PhpAttribute) for_property() PhpAttribute {
return attr.for_target(.property)
}
pub fn (attr PhpAttribute) for_class_constant() PhpAttribute {
return attr.for_target(.class_constant)
}
pub fn (attr PhpAttribute) for_parameter() PhpAttribute {
return attr.for_target(.parameter)
}
pub fn (attr PhpAttribute) for_constant() PhpAttribute {
return attr.for_target(.constant)
}
pub fn (attr PhpAttribute) for_all_targets() PhpAttribute {
return attr.for_target(.all)
}
pub fn (attr PhpAttribute) string(value string) PhpAttribute {
mut next := attr
next.items << PhpAttributeItem{
kind: 'string'
value: value
}
return next
}
pub fn (attr PhpAttribute) int(value int) PhpAttribute {
mut next := attr
next.items << PhpAttributeItem{
kind: 'int'
value: value.str()
}
return next
}
pub fn (attr PhpAttribute) i64(value i64) PhpAttribute {
mut next := attr
next.items << PhpAttributeItem{
kind: 'int'
value: value.str()
}
return next
}
pub fn (attr PhpAttribute) f64(value f64) PhpAttribute {
mut next := attr
next.items << PhpAttributeItem{
kind: 'float'
value: value.str()
}
return next
}
pub fn (attr PhpAttribute) bool_value(value bool) PhpAttribute {
mut next := attr
next.items << PhpAttributeItem{
kind: 'bool'
value: value.str()
}
return next
}
pub fn (attr PhpAttribute) null_value() PhpAttribute {
mut next := attr
next.items << PhpAttributeItem{
kind: 'null'
}
return next
}
pub fn (attr PhpAttribute) named_string(name string, value string) PhpAttribute {
mut next := attr
next.items << PhpAttributeItem{
kind: 'string'
name: name
value: value
}
return next
}
pub fn (attr PhpAttribute) named_int(name string, value int) PhpAttribute {
mut next := attr
next.items << PhpAttributeItem{
kind: 'int'
name: name
value: value.str()
}
return next
}
pub fn (attr PhpAttribute) named_i64(name string, value i64) PhpAttribute {
mut next := attr
next.items << PhpAttributeItem{
kind: 'int'
name: name
value: value.str()
}
return next
}
pub fn (attr PhpAttribute) named_f64(name string, value f64) PhpAttribute {
mut next := attr
next.items << PhpAttributeItem{
kind: 'float'
name: name
value: value.str()
}
return next
}
pub fn (attr PhpAttribute) named_bool(name string, value bool) PhpAttribute {
mut next := attr
next.items << PhpAttributeItem{
kind: 'bool'
name: name
value: value.str()
}
return next
}
pub fn (attr PhpAttribute) named_null(name string) PhpAttribute {
mut next := attr
next.items << PhpAttributeItem{
kind: 'null'
name: name
}
return next
}