From 4182305cf4375e93ecc9a0ec8bebe86af2967311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danijel=20Gali=C4=87?= Date: Mon, 12 Oct 2026 09:16:57 +0200 Subject: [PATCH 1/5] Improve `Random` class maximum value handling for consistency and clarity **Details:** - Set `$max` to default to the generator's maximum value (`mt_getrandmax()`) when not explicitly provided. - Removed redundant `mt_getrandmax()` calls by storing the generator's maximum in a `$maximum` variable. - Updated validation logic to ensure `$max` is appropriately bounded between `$min` and the generator's maximum value. - Improved PHPDoc to clarify the default behavior of the `$max` parameter. This update ensures clearer behavior and optimizes internal handling of random number generation boundaries. --- src/Random.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Random.php b/src/Random.php index 504930d..71b7419 100644 --- a/src/Random.php +++ b/src/Random.php @@ -46,6 +46,7 @@ *

* @param null|non-negative-int $max [optional]

* Optional highest value to be returned. + * Defaults to max value supported by the generator. *

* * @throws \FireHub\Runtime\Exception\RandomNumberBelowMinimumException If $min is less than 0. @@ -66,6 +67,10 @@ public static function number (int $min = 0, ?int $max = null):int { ] ); + $maximum = mt_getrandmax(); + + $max ??= $maximum; + if ($max !== null && $max < $min) throw new RandomMaximumBelowMinimumException( 'The maximum value must be greater than or equal to the minimum value.', @@ -75,7 +80,7 @@ public static function number (int $min = 0, ?int $max = null):int { ] ); - if ($max !== null && $max > $maximum = mt_getrandmax()) + if ($max !== null && $max > $maximum) throw new RandomNumberAboveGeneratorMaximumException( 'The maximum value must be less than or equal to the maximum value supported by the generator.', [ From 6dfdb88bbbddf1f4f1827037e97c90947032c1a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danijel=20Gali=C4=87?= Date: Mon, 12 Oct 2026 09:28:01 +0200 Subject: [PATCH 2/5] Suppress PHPStan warnings and refine random value generation checks **Details:** - Added `@phpstan-ignore` in `Arr\Access::array_rand` to suppress type-related warnings for `$number` annotations. - Simplified conditional checks in `Random` class: - Removed redundant `!== null` checks for `$max` in boundary validations. - Ensured proper handling of `$max` and `$min` consistency. - Adjusted `mt_rand` call to avoid nullable `$max`, ensuring type strictness. This update enhances static analysis compatibility and simplifies validation logic for random value handling. --- src/Arr/Access.php | 2 +- src/Random.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Arr/Access.php b/src/Arr/Access.php index 4c70af6..2164e7d 100644 --- a/src/Arr/Access.php +++ b/src/Arr/Access.php @@ -377,7 +377,7 @@ public static function random (array $array, int $number = 1):int|string|array { } /** @var ($number is int<2, max> ? list : TKey) */ - return array_rand($array, $number); + return array_rand($array, $number); // @phpstan-ignore varTag.type } diff --git a/src/Random.php b/src/Random.php index 71b7419..eb70245 100644 --- a/src/Random.php +++ b/src/Random.php @@ -71,7 +71,7 @@ public static function number (int $min = 0, ?int $max = null):int { $max ??= $maximum; - if ($max !== null && $max < $min) + if ($max < $min) throw new RandomMaximumBelowMinimumException( 'The maximum value must be greater than or equal to the minimum value.', [ @@ -80,7 +80,7 @@ public static function number (int $min = 0, ?int $max = null):int { ] ); - if ($max !== null && $max > $maximum) + if ($max > $maximum) throw new RandomNumberAboveGeneratorMaximumException( 'The maximum value must be less than or equal to the maximum value supported by the generator.', [ @@ -89,7 +89,7 @@ public static function number (int $min = 0, ?int $max = null):int { ] ); - return mt_rand($min, $max ?? ($maximum ?? 0)); + return mt_rand($min, $max); } From b54ff790d0489de8eabe5efbcaa62b59e1b2aeed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danijel=20Gali=C4=87?= Date: Mon, 12 Oct 2026 09:29:43 +0200 Subject: [PATCH 3/5] Update `CHANGELOG.md` for version `v0.3.3` **Details:** - Added a new section for version `v0.3.3` with release date, GitHub comparison link, and details: - Improved `Random` class maximum value handling for enhanced consistency and clarity. - Ensures accurate changelog updates for version tracking and improved documentation. --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ac1b82..080063c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [[v0.3.3](https://github.com/The-FireHub-Project/Runtime/compare/v0.3.2...v0.3.3)] – 2026-10-12 + +### Added +* Improve Random class maximum value handling for consistency and clarity by @dieselxxx + ## [[v0.3.2](https://github.com/The-FireHub-Project/Runtime/compare/v0.3.1...v0.3.2)] – 2026-09-29 ### Added From 7f5c2510995531795cfadc7e4a956dab9438ce25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danijel=20Gali=C4=87?= Date: Mon, 12 Oct 2026 09:30:11 +0200 Subject: [PATCH 4/5] Update version badge in `README.md` to `v0.3.3` **Details:** - Updated the version badge in `Runtime/README.md` from `v0.3.2` to `v0.3.3`. - Ensures the displayed version in documentation aligns with the latest release for consistency and transparency. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0487b2b..7e5addf 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ /> version From 34e79ef5a3d3374c0c75f6cfdc640fdeb103ff06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danijel=20Gali=C4=87?= <56673130+dieselxxx@users.noreply.github.com> Date: Mon, 12 Oct 2026 09:31:19 +0200 Subject: [PATCH 5/5] Update README.md --- README.md | 111 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 7e5addf..7e3f114 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