From f0acc519e8d2f068a0c9baa90fd560e84b5de9e8 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Wed, 12 Aug 2026 11:59:44 -0700 Subject: [PATCH 1/2] Add regression tests for calling `zend_version()` --- ext/opcache/tests/zend_version.phpt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ext/opcache/tests/zend_version.phpt diff --git a/ext/opcache/tests/zend_version.phpt b/ext/opcache/tests/zend_version.phpt new file mode 100644 index 000000000000..e61a0d46cfc6 --- /dev/null +++ b/ext/opcache/tests/zend_version.phpt @@ -0,0 +1,27 @@ +--TEST-- +zend_version() should be evaluated at compile time +--EXTENSIONS-- +opcache +--INI-- +opcache.enable_cli=1 +opcache.opt_debug_level=0x20000 +--FILE-- + +--EXPECTF-- +$_main: + ; (lines=7, args=0, vars=1, tmps=%d) + ; (after optimizer) + ; %s.php:%s +0000 INIT_FCALL 0 %d string("zend_version") +0001 T1 = DO_ICALL +0002 ASSIGN CV0($v) T1 +0003 INIT_FCALL 1 %d string("var_dump") +0004 SEND_VAR CV0($v) 1 +0005 DO_ICALL +0006 RETURN int(1) +string(%d) "%s" From 57e212d53cd2a452668a2a720307463918b77498 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Wed, 12 Aug 2026 12:02:19 -0700 Subject: [PATCH 2/2] Mark `zend_version()` as `@compile-time-eval` --- Zend/zend_builtin_functions.stub.php | 5 ++++- Zend/zend_builtin_functions_arginfo.h | 4 ++-- ext/opcache/tests/zend_version.phpt | 14 ++++++-------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Zend/zend_builtin_functions.stub.php b/Zend/zend_builtin_functions.stub.php index 1d405587145d..16ce7e2be8ca 100644 --- a/Zend/zend_builtin_functions.stub.php +++ b/Zend/zend_builtin_functions.stub.php @@ -15,7 +15,10 @@ function exit(string|int $status = 0): never {} /** @alias exit */ function die(string|int $status = 0): never {} -/** @refcount 1 */ +/** + * @refcount 1 + * @compile-time-eval + */ function zend_version(): string {} /** @forbid-dynamic-calls */ diff --git a/Zend/zend_builtin_functions_arginfo.h b/Zend/zend_builtin_functions_arginfo.h index b3af43fef340..fc8d8270b016 100644 --- a/Zend/zend_builtin_functions_arginfo.h +++ b/Zend/zend_builtin_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit zend_builtin_functions.stub.php instead. - * Stub hash: 64c61862de86d9968930893bf21b516119724064 */ + * Stub hash: 5d7145b7bc305bb50b45e75c02740206148223b1 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_clone, 0, 1, IS_OBJECT, 0) ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0) @@ -315,7 +315,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(clone, arginfo_clone) ZEND_FE(exit, arginfo_exit) ZEND_RAW_FENTRY("die", zif_exit, arginfo_die, 0, NULL, NULL) - ZEND_FE(zend_version, arginfo_zend_version) + ZEND_RAW_FENTRY("zend_version", zif_zend_version, arginfo_zend_version, ZEND_ACC_COMPILE_TIME_EVAL, NULL, NULL) #if (PHP_VERSION_ID >= 80600) ZEND_RAW_FENTRY("func_num_args", zif_func_num_args, arginfo_func_num_args, ZEND_FENTRY_FLAGS(0, ZEND_ACC2_FORBID_DYN_CALLS), NULL, NULL) #elif (PHP_VERSION_ID >= 80400) diff --git a/ext/opcache/tests/zend_version.phpt b/ext/opcache/tests/zend_version.phpt index e61a0d46cfc6..8f37bdc05353 100644 --- a/ext/opcache/tests/zend_version.phpt +++ b/ext/opcache/tests/zend_version.phpt @@ -14,14 +14,12 @@ var_dump($v); ?> --EXPECTF-- $_main: - ; (lines=7, args=0, vars=1, tmps=%d) + ; (lines=5, args=0, vars=1, tmps=%d) ; (after optimizer) ; %s.php:%s -0000 INIT_FCALL 0 %d string("zend_version") -0001 T1 = DO_ICALL -0002 ASSIGN CV0($v) T1 -0003 INIT_FCALL 1 %d string("var_dump") -0004 SEND_VAR CV0($v) 1 -0005 DO_ICALL -0006 RETURN int(1) +0000 ASSIGN CV0($v) string("%s") +0001 INIT_FCALL 1 %d string("var_dump") +0002 SEND_VAR CV0($v) 1 +0003 DO_ICALL +0004 RETURN int(1) string(%d) "%s"