Skip to content

Commit bf8b424

Browse files
committed
fix glayzzle#67 - using now encapsed nodes
1 parent 3a1daa9 commit bf8b424

File tree

6 files changed

+86
-23
lines changed

6 files changed

+86
-23
lines changed

dist/php-parser.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,17 @@ Encapsed.TYPE_SHELL = 'shell';
12191219
*/
12201220
Encapsed.TYPE_HEREDOC = 'heredoc';
12211221

1222+
/**
1223+
* The node contains a list of constref / variables / expr :
1224+
* ```php
1225+
* <?php
1226+
* echo $foo->bar_$baz;
1227+
* ```
1228+
* @constant {String} TYPE_OFFSET - `offset`
1229+
*/
1230+
Encapsed.TYPE_OFFSET = 'offset';
1231+
1232+
12221233
module.exports = Encapsed;
12231234

12241235
},{"./literal":46}],27:[function(require,module,exports){
@@ -7789,15 +7800,26 @@ module.exports = {
77897800
this.next();
77907801
what = what(name);
77917802
if (this.token === this.tok.T_VARIABLE) {
7792-
// @fixme : create encapsed var node
7803+
var inner = this.node('variable');
77937804
name = this.text().substring(1);
77947805
this.next();
7795-
// fix $obj->var_$prop
7796-
what = ['bin', '.', what, ['var', name]];
7806+
what = this.node('encapsed')(
7807+
[what, inner(name, false)],
7808+
'offset'
7809+
);
7810+
if (what.loc && what.value[0].loc) {
7811+
what.loc.start = what.value[0].loc.start;
7812+
}
77977813
} else if (this.token === '{') {
7798-
// fix $obj->var_{$prop}
7799-
what = ['bin', '.', what, this.next().read_expr()];
7814+
var expr = this.next().read_expr();
78007815
this.expect('}') && this.next();
7816+
what = this.node('encapsed')(
7817+
[what, expr],
7818+
'offset'
7819+
);
7820+
if (what.loc && what.value[0].loc) {
7821+
what.loc.start = what.value[0].loc.start;
7822+
}
78017823
}
78027824
break;
78037825
case this.tok.T_VARIABLE:

0 commit comments

Comments
 (0)