@@ -1219,6 +1219,17 @@ Encapsed.TYPE_SHELL = 'shell';
1219
1219
*/
1220
1220
Encapsed . TYPE_HEREDOC = 'heredoc' ;
1221
1221
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
+
1222
1233
module . exports = Encapsed ;
1223
1234
1224
1235
} , { "./literal" :46 } ] , 27 :[ function ( require , module , exports ) {
@@ -7789,15 +7800,26 @@ module.exports = {
7789
7800
this . next ( ) ;
7790
7801
what = what ( name ) ;
7791
7802
if ( this . token === this . tok . T_VARIABLE ) {
7792
- // @fixme : create encapsed var node
7803
+ var inner = this . node ( 'variable' ) ;
7793
7804
name = this . text ( ) . substring ( 1 ) ;
7794
7805
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
+ }
7797
7813
} else if ( this . token === '{' ) {
7798
- // fix $obj->var_{$prop}
7799
- what = [ 'bin' , '.' , what , this . next ( ) . read_expr ( ) ] ;
7814
+ var expr = this . next ( ) . read_expr ( ) ;
7800
7815
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
+ }
7801
7823
}
7802
7824
break ;
7803
7825
case this . tok . T_VARIABLE :
0 commit comments