[php-src] PR #23402: ext/standard: Change return type of header_register_callback() to true

From: Date: Fri, 21 Aug 2026 14:01:17 +0000
Subject: [php-src] PR #23402: ext/standard: Change return type of header_register_callback() to true
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-38043@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/23402 Author: lacatoire header_register_callback() is declared as returning bool, but PHP_FUNCTION(header_register_callback) in main/SAPI.c has a single non-throwing exit, RETURN_TRUE. The false return is a leftover from PHP 7: ```c /* php-7.0.0, main/SAPI.c */ if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callback_func) == FAILURE) { return; } if (!zend_is_callable(callback_func, 0, NULL)) { RETURN_FALSE; } ``` PHP 8.0.0 moved the check to the f parameter specifier, which throws a TypeError, and the RETURN_FALSE went away with it. The declared type was never adjusted. Checked on 8.4.22 and 8.5.8: every accepted callable form (closure, function name, Class::method, [$obj, 'method'], __invoke object, first-class callable syntax) returns true, an invalid callback throws TypeError, and registering after headers_sent() is already true — the case where the callback is knowingly discarded — returns true as well. true being a subtype of bool, the only observable change is what Reflection reports. Whether the headers_sent branch ought to report failure instead is a behaviour question, deliberately left out of this change.

« previous php.git-pulls (#38043) next »