[php-src] PHP-8.5: zend_test: Backport zend_test_compile_to_ast() function

From: Date: Thu, 22 Oct 2026 19:07:23 +0000
Subject: [php-src] PHP-8.5: zend_test: Backport zend_test_compile_to_ast() function
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142605@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-10-22T21:05:25+02:00 Commit: https://github.com/php/php-src/commit/359ce15176df8a115cf8bc99e9df46d4dd1fe13f Raw diff: https://github.com/php/php-src/commit/359ce15176df8a115cf8bc99e9df46d4dd1fe13f.diff zend_test: Backport zend_test_compile_to_ast() function This was introduced in 8.5. We need this in 8.4 too to debug AST dumping (see GH-24418). Changed paths: M ext/zend_test/test.c M ext/zend_test/test.stub.php M ext/zend_test/test_arginfo.h Diff: diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 42619c626027..09940e664e11 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -1792,6 +1792,28 @@ static PHP_FUNCTION(zend_test_create_throwing_resource) ZVAL_RES(return_value, res); } +static PHP_FUNCTION(zend_test_compile_to_ast) +{ + zend_string *str; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(str) + ZEND_PARSE_PARAMETERS_END(); + + zend_arena *ast_arena; + zend_ast *ast = zend_compile_string_to_ast(str, &ast_arena, ZSTR_EMPTY_ALLOC()); + if (!ast) { + RETURN_THROWS(); + } + + zend_string *result = zend_ast_export("", ast, ""); + + zend_ast_destroy(ast); + zend_arena_destroy(ast_arena); + + RETVAL_STR(result); +} + static PHP_FUNCTION(zend_test_gh18756) { ZEND_PARSE_PARAMETERS_NONE(); diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index caf3fbac08ed..6ea169d315b7 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -330,6 +330,8 @@ function zend_test_is_zend_ptr(int $addr): bool {} function zend_test_log_err_debug(string $str): void {} + function zend_test_compile_to_ast(string $str): string {} + function zend_test_gh18756(): void {} /** @compile-time-eval */ diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 43f347488780..aa11ba1f77cb 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: d22337c57d9b921e17a7db0673f10de3cc572421 */ + * Stub hash: de4bd0213b06d7be9e5a55ef7757ca137b03fa0e */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_array_return, 0, 0, IS_ARRAY, 0) ZEND_END_ARG_INFO() @@ -186,6 +186,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_log_err_debug, 0, 1, I ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) ZEND_END_ARG_INFO() +#define arginfo_zend_test_compile_to_ast arginfo_zend_create_unterminated_string + #define arginfo_zend_test_gh18756 arginfo_zend_test_void_return #define arginfo_zend_test_gh19792 arginfo_zend_test_void_return @@ -336,6 +338,7 @@ static ZEND_FUNCTION(zend_test_set_fmode); static ZEND_FUNCTION(zend_test_cast_fread); static ZEND_FUNCTION(zend_test_is_zend_ptr); static ZEND_FUNCTION(zend_test_log_err_debug); +static ZEND_FUNCTION(zend_test_compile_to_ast); static ZEND_FUNCTION(zend_test_gh18756); static ZEND_FUNCTION(zend_test_gh19792); static ZEND_FUNCTION(zend_test_handle_post_data); @@ -449,6 +452,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_test_cast_fread, arginfo_zend_test_cast_fread) ZEND_FE(zend_test_is_zend_ptr, arginfo_zend_test_is_zend_ptr) ZEND_FE(zend_test_log_err_debug, arginfo_zend_test_log_err_debug) + ZEND_FE(zend_test_compile_to_ast, arginfo_zend_test_compile_to_ast) ZEND_FE(zend_test_gh18756, arginfo_zend_test_gh18756) #if (PHP_VERSION_ID >= 80400) ZEND_RAW_FENTRY("zend_test_gh19792", zif_zend_test_gh19792, arginfo_zend_test_gh19792, ZEND_ACC_COMPILE_TIME_EVAL, NULL, NULL)

« previous php.cvs (#142605) next »