[php-src] master: Merge branch 'PHP-8.6'

From: Date: Sat, 24 Oct 2026 12:53:43 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142673@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-10-24T14:53:34+02:00 Commit: https://github.com/php/php-src/commit/84cf35b576e39928fb44c979cabb3bc2dc2ff2cb Raw diff: https://github.com/php/php-src/commit/84cf35b576e39928fb44c979cabb3bc2dc2ff2cb.diff Merge branch 'PHP-8.6' * PHP-8.6: zend_test: Fix function and constant imports in compile_to_ast and add support for grouping Changed paths: A ext/zend_test/tests/compile_to_ast/namespace.phpt M Zend/zend_ast.c Diff: diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index b81296599d6d..e6b7dd32e28c 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -2531,9 +2531,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio break; case ZEND_AST_USE: smart_str_appends(str, "use "); - if (ast->attr == T_FUNCTION) { + if (ast->attr == ZEND_SYMBOL_FUNCTION) { smart_str_appends(str, "function "); - } else if (ast->attr == T_CONST) { + } else if (ast->attr == ZEND_SYMBOL_CONST) { smart_str_appends(str, "const "); } goto simple_list; @@ -2973,6 +2973,19 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio } break; case ZEND_AST_USE_ELEM: + if (ast->attr == ZEND_SYMBOL_FUNCTION) { + smart_str_appends(str, "function "); + } else if (ast->attr == ZEND_SYMBOL_CONST) { + smart_str_appends(str, "const "); + } + + zend_ast_export_name(str, ast->child[0], 0, indent); + + if (ast->child[1]) { + smart_str_appends(str, " as "); + zend_ast_export_name(str, ast->child[1], 0, indent); + } + break; case ZEND_AST_TRAIT_ALIAS: zend_ast_export_name(str, ast->child[0], 0, indent); if (ast->attr & ZEND_ACC_PUBLIC) { @@ -2994,6 +3007,18 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio smart_str_appends(str, ": "); ast = ast->child[1]; goto tail_call; + case ZEND_AST_GROUP_USE: + smart_str_appends(str, "use "); + if (ast->attr == ZEND_SYMBOL_FUNCTION) { + smart_str_appends(str, "function "); + } else if (ast->attr == ZEND_SYMBOL_CONST) { + smart_str_appends(str, "const "); + } + smart_str_append(str, zend_ast_get_str(ast->child[0])); + smart_str_appends(str, "\\{"); + zend_ast_export_list(str, zend_ast_get_list(ast->child[1]), true, 20, indent); + smart_str_appends(str, "}"); + break; /* 3 child nodes */ case ZEND_AST_METHOD_CALL: diff --git a/ext/zend_test/tests/compile_to_ast/namespace.phpt b/ext/zend_test/tests/compile_to_ast/namespace.phpt new file mode 100644 index 000000000000..ee0165a2600b --- /dev/null +++ b/ext/zend_test/tests/compile_to_ast/namespace.phpt @@ -0,0 +1,68 @@ +--TEST-- +AST can be recreated (namespace) +--EXTENSIONS-- +zend_test +--FILE-- +<?php + +namespace Foo { + class FooTest { + } + + function fn_foo() { + } + + function fn_bar() { + } +} + +namespace Bar { + class BarTest { + } + + function fn_bar() { + } +} + +namespace { + use function Bar\fn_bar; + use Foo\{function fn_foo, FooTest, function fn_bar as fn_foobar}; + + new FooTest(); + fn_bar(); + fn_foobar(); + + echo zend_test_compile_to_ast(file_get_contents( __FILE__ )); +} + +?> +--EXPECT-- +namespace Foo { + class FooTest { + } + + function fn_foo() { + } + + function fn_bar() { + } + +} + +namespace Bar { + class BarTest { + } + + function fn_bar() { + } + +} + +namespace { + use function Bar\fn_bar; + use Foo\{function fn_foo, FooTest, function fn_bar as fn_foobar}; + new FooTest(); + fn_bar(); + fn_foobar(); + echo zend_test_compile_to_ast(file_get_contents(__FILE__)); +}

« previous php.cvs (#142673) next »