@@ -303,7 +303,24 @@ static void ast_fill_children_ht(HashTable *ht, zend_ast *ast, zend_long version
303
303
}
304
304
}
305
305
306
- if (ast_is_name (child , ast , i )) {
306
+ /* These two AST_CATCH checks should occur before ast_is_name() */
307
+ #if PHP_VERSION_ID >= 70100
308
+ if (ast -> kind == ZEND_AST_CATCH && version < 35
309
+ && i == 0 && zend_ast_get_list (child )-> children == 1 ) {
310
+ /* Emulate PHP 7.0 format (no list) */
311
+ ast_create_virtual_node (
312
+ & child_zv , AST_NAME , zend_ast_get_list (child )-> child [0 ], version );
313
+ }
314
+ #else
315
+ if (ast -> kind == ZEND_AST_CATCH && version >= 35 && i == 0 ) {
316
+ /* Emulate PHP 7.1 format (name list) */
317
+ zval tmp ;
318
+ ast_create_virtual_node (& tmp , AST_NAME , child , version );
319
+ ast_create_virtual_node_ex (
320
+ & child_zv , ZEND_AST_NAME_LIST , 0 , zend_ast_get_lineno (child ), & tmp , version );
321
+ }
322
+ #endif
323
+ else if (ast_is_name (child , ast , i )) {
307
324
zend_uchar type ;
308
325
zend_bool is_nullable = 0 ;
309
326
if (child -> attr & ZEND_TYPE_NULLABLE ) {
@@ -357,20 +374,6 @@ static void ast_fill_children_ht(HashTable *ht, zend_ast *ast, zend_long version
357
374
&& (ast -> kind == ZEND_AST_PROP_ELEM || ast -> kind == ZEND_AST_CONST_ELEM )) {
358
375
/* Skip docComment child -- It's handled separately */
359
376
continue ;
360
- #if PHP_VERSION_ID >= 70100
361
- } else if (ast -> kind == ZEND_AST_CATCH && version < 35
362
- && i == 0 && zend_ast_get_list (child )-> children == 1 ) {
363
- /* Emulate PHP 7.0 format (no list) */
364
- ast_create_virtual_node (
365
- & child_zv , AST_NAME , zend_ast_get_list (child )-> child [0 ], version );
366
- #else
367
- } else if (ast -> kind == ZEND_AST_CATCH && version >= 35 ) {
368
- /* Emulate PHP 7.1 format (name list) */
369
- zval tmp ;
370
- ast_create_virtual_node (& tmo , AST_NAME , child , version );
371
- ast_create_virtual_node_ex (
372
- & child_zv , ZEND_AST_NAME_LIST , 0 , zend_ast_get_lineno (child ), & tmp , version );
373
- #endif
374
377
} else {
375
378
ast_to_zval (& child_zv , child , version );
376
379
}
0 commit comments