Skip to content

Stdlib: ResponseCode enum — PHP 8.4 http_response_code() backed enum missing (ext/standard/head.c, pairs #6037) #7322

@PurHur

Description

@PurHur

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)

  1. Register ResponseCode in ext/standard/BuiltinEnums.php.
  2. 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).
  3. Update lib/JIT/Builtin/HttpResponseCode.php lowering for enum operands.
  4. Compliance .phpt under test/compliance/cases/stdlib/http_response_code_enum.phpt (VM + JIT/AOT).

Done when

Links

#6037 · #7294 · #1492

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machinearea:webWeb / CGI / superglobalsenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions