Skip to content

Stdlib: http_response_code() for 404/500 and API status (#252)#278

Merged
PurHur merged 1 commit into
masterfrom
fix/252-http-response-code
May 19, 2026
Merged

Stdlib: http_response_code() for 404/500 and API status (#252)#278
PurHur merged 1 commit into
masterfrom
fix/252-http-response-code

Conversation

@PurHur
Copy link
Copy Markdown
Owner

@PurHur PurHur commented May 19, 2026

Summary

  • Add VM builtin http_response_code(?int $code = null) backed by request-scoped Web\ResponseContext.
  • Wire bin/serve.php to reset/read status per request; expand DevServer::respond() reason phrases for common codes.
  • Fix void-call execution so statement-form http_response_code(404); runs (no echo required).

Test plan

  • ServeTest::testHttpResponseCodeSetsStatusLine — serve returns HTTP/1.1 404 when script calls http_response_code(404).
  • PHPT test/real/cases/web_http_response_code.phpt — get/set/invalid code semantics.
  • script/capability-matrix.php --check and script/bootstrap-inventory.php --check.
  • Docker: vendor/bin/phpunit test/real/ServeTest.php --filter testHttpResponseCode.

Closes #252.

Made with Cursor

Scripts can set HTTP status via http_response_code(); bin/serve.php reads
ResponseContext after each request. Fixes void-call handling so statement-form
calls take effect without echo.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: http_response_code() for 404/500 and API status

1 participant