Skip to content

Commit 9aba6a6

Browse files
committed
glayzzle#41 make function AST more consistent
1 parent 6e0fd23 commit 9aba6a6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/parser/function.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,16 @@ module.exports = {
133133
* @see https://github.com/php/php-src/blob/493524454d66adde84e00d249d607ecd540de99f/Zend/zend_language_parser.y#L640
134134
*/
135135
,read_parameter: function() {
136+
var node = this.node('param');
136137
var type = this.read_type();
137138
var isRef = this.is_reference();
138139
var isVariadic = this.is_variadic();
139140
var name = this.expect(this.tok.T_VARIABLE).text();
140-
var value = [];
141+
var value = null;
141142
if (this.next().token == '=') {
142143
value = this.next().read_expr();
143144
}
144-
return [name, type, value, isRef, isVariadic];
145+
return node(name, type, value, isRef, isVariadic);
145146
}
146147
/**
147148
* <ebnf>
@@ -183,15 +184,15 @@ module.exports = {
183184
switch(this.token) {
184185
case this.tok.T_ARRAY:
185186
this.next();
186-
return 'array';
187+
return ['array'];
187188
case this.tok.T_NS_SEPARATOR:
188189
case this.tok.T_STRING:
189190
return this.read_namespace_name();
190191
case this.tok.T_CALLABLE:
191192
this.next();
192-
return 'callable';
193+
return ['callable'];
193194
default:
194-
return 'mixed';
195+
return null;
195196
}
196197
}
197198
};

0 commit comments

Comments
 (0)