[php-src] master: ext/standard: declare true as the return type of header_register_callback() (#23402)

Louis-Arnaud via GitHub <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Louis-Arnaud (lacatoire)
Committer: GitHub (web-flow)
Pusher: LamentXU123
Date: 2026-08-22T03:58:21+08:00

Commit: https://github.com/php/php-src/commit/f89291a94f8ee886b2d5da6851726f846e351bed
Raw diff: https://github.com/php/php-src/commit/f89291a94f8ee886b2d5da6851726f846e351bed.diff

ext/standard: declare true as the return type of header_register_callback() (#23402)

The function has a single non-throwing exit, RETURN_TRUE (main/SAPI.c).
The false return disappeared in PHP 8.0.0: until then an invalid callback
was rejected with RETURN_FALSE, whereas the zend_parse_parameters() 'f'
specifier introduced there throws a TypeError. Registering a callback
after the headers have been sent, the one case where the callback is
knowingly discarded, also returns true.

ksort(), asort() and natsort() already declare true in the same stub.

Changed paths:
  M  UPGRADING
  M  ext/standard/basic_functions.stub.php
  M  ext/standard/basic_functions_arginfo.h
  M  ext/standard/basic_functions_decl.h


Diff:

diff --git a/UPGRADING b/UPGRADING
index b2c488220f20..d8fc594e82f8 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -615,6 +615,9 @@ PHP 8.6 UPGRADE NOTES
     returned.
 
 - Standard:
+  . header_register_callback() now declares true as its return type. It has not
+    been able to return false since PHP 8.0.0, where passing an invalid
+    callback started throwing a TypeError instead.
   . ini_get_all() now includes a "builtin_default_value" element for each
     directive when $details is true. It holds the built-in default value of the
     directive (or null if it has none), independent of values set in php.ini,
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php
index c87e22433400..42cb711512b8 100644
--- a/ext/standard/basic_functions.stub.php
+++ b/ext/standard/basic_functions.stub.php
@@ -1505,7 +1505,7 @@ function set_time_limit(int $seconds): bool {}
 
 /* main/SAPI.c */
 
-function header_register_callback(callable $callback): bool {}
+function header_register_callback(callable $callback): true {}
 
 /* main/output.c */
 
diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h
index ab8c57d4e8d9..a057d3d48be3 100644
--- a/ext/standard/basic_functions_arginfo.h
+++ b/ext/standard/basic_functions_arginfo.h
@@ -1,12 +1,12 @@
 /* This is a generated file, edit basic_functions.stub.php instead.
- * Stub hash: cf2ea35cd867f7091ee1fcf83bbfb543b51e5786
+ * Stub hash: 13b6fd340958d1a7c782c8f5f3685517e62e5edc
  * Has decl header: yes */
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
 	ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_header_register_callback, 0, 1, _IS_BOOL, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_header_register_callback, 0, 1, IS_TRUE, 0)
 	ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0)
 ZEND_END_ARG_INFO()
 
diff --git a/ext/standard/basic_functions_decl.h b/ext/standard/basic_functions_decl.h
index 02203be0df41..ab0a8ec94f7b 100644
--- a/ext/standard/basic_functions_decl.h
+++ b/ext/standard/basic_functions_decl.h
@@ -1,8 +1,8 @@
 /* This is a generated file, edit basic_functions.stub.php instead.
- * Stub hash: cf2ea35cd867f7091ee1fcf83bbfb543b51e5786 */
+ * Stub hash: 13b6fd340958d1a7c782c8f5f3685517e62e5edc */
 
-#ifndef ZEND_BASIC_FUNCTIONS_DECL_cf2ea35cd867f7091ee1fcf83bbfb543b51e5786_H
-#define ZEND_BASIC_FUNCTIONS_DECL_cf2ea35cd867f7091ee1fcf83bbfb543b51e5786_H
+#ifndef ZEND_BASIC_FUNCTIONS_DECL_13b6fd340958d1a7c782c8f5f3685517e62e5edc_H
+#define ZEND_BASIC_FUNCTIONS_DECL_13b6fd340958d1a7c782c8f5f3685517e62e5edc_H
 
 typedef enum zend_enum_SortDirection {
 	ZEND_ENUM_SortDirection_Ascending = 1,
@@ -20,4 +20,4 @@ typedef enum zend_enum_RoundingMode {
 	ZEND_ENUM_RoundingMode_PositiveInfinity = 8,
 } zend_enum_RoundingMode;
 
-#endif /* ZEND_BASIC_FUNCTIONS_DECL_cf2ea35cd867f7091ee1fcf83bbfb543b51e5786_H */
+#endif /* ZEND_BASIC_FUNCTIONS_DECL_13b6fd340958d1a7c782c8f5f3685517e62e5edc_H */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.