Breaking changes
next()
andprevious()
onIsCollectionType
no longer return a value.- This is because of
\Iterator
requiringnext
to returnvoid
, and it makes sense fornext
andprevious
to function in the same way.
- This is because of
ConversionError
now 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
, andAnyCollection
also implements the\Iterator
interface.
-
Added default
Percentage
andEmail
classes\FireMidge\ValueObject\Generic\Percentage
\FireMidge\ValueObject\Generic\Email
-
New methods on
IsCollectionType
:merge
withMerged
pop
popMultiple
split
shuffle
withReversedOrder
-
jsonSerialize
has been implemented for all types, to aid easy serialisation.- In order for automatic serialisation to happen when
json_encode
is called, the class using these traits has to implement theJsonSerializable
interface. - 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
$reasons
from aConversionError
InvalidValue
renders 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%.