Commit 7c0b9008963 for php
commit 7c0b9008963e0fbffd4d71f92e01e2ac2b8ec410
Author: Jorg Sowa <jorg.sowa@gmail.com>
Date: Thu Nov 5 00:57:54 2026 +0100
Fix AST printing of qualified names in name lists
Closes GH-25066
diff --git a/NEWS b/NEWS
index 0e2a521673f..6d29a2e891b 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ PHP NEWS
- Core:
. Fixed AST printing of interface extends list as implements. (Jorg Sowa)
+ . Fixed AST printing dropping fully qualified and namespace-relative prefixes
+ of class names in implements, catch, and trait use lists. (Jorg Sowa)
- Curl:
. Fixed curl_reset() retaining CURLOPT_PRIVATE after reset. (lacatoire)
diff --git a/Zend/tests/assert/expect_qualified_name_lists.phpt b/Zend/tests/assert/expect_qualified_name_lists.phpt
new file mode 100644
index 00000000000..24c54b7bee0
--- /dev/null
+++ b/Zend/tests/assert/expect_qualified_name_lists.phpt
@@ -0,0 +1,37 @@
+--TEST--
+AST printing of fully qualified and namespace-relative names in name lists
+--INI--
+zend.assertions=1
+--FILE--
+<?php
+
+try {
+ assert(false && function () {
+ class C implements \A, namespace\B, C {
+ use \T1, namespace\T2, T3 {
+ \T1::foo insteadof namespace\T2, T3;
+ namespace\T2::foo as bar;
+ }
+ }
+ try {
+ } catch (\E1 | namespace\E2 | E3 $e) {
+ }
+ });
+} catch (AssertionError $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+assert(false && function () {
+ class C implements \A, namespace\B, C {
+ use \T1, namespace\T2, T3 {
+ \T1::foo insteadof namespace\T2, T3;
+ namespace\T2::foo as bar;
+ }
+ }
+
+ try {
+ } catch (\E1|namespace\E2|E3 $e) {
+ }
+})
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c
index eec705588a1..dc40c15fc45 100644
--- a/Zend/zend_ast.c
+++ b/Zend/zend_ast.c
@@ -1497,7 +1497,7 @@ static ZEND_COLD void zend_ast_export_name_list_ex(smart_str *str, zend_ast_list
if (i != 0) {
smart_str_appends(str, separator);
}
- zend_ast_export_name(str, list->child[i], 0, indent);
+ zend_ast_export_ns_name(str, list->child[i], 0, indent);
i++;
}
}
@@ -2481,7 +2481,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
break;
case ZEND_AST_METHOD_REFERENCE:
if (ast->child[0]) {
- zend_ast_export_name(str, ast->child[0], 0, indent);
+ zend_ast_export_ns_name(str, ast->child[0], 0, indent);
smart_str_appends(str, "::");
}
zend_ast_export_name(str, ast->child[1], 0, indent);