ext/standard: Change return type of header_register_callback() to true - #23402
Merged
LamentXU123 merged 1 commit intoAug 21, 2026
Merged
Conversation
…back() 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.
LamentXU123
approved these changes
Aug 21, 2026
LamentXU123
left a comment
Member
There was a problem hiding this comment.
This seems correct. But since this is sapi stuff cc @NattyNarwhal
Member
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
header_register_callback()is declared as returningbool, butPHP_FUNCTION(header_register_callback)inmain/SAPI.chas a single non-throwing exit,RETURN_TRUE.The
falsereturn is a leftover from PHP 7:PHP 8.0.0 moved the check to the
fparameter specifier, which throws aTypeError, and theRETURN_FALSEwent 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'],__invokeobject, first-class callable syntax) returnstrue, an invalid callback throwsTypeError, and registering afterheaders_sent()is alreadytrue— the case where the callback is knowingly discarded — returnstrueas well.truebeing a subtype ofbool, the only observable change is what Reflection reports.Whether the
headers_sentbranch ought to report failure instead is a behaviour question, deliberately left out of this change.