Commit 4561d52aaf1 for php
commit 4561d52aaf1a786ca80bf3347e482f1c97a96c34
Author: Alexander Danilov <10532067+adapik@users.noreply.github.com>
Date: Sat Oct 10 00:32:28 2026 +0300
Mark several functions with `@compile-time-eval` attribute. (#24212)
diff --git a/ext/opcache/tests/opt/ct_eval_md5_sha1.phpt b/ext/opcache/tests/opt/ct_eval_md5_sha1.phpt
new file mode 100644
index 00000000000..152533a5ada
--- /dev/null
+++ b/ext/opcache/tests/opt/ct_eval_md5_sha1.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Compile-time evaluation of md5() and sha1()
+--EXTENSIONS--
+opcache
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.opt_debug_level=0x20000
+zend_test.observer.enabled=0
+--FILE--
+<?php
+function test() {
+ return [
+ md5('hello'),
+ bin2hex(md5('hello', true)),
+ sha1('hello'),
+ bin2hex(sha1('hello', true)),
+ ];
+}
+var_dump(test());
+?>
+--EXPECTF--
+$_main:
+ ; (lines=6, args=0, vars=0, tmps=1)
+ ; (after optimizer)
+ ; %sct_eval_md5_sha1.php:1-12
+0000 INIT_FCALL 1 %d string("var_dump")
+0001 INIT_FCALL 0 %d string("test")
+0002 T0 = DO_UCALL
+0003 SEND_VAL T0 1
+0004 DO_ICALL
+0005 RETURN int(1)
+
+test:
+ ; (lines=1, args=0, vars=0, tmps=0)
+ ; (after optimizer)
+ ; %sct_eval_md5_sha1.php:2-9
+0000 RETURN array(...)
+array(4) {
+ [0]=>
+ string(32) "5d41402abc4b2a76b9719d911017c592"
+ [1]=>
+ string(32) "5d41402abc4b2a76b9719d911017c592"
+ [2]=>
+ string(40) "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
+ [3]=>
+ string(40) "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
+}
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php
index 8d4d8bd9e8b..e55993eeb23 100644
--- a/ext/standard/basic_functions.stub.php
+++ b/ext/standard/basic_functions.stub.php
@@ -2194,7 +2194,10 @@ function hrtime(bool $as_number = false): array|int|float|false {}
/* md5.c */
-/** @refcount 1 */
+/**
+ * @refcount 1
+ * @compile-time-eval
+ */
function md5(string $string, bool $binary = false): string {}
/** @refcount 1 */
@@ -2214,7 +2217,10 @@ function getlastmod(): int|false {}
/* sha1.c */
-/** @refcount 1 */
+/**
+ * @refcount 1
+ * @compile-time-eval
+ */
function sha1(string $string, bool $binary = false): string {}
/** @refcount 1 */
diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h
index b0eb39090e0..a4bab4cbbb9 100644
Binary files a/ext/standard/basic_functions_arginfo.h and b/ext/standard/basic_functions_arginfo.h differ
diff --git a/ext/standard/basic_functions_decl.h b/ext/standard/basic_functions_decl.h
index 7ed3c749a28..5f1ea26850c 100644
Binary files a/ext/standard/basic_functions_decl.h and b/ext/standard/basic_functions_decl.h differ