Skip to content

Binary Flags v3#16

Merged
reinder83 merged 18 commits into
masterfrom
feature/v3.0
Jun 23, 2026
Merged

Binary Flags v3#16
reinder83 merged 18 commits into
masterfrom
feature/v3.0

Conversation

@reinder83

Copy link
Copy Markdown
Owner

This pull request introduces the breaking changes for version 3.0.0 of the BinaryFlags package, enforcing integer-only masks and flags, removing legacy float support, and eliminating the deprecated Bits::BIT_64. It also updates documentation and code contracts to reflect these changes, and upgrades development dependencies for better compatibility and analysis.

Integer-only API and removal of float support

  • All mask and flag values across the codebase are now strictly int; passing a float will throw a TypeError instead of being normalized or issuing a deprecation warning. The float normalization/deprecation logic has been removed from Traits\InteractsWithNumericFlags, and all relevant method signatures and docblocks have been updated. (src/Traits/InteractsWithNumericFlags.php [1] [2] [3] [4] [5] [6] [7] [8]; src/BinaryFlags.php [9] [10] [11] [12]

Removal of Bits::BIT_64

  • The deprecated Bits::BIT_64 constant has been removed, as the 64th bit is the sign bit in PHP and cannot be reliably used for flags. All documentation and migration notes have been updated accordingly. (src/Bits.php [1]; README.md [2] [3]; RELEASE_NOTES.md [4]; UPGRADE-v3.md [5]

Documentation and migration guidance

  • The README.md, RELEASE_NOTES.md, and UPGRADE-v3.md have been updated to clarify the integer-only API, explain the removal of float support and BIT_64, and provide migration instructions for users upgrading from earlier versions. (README.md [1] [2]; RELEASE_NOTES.md [3]; UPGRADE-v3.md [4] [5]

Development tooling updates

  • Upgraded development dependencies to newer major versions for phpstan/phpstan, pestphp/pest, and rector/rector for improved analysis and testing. Added a new ignore rule for unused trait analysis in phpstan.neon.dist. (composer.json [1]; phpstan.neon.dist [2]

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prepares BinaryFlags for the v3.0.0 breaking release by moving the numeric API toward integer-only masks/flags, removing Bits::BIT_64, updating docs/migration guidance, and refreshing dev tooling and tests to reflect the new contract.

Changes:

  • Tighten numeric mask/flag APIs toward int-only usage (and remove the prior float deprecation/normalization path).
  • Remove Bits::BIT_64 and add/adjust tests + migration docs accordingly.
  • Add declare(strict_types=1); broadly and upgrade dev dependencies (PHPStan/Pest/Rector), plus PHPStan config tweaks.

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
UPGRADE-v3.md Updates v3 migration guidance and describes runtime impact of float inputs.
RELEASE_NOTES.md Refreshes release notes to v3.0.0 scope (int-only + BIT_64 removal).
README.md Updates breaking-change notice and BIT_64 guidance for v3.
composer.json Bumps dev tooling versions (PHPStan/Pest/Rector).
phpstan.neon.dist Adds ignore rule for deprecated alias trait not being analyzed.
src/Traits/InteractsWithNumericFlags.php Removes float normalization/deprecation logic and tightens signatures to int.
src/BinaryFlags.php Updates constructor and iterator/phpdoc contracts to int.
src/Bits.php Removes Bits::BIT_64 constant and adds strict types.
src/Mask.php Adds strict types declaration.
src/Flag.php Adds strict types declaration.
src/BinaryEnumFlags.php Adds strict types declaration.
src/Traits/InteractsWithEnumFlags.php Adds strict types declaration.
src/Traits/BinaryFlags.php Adds strict types declaration to deprecated alias trait.
tests/NumericTypeValidationTest.php Adds new tests asserting floats are rejected and BIT_64 is undefined.
tests/NumericDeprecationTest.php Removes v2.x float deprecation-warning behavior test.
tests/PermissionEnumTest.php Renames/adjusts enum test wording around deprecation/float validation behavior.
tests/TestCase.php Adds strict types declaration.
tests/Pest.php Adds strict types declaration.
tests/NumericBitsTest.php Adds strict types declaration.
tests/NumericBitsNamesTest.php Adds strict types declaration.
tests/MaskTest.php Adds strict types declaration.
tests/LegacyTraitCompatibilityTest.php Adds strict types declaration.
tests/FlagWithNamesTest.php Adds strict types declaration.
tests/FlagEnumTest.php Adds strict types declaration.
tests/EnumErrorPathsTest.php Adds strict types declaration.
tests/Stubs/Permission.php Adds strict types declaration.
tests/Stubs/LegacyTraitFlags.php Adds strict types declaration.
tests/Stubs/InvalidPermission.php Adds strict types declaration.
tests/Stubs/ExamplePermissionFlags.php Adds strict types declaration.
tests/Stubs/ExampleInvalidPermissionFlags.php Adds strict types declaration.
tests/Stubs/ExampleFlagsWithNames.php Adds strict types declaration.
tests/Stubs/ExampleFlags.php Adds strict types declaration.
tests/Stubs/ExampleEnumFlags.php Adds strict types declaration.
tests/Stubs/BadStringFlag.php Adds strict types declaration.
Comments suppressed due to low confidence (1)

src/Traits/InteractsWithNumericFlags.php:65

  • getAllFlagsMask()'s array_reduce() callback is untyped, so static analysis (and PHPStan max) may infer mixed for $carry/$flag and the return value even though the method promises int. This is especially relevant after tightening the return type to int.

Type-hint the closure parameters/return to keep the contract explicit and avoid PHPStan errors.

        return array_reduce(
            array_keys(static::getAllFlags()),
            function ($carry, $flag) {
                return $carry | $flag;
            },
            0,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Traits/InteractsWithNumericFlags.php
Comment thread src/Traits/InteractsWithNumericFlags.php
Comment thread src/BinaryFlags.php
Comment thread README.md
Comment thread UPGRADE-v3.md Outdated
Comment thread RELEASE_NOTES.md

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 34 changed files in this pull request and generated 3 comments.

Comment thread README.md
Comment thread tests/PermissionEnumTest.php Outdated
Comment thread tests/NumericTypeValidationTest.php
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@reinder83 reinder83 merged commit 68d4405 into master Jun 23, 2026
5 checks passed
@reinder83 reinder83 deleted the feature/v3.0 branch June 23, 2026 11:12
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.

2 participants