Summary
PHP 8.4 adds ResponseCode int-backed enum as the typed parameter/return for http_response_code(). This compiler implements int-based http_response_code() (ext/standard/http_response_code.php, lib/Web/ResponseContext.php) but does not register the enum; callers cannot pass ResponseCode::NotFound and reads do not return enum cases.
Issue #6037 covers php-src-strict TypeError when passing arbitrary enum cases to int-only paths; this issue implements the real ResponseCode enum surface.
php-src reference
Repro
./script/docker-exec.sh -- php bin/vm.php test/repro-maintainer/response_code_enum.php
Current: bool(false) for class_exists('ResponseCode'); int path works (http_response_code(404) → int(404))
Expected (Zend PHP 8.4+): enum_exists('ResponseCode'); http_response_code(ResponseCode::NotFound) sets status; getter returns ResponseCode case (or false when unset per Zend).
Implementation (PHP-in-PHP)
- Register
ResponseCode in ext/standard/BuiltinEnums.php.
- Extend
ext/standard/http_response_code.php VM handler + JitHttpResponseCode.php to accept enum case operands and return enum on read (coerce backing int for CGI emit).
- Update
lib/JIT/Builtin/HttpResponseCode.php lowering for enum operands.
- Compliance
.phpt under test/compliance/cases/stdlib/http_response_code_enum.phpt (VM + JIT/AOT).
Done when
Links
#6037 · #7294 · #1492
Summary
PHP 8.4 adds
ResponseCodeint-backed enum as the typed parameter/return forhttp_response_code(). This compiler implements int-basedhttp_response_code()(ext/standard/http_response_code.php,lib/Web/ResponseContext.php) but does not register the enum; callers cannot passResponseCode::NotFoundand reads do not return enum cases.Issue #6037 covers php-src-strict
TypeErrorwhen passing arbitrary enum cases to int-only paths; this issue implements the real ResponseCode enum surface.php-src reference
ext/standard/head.c—zif_http_response_codeext/standard/basic_functions.stub.php—enum ResponseCode: int { … }Repro
Current:
bool(false)forclass_exists('ResponseCode'); int path works (http_response_code(404)→int(404))Expected (Zend PHP 8.4+):
enum_exists('ResponseCode');http_response_code(ResponseCode::NotFound)sets status; getter returnsResponseCodecase (orfalsewhen unset per Zend).Implementation (PHP-in-PHP)
ResponseCodeinext/standard/BuiltinEnums.php.ext/standard/http_response_code.phpVM handler +JitHttpResponseCode.phpto accept enum case operands and return enum on read (coerce backing int for CGI emit).lib/JIT/Builtin/HttpResponseCode.phplowering for enum operands..phptundertest/compliance/cases/stdlib/http_response_code_enum.phpt(VM + JIT/AOT).Done when
enum_exists('ResponseCode')trueLinks
#6037 · #7294 · #1492