Skip to content

Commit 1ba1ca7

Browse files
committed
And fix the PHP 7.0 build again
1 parent 2d3812a commit 1ba1ca7

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

ast.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,24 @@ static void ast_fill_children_ht(HashTable *ht, zend_ast *ast, zend_long version
303303
}
304304
}
305305

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)) {
307324
zend_uchar type;
308325
zend_bool is_nullable = 0;
309326
if (child->attr & ZEND_TYPE_NULLABLE) {
@@ -357,20 +374,6 @@ static void ast_fill_children_ht(HashTable *ht, zend_ast *ast, zend_long version
357374
&& (ast->kind == ZEND_AST_PROP_ELEM || ast->kind == ZEND_AST_CONST_ELEM)) {
358375
/* Skip docComment child -- It's handled separately */
359376
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
374377
} else {
375378
ast_to_zval(&child_zv, child, version);
376379
}

0 commit comments

Comments
 (0)