Skip to content

Commit efb2b54

Browse files
committed
glayzzle#73 define the curly property on variable node
1 parent 1d2ce7c commit efb2b54

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/parser/function.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ module.exports = {
115115
this.expect(this.tok.T_VARIABLE);
116116
var name = this.text().substring(1);
117117
this.next();
118-
return result(name, isRef);
118+
return result(name, isRef, false);
119119
}
120120
/**
121121
* reads a list of parameters

src/parser/scalar.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,20 +170,22 @@ module.exports = {
170170
var varName = this.text();
171171
name = this.node('variable');
172172
this.next();
173-
name = name(varName, false);
174173
// check if lookup an offset
175174
// https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L1243
176175
if (this.token === '[') {
176+
name = name(varName, false);
177177
var node = this.node('offsetlookup');
178178
var offset = this.next().read_expr();
179179
this.expect(']') && this.next();
180180
name = node(name, offset);
181+
} else {
182+
name = varName;
181183
}
182184
} else {
183185
name = this.read_expr();
184186
}
185187
this.expect('}') && this.next();
186-
result = result('variable', name, false);
188+
result = result('variable', name, false, true);
187189
}
188190

189191
// expression

src/parser/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ module.exports = {
105105
if (this.expect(this.tok.T_VARIABLE)) {
106106
var name = this.text().substring(1);
107107
this.next();
108-
variable = variable(name, false);
108+
variable = variable(name, false, false);
109109
} else {
110-
variable = variable('#ERR', false);
110+
variable = variable('#ERR', false, false);
111111
}
112112
if (this.token === '=') {
113113
return node(variable, this.next().read_expr());

src/parser/variable.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ module.exports = {
140140
name = this.text().substring(1);
141141
this.next();
142142
what = this.node('encapsed')(
143-
[what, inner(name, false)],
143+
[what, inner(name, false, false)],
144144
'offset'
145145
);
146146
if (what.loc && what.value[0].loc) {
@@ -162,7 +162,7 @@ module.exports = {
162162
what = this.node('variable');
163163
var name = this.text().substring(1);
164164
this.next();
165-
what = what(name, false);
165+
what = what(name, false, false);
166166
break;
167167
case '$':
168168
this.next().expect(['{', this.tok.T_VARIABLE]);
@@ -216,7 +216,7 @@ module.exports = {
216216
} else if (this.token === this.tok.T_VARIABLE) {
217217
var name = this.text().substring(1);
218218
this.next();
219-
offset = offset('variable', name, false);
219+
offset = offset('variable', name, false, false);
220220
} else {
221221
this.expect([
222222
this.tok.T_STRING,
@@ -273,15 +273,15 @@ module.exports = {
273273
// plain variable name
274274
var name = this.text().substring(1);
275275
this.next();
276-
result = result(name, byref);
276+
result = result(name, byref, false);
277277
} else {
278278
if (this.token === '$') this.next();
279279
// dynamic variable name
280280
switch(this.token) {
281281
case '{':
282282
var expr = this.next().read_expr();
283283
this.expect('}') && this.next();
284-
result = result(expr, byref);
284+
result = result(expr, byref, true);
285285
break;
286286
case '$': // $$$var
287287
result = result(this.read_simple_variable(false), byref);
@@ -290,14 +290,14 @@ module.exports = {
290290
var name = this.text().substring(1);
291291
var node = this.node('variable');
292292
this.next();
293-
result = result(node(name, false), byref);
293+
result = result(node(name, false, false), byref, false);
294294
break;
295295
default:
296296
this.error(['{', '$', this.tok.T_VARIABLE]);
297297
// graceful mode
298298
var name = this.text();
299299
this.next();
300-
result = result(name, byref);
300+
result = result(name, byref, false);
301301
}
302302
}
303303
return result;

0 commit comments

Comments
 (0)