Commit a9ba369abe4 for php.net

commit a9ba369abe43a4947e4015171f0111c4a816a630
Author: Gina Peter Banyard <girgias@php.net>
Date:   Wed Aug 5 14:56:06 2026 +0100

    Zend: deprecate naming a function readonly

    RFC: https://wiki.php.net/rfc/deprecations_php_8_6#deprecate_the_possibility_to_name_a_function_readonly

diff --git a/Zend/tests/functions/readonly_as_fn_name_is_deprecated.phpt b/Zend/tests/functions/readonly_as_fn_name_is_deprecated.phpt
new file mode 100644
index 00000000000..2ac975dcf65
--- /dev/null
+++ b/Zend/tests/functions/readonly_as_fn_name_is_deprecated.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Naming a function readonly is deprecated
+--FILE--
+<?php
+
+function readonly() {}
+
+?>
+DONE
+--EXPECTF--
+Deprecated: Calling a function “readonly” is deprecated in %s on line %d
+DONE
diff --git a/Zend/tests/functions/readonly_as_fn_name_is_deprecated_namespaced.phpt b/Zend/tests/functions/readonly_as_fn_name_is_deprecated_namespaced.phpt
new file mode 100644
index 00000000000..f4b39d6c3e5
--- /dev/null
+++ b/Zend/tests/functions/readonly_as_fn_name_is_deprecated_namespaced.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Naming a function readonly is deprecated
+--FILE--
+<?php
+
+namespace Foo;
+
+function readonly() {}
+
+?>
+DONE
+--EXPECTF--
+Deprecated: Calling a function “readonly” is deprecated in %s on line %d
+DONE
diff --git a/Zend/tests/functions/readonly_as_fn_name_is_deprecated_throw_handler.phpt b/Zend/tests/functions/readonly_as_fn_name_is_deprecated_throw_handler.phpt
new file mode 100644
index 00000000000..428bd339d11
--- /dev/null
+++ b/Zend/tests/functions/readonly_as_fn_name_is_deprecated_throw_handler.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Naming a function readonly is deprecated with an error handler elevating it to an exception
+--FILE--
+<?php
+
+set_error_handler(function ($number, $message) {
+	throw new Exception($message);
+});
+
+/* Throwing error handlers do no apply for compile time deprecations */
+function readonly() {}
+
+?>
+DONE
+--EXPECTF--
+Deprecated: Calling a function “readonly” is deprecated in %s on line %d
+DONE
diff --git a/Zend/tests/functions/readonly_as_method_name_is_ok.phpt b/Zend/tests/functions/readonly_as_method_name_is_ok.phpt
new file mode 100644
index 00000000000..373fa735365
--- /dev/null
+++ b/Zend/tests/functions/readonly_as_method_name_is_ok.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Naming a function readonly is deprecated
+--FILE--
+<?php
+
+class C {
+	public function readonly() {}
+}
+
+?>
+DONE
+--EXPECT--
+DONE
diff --git a/Zend/tests/grammar/readonly_function.phpt b/Zend/tests/grammar/readonly_function.phpt
index 35102d36b9d..c1592aa1fe8 100644
--- a/Zend/tests/grammar/readonly_function.phpt
+++ b/Zend/tests/grammar/readonly_function.phpt
@@ -32,7 +32,8 @@ function readonly() {
 echo $b->readonly, "\n";

 ?>
---EXPECT--
+--EXPECTF--
+Deprecated: Calling a function “readonly” is deprecated in %s on line %d
 Hi!
 Const hi!
 Static hi!
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 882b1bf990b..92807513bc6 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -8931,6 +8931,10 @@ static zend_string *zend_begin_func_decl(znode *result, zend_op_array *op_array,
 			"__autoload() is no longer supported, use spl_autoload_register() instead");
 	}

+	if (zend_string_equals_literal_ci(unqualified_name, "readonly")) {
+		zend_error(E_DEPRECATED, "Calling a function “readonly” is deprecated");
+	}
+
 	if (zend_string_equals_literal_ci(unqualified_name, "assert")) {
 		zend_error(E_COMPILE_ERROR,
 			"Defining a custom assert() function is not allowed, "