-
-
Notifications
You must be signed in to change notification settings - Fork 3
Prepare v2.1.0 release #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
25c8b2a
Update testing tools
reinder83 eb6f5e3
Update workflow for parallel tests
reinder83 97c0b52
Add named enum flags and split tests
reinder83 af99ca1
Add enum mask conversion guide
reinder83 a678a1e
Document enum conversion example
reinder83 0cd74fd
Run pint
reinder83 dec53a2
Add phpstan templates for enum flags and mask typing
reinder83 1b7164e
Add additional coverage tests for enum and mask edge cases
reinder83 7b526a8
Fix docblock and reducer order
reinder83 b2dee71
Fix enum flag docblock and reducer
reinder83 ca6744c
Correct flag traits docblocks
reinder83 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| /.idea/ | ||
| /.phpunit.result.cache | ||
| /.phpunit.cache | ||
| /cache.properties | ||
| /vendor/ | ||
| composer.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Release Notes - v2.1.0 | ||
|
|
||
| ## Added | ||
| - New enum-backed API: | ||
| - `BinaryEnumFlags` | ||
| - `Traits\InteractsWithEnumFlags` | ||
| - `Flag` enum and `Mask` value object | ||
| - Enum-backed flags now return a `Mask` object from `getMask()`. | ||
| - New `getMaskValue(): int` method for enum-backed flags to persist/interoperate with integer masks. | ||
| - Deprecation warnings for passing `float` values as masks/flags. | ||
| - README migration notice for the upcoming `v3.0.0` integer-only API. | ||
| - `UPGRADE-v3.md` with migration instructions. | ||
| - New primary numeric trait: `Traits\InteractsWithNumericFlags`. | ||
| - `Traits\BinaryFlags` is now deprecated and kept for backward compatibility. | ||
|
|
||
| ## Deprecated | ||
| - Passing `float` to BinaryFlags mask/flag methods is deprecated in `v2.1.0`. | ||
| - Float support will be removed in `v3.0.0`. | ||
| - `Bits::BIT_64` will be removed in `v3.0.0`. | ||
|
|
||
| ## BIT_64 Notice | ||
| `Bits::BIT_64` is being removed because PHP numbers for bitwise flags are signed. The 64th bit is the sign bit, so it cannot be used reliably as a normal flag. | ||
|
|
||
| Using integer-compatible bits avoids these issues. | ||
|
|
||
| ## Migration Recommendation | ||
| Cast external/legacy mask and flag values to `int` before calling BinaryFlags methods. | ||
|
|
||
| ```php | ||
| $flags->setMask((int) $mask); | ||
| $flags->addFlag((int) $flag); | ||
| ``` | ||
|
|
||
| ## Enum Migration Example | ||
| ```php | ||
| // Before: numeric PermissionFlags | ||
| class PermissionFlags extends BinaryFlags | ||
| { | ||
| public const CAN_VIEW = Bits::BIT_1; | ||
| public const CAN_BOOK = Bits::BIT_2; | ||
| } | ||
|
|
||
| $flags = new PermissionFlags($storedMask); | ||
| $flags->addFlag(PermissionFlags::CAN_VIEW | PermissionFlags::CAN_BOOK); | ||
| $storedMask = $flags->getMask(); | ||
|
|
||
| // After: enum-backed PermissionFlags | ||
| enum Permission: int | ||
| { | ||
| case CanView = Bits::BIT_1; | ||
| case CanBook = Bits::BIT_2; | ||
| } | ||
|
|
||
| class PermissionFlags extends BinaryEnumFlags | ||
| { | ||
| protected static function getFlagEnumClass(): string | ||
| { | ||
| return Permission::class; | ||
| } | ||
| } | ||
|
|
||
| $flags = new PermissionFlags(Mask::fromInt($storedMask, Permission::class)); | ||
| $flags->addFlag(Permission::CanView); | ||
| $flags->addFlag(Permission::CanBook); | ||
| $storedMask = $flags->getMaskValue(); | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Upgrade Guide for v3.0.0 | ||
|
|
||
| ## Summary | ||
| `v3.0.0` removes support for `float` values in masks and flags. | ||
| `v3.0.0` also removes `Bits::BIT_64`. | ||
|
|
||
| ## What Changed | ||
| - `v2.x`: `int|float` accepted in mask/flag methods. | ||
| - `v3.0.0`: only `int` is accepted. | ||
| - `v2.x`: `Bits::BIT_64` exists but is not reliable in real bitwise usage. | ||
| - `v3.0.0`: `Bits::BIT_64` is removed. Use `BIT_1` through `BIT_63`. | ||
|
|
||
| ## How to Migrate | ||
| 1. Find every call that passes mask/flag values into BinaryFlags methods. | ||
| 2. Ensure values are cast to `int` before passing them. | ||
| 3. Ensure database or external sources provide integer-compatible values. | ||
|
|
||
| ## Example | ||
| Before: | ||
| ```php | ||
| $flags->setMask($legacyValue); | ||
| $flags->addFlag($legacyFlag); | ||
| ``` | ||
|
|
||
| After: | ||
| ```php | ||
| $flags->setMask((int) $legacyValue); | ||
| $flags->addFlag((int) $legacyFlag); | ||
| ``` | ||
|
|
||
| ## v2.1+ Deprecation Signal | ||
| Starting in `v2.1.0`, float inputs trigger deprecation warnings to help detect call sites before moving to `v3.0.0`. | ||
|
|
||
| ## Why BIT_64 Is Being Removed | ||
| `BIT_64` is being removed because PHP numbers for bitwise flags are signed. The 64th bit is the sign bit, so it cannot be used reliably as a normal flag. | ||
|
|
||
| Staying with integer-compatible bits prevents those runtime issues. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.