Commit 89a17252a49 for php.net
commit 89a17252a495202895a219ff93c1a08d3acee863
Author: Ondrej Mirtes <ondrej@mirtes.cz>
Date: Fri Jul 10 12:32:07 2026 +0200
Make strtolower()/strtoupper() frameless
Both are single-argument wrappers around zend_string_tolower/upper;
static analyzers and general string handling call them at very high
frequency. The frameless call convention removes the call frame setup
and argument copying.
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
Closes GH-23084
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php
index 9f52df10e1d..c87e2243340 100644
--- a/ext/standard/basic_functions.stub.php
+++ b/ext/standard/basic_functions.stub.php
@@ -2368,10 +2368,16 @@ function join(string|array $separator, ?array $array = null): string {}
*/
function strtok(string $string, ?string $token = null): string|false {}
-/** @compile-time-eval */
+/**
+ * @compile-time-eval
+ * @frameless-function {"arity": 1}
+ */
function strtoupper(string $string): string {}
-/** @compile-time-eval */
+/**
+ * @compile-time-eval
+ * @frameless-function {"arity": 1}
+ */
function strtolower(string $string): string {}
function str_increment(string $string): string {}
diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h
index 0155187f161..ab8c57d4e8d 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 40e4c918ba6..02203be0df4 100644
Binary files a/ext/standard/basic_functions_decl.h and b/ext/standard/basic_functions_decl.h differ
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 91c930515b7..e5307a4f2d4 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1192,6 +1192,19 @@ PHP_FUNCTION(strtoupper)
}
/* }}} */
+ZEND_FRAMELESS_FUNCTION(strtoupper, 1)
+{
+ zval str_tmp;
+ zend_string *str;
+
+ Z_FLF_PARAM_STR(1, str, str_tmp);
+
+ RETVAL_STR(zend_string_toupper(str));
+
+flf_clean:
+ Z_FLF_PARAM_FREE_STR(1, str_tmp);
+}
+
/* {{{ Makes a string lowercase */
PHP_FUNCTION(strtolower)
{
@@ -1205,6 +1218,19 @@ PHP_FUNCTION(strtolower)
}
/* }}} */
+ZEND_FRAMELESS_FUNCTION(strtolower, 1)
+{
+ zval str_tmp;
+ zend_string *str;
+
+ Z_FLF_PARAM_STR(1, str, str_tmp);
+
+ RETVAL_STR(zend_string_tolower(str));
+
+flf_clean:
+ Z_FLF_PARAM_FREE_STR(1, str_tmp);
+}
+
PHP_FUNCTION(str_increment)
{
zend_string *str;