Breaking changes
next()andprevious()onIsCollectionTypeno longer return a value.- This is because of
\Iteratorrequiringnextto returnvoid, and it makes sense fornextandpreviousto function in the same way.
- This is because of
ConversionErrornow extends from\ValueError(previously\RuntimeException)
Features
-
Added default classes to be able to use some of the traits instantly without having to create an empty new class each time. The classes added are:
\FireMidge\ValueObject\Generic\AnyCollection\FireMidge\ValueObject\Generic\AnyFloat\FireMidge\ValueObject\Generic\AnyInteger\FireMidge\ValueObject\Generic\AnyString- All of the above classes implement
\JsonSerializable, andAnyCollectionalso implements the\Iteratorinterface.
-
Added default
PercentageandEmailclasses\FireMidge\ValueObject\Generic\Percentage\FireMidge\ValueObject\Generic\Email
-
New methods on
IsCollectionType:mergewithMergedpoppopMultiplesplitshufflewithReversedOrder
-
jsonSerializehas been implemented for all types, to aid easy serialisation.- In order for automatic serialisation to happen when
json_encodeis called, the class using these traits has to implement theJsonSerializableinterface. - The new generic classes all implement it already.
- In order for automatic serialisation to happen when
Improvements
- Added Psalm annotations in the collection type.
- This allows for better IDE-internal type hints for methods like
toArray(),first(),last()etc. - Usage is showcased in
README.md
- This allows for better IDE-internal type hints for methods like
- More specific error messages for adding or subtracting a value from a float or integer type beyond allowed min/max values.
- Option to return
$reasonsfrom aConversionError InvalidValuerenders different types better, e.g. non-strings are no longer wrapped in double quotes- Library is tested against PHP 8.4. Worked without changes to the code.
- Upgraded from PhpUnit 9 to 11.5 and upgraded Infection to 29.0.
- Changed all docblock annotations to attributes
- Infection's output is vastly improved, removing the vast majority of false positives. MSI has changed from 97% to 99%, Mutation Code Coverage from 98% to 99% and Covered Code MSI from 98% to 100%.