Commit fb602cc680a for php.net
commit fb602cc680ae34baa4f0a45933d8825d1f97577a
Author: Louis-Arnaud <la.catoire@gmail.com>
Date: Tue Aug 25 17:36:54 2026 +0200
ext/readline: declare true as the return type of readline_completion_function() (#23433)
The returned value was RETURN_BOOL(rl_attempted_completion_function !=
NULL) on the line right after that variable is assigned the address of
a static function, so it is true unconditionally. Return true directly
and declare it.
diff --git a/UPGRADING b/UPGRADING
index f015399f645..f3b4ed8b99f 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -652,6 +652,12 @@ PHP 8.6 UPGRADE NOTES
- Phar:
. Phar::mungServer() now supports reference values.
+- Readline:
+ . readline_completion_function() now declares true as its return type. The
+ function assigns a static callback and then tests whether the assignment
+ landed, which is a tautology; an invalid callback throws a TypeError via
+ ZPP before the function body is reached.
+
- Sockets:
. socket_addrinfo_lookup() now has an additional optional argument $error
when not null, and on failure, gives the error code (one of the EAI_*
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index cbc0ebdd871..d9ec274996c 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -489,8 +489,8 @@ PHP_FUNCTION(readline_completion_function)
/* NOTE: The rl_attempted_completion_function variable (and others) are part of the readline library, not php */
rl_attempted_completion_function = php_readline_completion_cb;
-
- RETURN_BOOL(rl_attempted_completion_function != NULL);
+
+ RETURN_TRUE;
}
/* }}} */
diff --git a/ext/readline/readline.stub.php b/ext/readline/readline.stub.php
index be445df2141..4dae1237c60 100644
--- a/ext/readline/readline.stub.php
+++ b/ext/readline/readline.stub.php
@@ -29,7 +29,7 @@ function readline_read_history(?string $filename = null): bool {}
function readline_write_history(?string $filename = null): bool {}
-function readline_completion_function(callable $callback): bool {}
+function readline_completion_function(callable $callback): true {}
#ifdef HAVE_RL_CALLBACK_READ_CHAR
diff --git a/ext/readline/readline_arginfo.h b/ext/readline/readline_arginfo.h
index 689d5f762ee..1ce08c443ee 100644
Binary files a/ext/readline/readline_arginfo.h and b/ext/readline/readline_arginfo.h differ