File tree 2 files changed +26
-0
lines changed 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -405,6 +405,19 @@ module.exports = {
405
405
}
406
406
} else if ( this . is ( 'SCALAR' ) ) {
407
407
expr = this . read_scalar ( ) ;
408
+ // handle dereferencable
409
+ while ( this . token !== this . EOF ) {
410
+ if ( this . token === this . tok . T_OBJECT_OPERATOR ) {
411
+ expr = this . recursive_variable_chain_scan ( expr , false ) ;
412
+ } else if ( this . token === this . tok . T_CURLY_OPEN || this . token === '[' ) {
413
+ expr = this . read_dereferencable ( expr ) ;
414
+ } else if ( this . token === '(' ) {
415
+ // https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L1118
416
+ expr = this . node ( 'call' ) ( expr , this . read_function_argument_list ( ) ) ;
417
+ } else {
418
+ return expr ;
419
+ }
420
+ }
408
421
} else {
409
422
this . error ( 'EXPR' ) ;
410
423
this . next ( ) ;
Original file line number Diff line number Diff line change @@ -3,6 +3,19 @@ var parser = require('../src/index');
3
3
4
4
describe ( 'Array without keys' , function ( ) {
5
5
6
+ it ( 'deference array' , function ( ) {
7
+ var ast = parser . parseEval ( [
8
+ '$a = [' ,
9
+ '"a", "b"' ,
10
+ ']($foo)[$foo->bar()[1]]->foo()'
11
+ ] . join ( '\r' ) , {
12
+ parser : {
13
+ debug : true
14
+ }
15
+ } ) ;
16
+ console . log ( ast ) ;
17
+ } ) ;
18
+
6
19
describe ( 'of strings' , function ( ) {
7
20
// Get result from parser
8
21
var ast = parser . parseEval ( 'array("item1", "item2", "item3")' ) ;
You can’t perform that action at this time.
0 commit comments