|
1 | | -# Release Notes - v2.1.0 |
| 1 | +# Release Notes - v3.0.0 |
2 | 2 |
|
3 | | -## Added |
4 | | -- New enum-backed API: |
5 | | - - `BinaryEnumFlags` |
6 | | - - `Traits\InteractsWithEnumFlags` |
7 | | - - `Flag` enum and `Mask` value object |
8 | | -- Enum-backed flags now return a `Mask` object from `getMask()`. |
9 | | -- New `getMaskValue(): int` method for enum-backed flags to persist/interoperate with integer masks. |
10 | | -- Deprecation warnings for passing `float` values as masks/flags. |
11 | | -- README migration notice for the upcoming `v3.0.0` integer-only API. |
12 | | -- `UPGRADE-v3.md` with migration instructions. |
13 | | -- New primary numeric trait: `Traits\InteractsWithNumericFlags`. |
14 | | -- `Traits\BinaryFlags` is now deprecated and kept for backward compatibility. |
| 3 | +## Changed |
| 4 | +- Numeric `BinaryFlags` APIs now accept `int` values only. |
| 5 | +- Passing `float` values to numeric mask/flag methods now raises `TypeError` for `strict_types=1` callers. |
| 6 | +- Non-strict callers should still cast or validate external values before calling the API because PHP scalar coercion can convert `float` to `int` at the call boundary. |
| 7 | +- The numeric iterator and JSON serialization contracts are now documented as `int`-based. |
15 | 8 |
|
16 | | -## Deprecated |
17 | | -- Passing `float` to BinaryFlags mask/flag methods is deprecated in `v2.1.0`. |
18 | | -- Float support will be removed in `v3.0.0`. |
19 | | -- `Bits::BIT_64` will be removed in `v3.0.0`. |
| 9 | +## Removed |
| 10 | +- `Bits::BIT_64`. |
| 11 | +- The v2.x float-normalization/deprecation path in `Traits\InteractsWithNumericFlags`. |
20 | 12 |
|
21 | 13 | ## BIT_64 Notice |
22 | | -`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. |
| 14 | +`Bits::BIT_64` was 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. |
23 | 15 |
|
24 | 16 | Using integer-compatible bits avoids these issues. |
25 | | - |
26 | | -## Migration Recommendation |
27 | | -Cast external/legacy mask and flag values to `int` before calling BinaryFlags methods. |
28 | | - |
29 | | -```php |
30 | | -$flags->setMask((int) $mask); |
31 | | -$flags->addFlag((int) $flag); |
32 | | -``` |
33 | | - |
34 | | -## Enum Migration Example |
35 | | -```php |
36 | | -// Before: numeric PermissionFlags |
37 | | -class PermissionFlags extends BinaryFlags |
38 | | -{ |
39 | | - public const CAN_VIEW = Bits::BIT_1; |
40 | | - public const CAN_BOOK = Bits::BIT_2; |
41 | | -} |
42 | | - |
43 | | -$flags = new PermissionFlags($storedMask); |
44 | | -$flags->addFlag(PermissionFlags::CAN_VIEW | PermissionFlags::CAN_BOOK); |
45 | | -$storedMask = $flags->getMask(); |
46 | | - |
47 | | -// After: enum-backed PermissionFlags |
48 | | -enum Permission: int |
49 | | -{ |
50 | | - case CanView = Bits::BIT_1; |
51 | | - case CanBook = Bits::BIT_2; |
52 | | -} |
53 | | - |
54 | | -class PermissionFlags extends BinaryEnumFlags |
55 | | -{ |
56 | | - protected static function getFlagEnumClass(): string |
57 | | - { |
58 | | - return Permission::class; |
59 | | - } |
60 | | -} |
61 | | - |
62 | | -$flags = new PermissionFlags(Mask::fromInt($storedMask, Permission::class)); |
63 | | -$flags->addFlag(Permission::CanView); |
64 | | -$flags->addFlag(Permission::CanBook); |
65 | | -$storedMask = $flags->getMaskValue(); |
66 | | -``` |
0 commit comments