File tree 2 files changed +19
-3
lines changed
2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -279,22 +279,25 @@ module.exports = {
279
279
if ( this . token === ':' ) {
280
280
this . nextWithComments ( ) ;
281
281
while ( this . token != this . EOF && this . token !== this . tok . T_ENDDECLARE ) {
282
- body . push ( this . read_statement ( ) ) ;
282
+ // @todo : check declare_statement from php / not valid
283
+ body . push ( this . read_top_statement ( ) ) ;
283
284
}
284
285
this . expect ( this . tok . T_ENDDECLARE ) && this . next ( ) ;
285
286
this . expectEndOfStatement ( ) ;
286
287
mode = this . ast . declare . MODE_SHORT ;
287
288
} else if ( this . token === '{' ) {
288
289
this . nextWithComments ( ) ;
289
290
while ( this . token != this . EOF && this . token !== '}' ) {
290
- body . push ( this . read_statement ( ) ) ;
291
+ // @todo : check declare_statement from php / not valid
292
+ body . push ( this . read_top_statement ( ) ) ;
291
293
}
292
294
this . expect ( '}' ) && this . next ( ) ;
293
295
mode = this . ast . declare . MODE_BLOCK ;
294
296
} else {
295
297
this . expect ( ';' ) && this . next ( ) ;
296
298
while ( this . token != this . EOF && this . token !== this . tok . T_DECLARE ) {
297
- body . push ( this . read_statement ( ) ) ;
299
+ // @todo : check declare_statement from php / not valid
300
+ body . push ( this . read_top_statement ( ) ) ;
298
301
}
299
302
mode = this . ast . declare . MODE_NONE ;
300
303
}
Original file line number Diff line number Diff line change @@ -82,4 +82,17 @@ describe('Test namespace statements', function() {
82
82
nsKeyword . children [ 0 ] . what . name . should . be . exactly ( 'foo' ) ;
83
83
// @todo : test second child
84
84
} ) ;
85
+
86
+ it ( 'should work with declare statement' , function ( ) {
87
+ var ast = parser . parseEval ( [
88
+ 'declare(strict_types=1);' ,
89
+ 'namespace foo;' ,
90
+ 'class bar {}'
91
+ ] . join ( '\n' ) , {
92
+ parser : {
93
+ debug : false
94
+ }
95
+ } ) ;
96
+ // @todo : make assertions
97
+ } ) ;
85
98
} ) ;
You can’t perform that action at this time.
0 commit comments