File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -84,10 +84,7 @@ module.exports = {
84
84
if ( this . token === this . tok . T_OBJECT_OPERATOR ) {
85
85
return this . recursive_variable_chain_scan ( expr , false ) ;
86
86
} else if ( this . token === this . tok . T_CURLY_OPEN || this . token === '[' ) {
87
- // @fixme - should avoid a new token (could be resolved)
88
- return this . node ( 'deference' ) (
89
- expr , this . read_encapsed_string_item ( )
90
- ) ;
87
+ return this . read_dereferencable ( expr ) ;
91
88
} else if ( this . token === '(' ) {
92
89
// https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L1118
93
90
return this . node ( 'call' ) (
@@ -315,8 +312,7 @@ module.exports = {
315
312
if ( this . token === this . tok . T_OBJECT_OPERATOR ) {
316
313
expr = this . recursive_variable_chain_scan ( expr , false ) ;
317
314
} else if ( this . token === this . tok . T_CURLY_OPEN || this . token === '[' ) {
318
- // @fixme - should avoid a new token (could be resolved)
319
- expr = this . node ( 'deference' ) ( expr , this . read_encapsed_string_item ( ) ) ;
315
+ expr = this . read_dereferencable ( expr ) ;
320
316
} else if ( this . token === '(' ) {
321
317
// https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L1118
322
318
expr = this . node ( 'call' ) ( expr , this . read_function_argument_list ( ) ) ;
Original file line number Diff line number Diff line change @@ -113,6 +113,19 @@ module.exports = {
113
113
}
114
114
}
115
115
}
116
+ /**
117
+ * Handles the dereferencing
118
+ */
119
+ , read_dereferencable : function ( expr ) {
120
+ var result ;
121
+ if ( this . token === '[' ) {
122
+ result = [ 'offset' , expr , this . next ( ) . read_expr ( ) ] ;
123
+ this . expect ( ']' ) . next ( ) ;
124
+ } else if ( this . token === this . tok . T_DOLLAR_OPEN_CURLY_BRACES ) {
125
+ result = [ 'offset' , expr , this . read_encapsed_string_item ( ) ] ;
126
+ }
127
+ return result ;
128
+ }
116
129
/**
117
130
* <ebnf>
118
131
* encapsed_string_item ::= T_ENCAPSED_AND_WHITESPACE | T_DOLLAR_OPEN_CURLY_BRACES ... | variable | T_CURLY_OPEN variable '}'
You can’t perform that action at this time.
0 commit comments