From 71d05fb57ed7997e617ab4ab900c3a1712e94191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danijel=20Gali=C4=87?= Date: Fri, 6 Nov 2026 10:41:29 +0100 Subject: [PATCH 1/3] Simplify timezone unit test data setup **Details:** - Replaced external timezone data provider usage with inline `TestWith` data. - Removed the unused `DateDataProvider` import. - Keeps the timezone default setter/getter test focused on a single explicit `Zone` case. --- tests/Unit/Date/TimezoneTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/Unit/Date/TimezoneTest.php b/tests/Unit/Date/TimezoneTest.php index 2efdbfd..7f85d8a 100644 --- a/tests/Unit/Date/TimezoneTest.php +++ b/tests/Unit/Date/TimezoneTest.php @@ -16,9 +16,8 @@ use FireHub\Testing\FireHubTestCase; use FireHub\Runtime\Date; use FireHub\Core\Type\Date\Zone; -use FireHub\Testing\DataProviders\DateDataProvider; use PHPUnit\Framework\Attributes\ { - CoversClass, DataProviderExternal, Group, Small + CoversClass, Group, Small, TestWith }; /** @@ -40,7 +39,7 @@ final class TimezoneTest extends FireHubTestCase { * * @return void */ - #[DataProviderExternal(DateDataProvider::class, 'timezones')] + #[TestWith([Zone::ARCTIC_LONGYEARBYEN])] public function testSetAndGetDefaultTimezone (Zone $expected):void { self::assertTrue(Date\Timezone::setDefault($expected)); From 0ab1fc8b4dbd7c2df36430a7251cc30b593f7126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danijel=20Gali=C4=87?= Date: Tue, 10 Nov 2026 13:14:38 +0100 Subject: [PATCH 2/3] Add native HTTP request and response utilities in `Runtime` **Details:** - Introduced `Request` for retrieving HTTP request headers via `getallheaders`. - Added `Response` wrappers for managing headers, checking sent headers, and handling status codes. - Added native cookie helpers for encoded and raw cookie responses. - Preserves PHP SAPI behavior without additional parsing, validation, or normalization. --- CHANGELOG.md | 5 + README.md | 2 +- src/Http/Request.php | 48 ++++++++++ src/Http/Response.php | 206 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 src/Http/Request.php create mode 100644 src/Http/Response.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 4478978..d2b030a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [[v0.6.0](https://github.com/The-FireHub-Project/Runtime/compare/v0.5.2...v0.6.0)] – 2026-11-10 + +### Added +* Add native HTTP request and response utilities in `Runtime` by @dieselxxx + # [[v0.5.2](https://github.com/The-FireHub-Project/Runtime/compare/v0.5.1...v0.5.2)] – 2026-11-06 ### Added diff --git a/README.md b/README.md index 1b3c7aa..8b97d3e 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ /> version diff --git a/src/Http/Request.php b/src/Http/Request.php new file mode 100644 index 0000000..6258ec5 --- /dev/null +++ b/src/Http/Request.php @@ -0,0 +1,48 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/Apache-2-0 Apache License, Version 2.0 + * + * @php-version >=8.1 + * @package Runtime + */ + +namespace FireHub\Runtime\Http; + +use FireHub\Core\Boundary\Runtime\NativeRuntime; + +use function getallheaders; + +/** + * ### Native HTTP Request Utilities + * + * Provides low-level wrappers for accessing HTTP request information exposed by the PHP Server API (SAPI). + * + * This component preserves native PHP request behavior without introducing HTTP message parsing, validation, or + * normalization. + * @since 1.0.0 + */ +final readonly class Request extends NativeRuntime { + + /** + * ### Gets all HTTP request headers + * + * Fetches all HTTP request headers from the current request. + * + * Header names are returned as provided by the underlying PHP Server API. Header name casing is not normalized. + * @since 1.0.0 + * + * @return array Associative array of HTTP request headers. + */ + public static function headers ():array { + + /** @var array */ + return getallheaders(); + + } + +} \ No newline at end of file diff --git a/src/Http/Response.php b/src/Http/Response.php new file mode 100644 index 0000000..c143070 --- /dev/null +++ b/src/Http/Response.php @@ -0,0 +1,206 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/Apache-2-0 Apache License, Version 2.0 + * + * @php-version >=8.1 + * @package Runtime + */ + +namespace FireHub\Runtime\Http; + +use FireHub\Core\Boundary\Runtime\NativeRuntime; + +use function header; +use function header_remove; +use function headers_list; +use function headers_sent; +use function http_response_code; +use function setcookie; +use function setrawcookie; + +/** + * ### Native HTTP Response Utilities + * + * Provides low-level wrappers for managing HTTP response headers, status codes, and cookies through the PHP Server + * API (SAPI). + * + * This component preserves native PHP response behavior without introducing HTTP message abstractions, validation, + * or normalization. + * @since 1.0.0 + */ +final readonly class Response extends NativeRuntime { + + /** + * ### Sends a raw HTTP header + * + * Sends a raw HTTP header to the client. + * + * The header is scheduled for transmission when PHP sends the response headers. + * @since 1.0.0 + * + * @param string $header

