[php-src] master: Fix AST printing of qualified names in name lists

From: Date: Thu, 05 Nov 2026 00:14:44 +0000
Subject: [php-src] master: Fix AST printing of qualified names in name lists
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143339@lists.php.net to get a copy of this message
Author: Jorg Sowa (jorgsowa) Date: 2026-11-05T00:57:54+01:00 Commit: https://github.com/php/php-src/commit/7c0b9008963e0fbffd4d71f92e01e2ac2b8ec410 Raw diff: https://github.com/php/php-src/commit/7c0b9008963e0fbffd4d71f92e01e2ac2b8ec410.diff Fix AST printing of qualified names in name lists Closes GH-25066 Changed paths: A Zend/tests/assert/expect_qualified_name_lists.phpt M NEWS M Zend/zend_ast.c Diff: diff --git a/NEWS b/NEWS index 0e2a521673f0..6d29a2e891bc 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 000000000000..24c54b7bee08 --- /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 eec705588a13..dc40c15fc45e 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);

« previous php.cvs (#143339) next »