+ * Raw HTTP header string. + *

+ * @param bool $replace [optional]

+ * Whether to replace a previously defined similar header. + *

+ * @param int $response_code [optional]

+ * HTTP response status code. A value of 0 preserves PHP's default behavior. + *

+ * + * @return void + */ + public static function sendHeader (string $header, bool $replace = true, int $response_code = 0):void { + + header($header, $replace, $response_code); + + } + + /** + * ### Removes a previously set HTTP header + * + * Removes a previously scheduled HTTP response header. + * + * If no header name is provided, all previously scheduled headers are removed. + * @since 1.0.0 + * + * @param null|string $name [optional]

+ * Header name to remove, or null to remove all headers. + *

+ * + * @return void + */ + public static function removeHeader (?string $name = null):void { + + header_remove($name); + + } + + /** + * ### Gets all response headers + * + * Returns a list of HTTP response headers that have been prepared for transmission. + * @since 1.0.0 + * + * @return list List of HTTP response headers. + */ + public static function headers ():array { + + return headers_list(); + + } + + /** + * ### Checks whether HTTP headers have been sent + * + * Determines whether HTTP response headers have already been sent to the client. + * + * When headers have been sent, the optional output parameters contain the filename and line number where the + * output started. + * @since 1.0.0 + * + * @param string|null $file [optional]

+ * Receives the filename where output started. + *

+ * @param int|null $line [optional]

+ * Receives the line number where output started. + *

+ * + * @return bool True if headers have already been sent, false otherwise. + */ + public static function headersSent (?string &$file = null, ?int &$line = null):bool { + + return headers_sent($file, $line); + + } + + /** + * ### Gets or sets the HTTP response status code + * + * Retrieves the current HTTP response status code or sets a new response status code. + * @since 1.0.0 + * + * @param int $code [optional]

+ * HTTP response status code to set, or null to retrieve the current status code. + *

+ * + * @return int|bool Current or previous HTTP response status code, or false if no status code is available. + */ + public static function statusCode (int $code = 0):int|bool { + + return http_response_code($code); + + } + + /** + * ### Sends an HTTP cookie + * + * Sends a cookie using PHP's native cookie handling. + * + * The cookie value is URL-encoded automatically. + * @since 1.0.0 + * + * @param string $name

+ * Cookie name. + *

+ * @param string $value [optional]

+ * Cookie value. + *

+ * @param array{ + * expires?: int, + * path?: string, + * domain?: string, + * secure?: bool, + * httponly?: bool, + * samesite?: 'Lax'|'lax'|'None'|'none'|'Strict'|'strict', + * partitioned?: bool + * } $options [optional]

+ * Cookie configuration options. + *

+ * + * @return bool True on success, false otherwise. + */ + public static function setCookie (string $name, string $value = '', array $options = []):bool { + + return setcookie($name, $value, $options); + + } + + /** + * ### Sends a raw HTTP cookie + * + * Sends a cookie without URL-encoding its value. + * @since 1.0.0 + * + * @param string $name

+ * Cookie name. + *

+ * @param string $value [optional]

+ * Raw cookie value. + *

+ * @param array{ + * expires?: int, + * path?: string, + * domain?: string, + * secure?: bool, + * httponly?: bool, + * samesite?: 'Lax'|'lax'|'None'|'none'|'Strict'|'strict', + * partitioned?: bool + * } $options [optional]

+ * Cookie configuration options. + *

+ * + * @return bool True on success, false otherwise. + */ + public static function setRawCookie (string $name, string $value = '', array $options = []):bool { + + return setrawcookie($name, $value, $options); + + } + +} \ No newline at end of file From 243aa4003e301e28ee6b8dad12032b2cc6976ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danijel=20Gali=C4=87?= <56673130+dieselxxx@users.noreply.github.com> Date: Tue, 10 Nov 2026 13:15:49 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 111 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 8b97d3e..022e41e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ PHP Runtime Foundation
release @@ -22,25 +22,46 @@ /> -[![PHPStan](https://github.com/The-FireHub-Project/Runtime/actions/workflows/PHPStan.yml/badge.svg?branch=develop)](https://github.com/The-FireHub-Project/Runtime/actions/workflows/PHPStan.yml) -[![PHPUnit](https://github.com/The-FireHub-Project/Runtime/actions/workflows/PHPUnit.yml/badge.svg?branch=develop)](https://github.com/The-FireHub-Project/Runtime/actions/workflows/PHPUnit.yml) -[![Codecov](https://codecov.io/gh/The-FireHub-Project/Runtime/branch/develop/graph/badge.svg?token=XW2YEONF51)](https://app.codecov.io/gh/The-FireHub-Project/Runtime/tree/develop) -

- + + GitHub created at + GitHub last commit (branch) - + GitHub activity (branch) - + + GitHub contributors + GitHub commit difference between two branches + + GitHub top language + + GitHub repo size + + GitHub code size

@@ -54,47 +75,55 @@ Its role is to provide a consistent execution foundation between native PHP capa --- -## FireHub Icon Development Branch +## FireHub Icon Repository Purpose -⚠️ **This is the `develop` branch** +This repository provides a lightweight PHP runtime abstraction layer that wraps native PHP functionality into clean, consistent, and deterministic APIs. -- Unstable -- APIs may change without notice -- Not intended for production use +Its purpose is to reduce boilerplate and standardize common execution patterns across the FireHub ecosystem by offering ergonomic helper classes for arrays, strings, files, environment access, and other low-level runtime operations. -## FireHub Icon Branch Purpose +It is strictly focused on execution-level concerns and does not contain domain logic, business rules, or framework-level orchestration. It exists to improve developer productivity while preserving native PHP behavior and ensuring zero framework coupling. -The `develop` branch is the **primary integration branch** for all ongoing development. +## FireHub Icon Security -It serves as the staging area where: -- Feature branches are merged -- Bug fixes are integrated -- Experimental work is stabilized -- Code is prepared for upcoming releases +For security reporting and guidelines, please refer to our [SECURITY.md](https://github.com/The-FireHub-Project/.github/blob/master/.github/SECURITY.md) file. -All **release branches** are created **from `develop`**. +## FireHub Icon Community -## Stability Guarantee +![GitHub watchers](https://img.shields.io/github/watchers/The-FireHub-Project/Runtime?style=social) +![GitHub Repo stars](https://img.shields.io/github/stars/The-FireHub-Project/Runtime?style=social) +![GitHub forks](https://img.shields.io/github/forks/The-FireHub-Project/Runtime?style=social) -❌ No backward compatibility guarantee -❌ APIs may change without notice -❌ Behavior may be incomplete or inconsistent -❌ Breaking changes are expected +- Be sure to review the [Code of Conduct](https://github.com/The-FireHub-Project/.github/blob/master/.github/CODE_OF_CONDUCT.md). +- Read a [Contributing](https://github.com/The-FireHub-Project/.github/blob/master/.github/CONTRIBUTING.md) file to see how you can contribute to this project. +- Read our [Security policy](https://github.com/The-FireHub-Project/.github/blob/master/.github/SECURITY.md) file to see how you can report a vulnerability. +- Review the project [Governance model](https://github.com/The-FireHub-Project/.github/blob/master/.github/GOVERNANCE.md), including roles, decision-making, RFC process, and releases. -This branch is intended **only for contributors and advanced testers**. +## FireHub Icon Support -## FireHub Icon Composer Usage (Not Recommended) +

+ + GitHub in-progress issues + + GitHub total issues + + GitHub opened pull requests +

-For internal testing only: +For help with FireHub products, please refer to the following resources: -```json -{ - "require": { - "the-firehub-project/runtime": "dev-develop" - } -} -``` -⚠️ Never use dev-develop in production. +- **General questions & discussions**: [GitHub Discussions](https://github.com/orgs/The-FireHub-Project/discussions) +- **Bug reports & issues**: [Support](https://github.com/The-FireHub-Project/Runtime/issues) +- **Documentation & guides**: [FireHub Docs](https://the-firehub-project.github.io) +- **Commercial support** (Pro/Enterprise): contact your account manager ## FireHub Icon Authors and Contributors