Releases: aternosorg/php-serializer
Releases · aternosorg/php-serializer
v1.5.0
Additions
- You can now deserialize classes with private or protected constructors
- You can now deserialize classes with constructor parameters if they use the
Serializeattribute
Improvements
- Template bounds are now specified in PHPDoc
- Added missing
@throwsto DeserializerInterface - Added note about intersection types with custom deserializers to the README
Full Changelog: 1.4.0...1.5.0
v1.4.0
What's Changed
- Add BackedEnumSerializer to serialize enums
This is useful if your object contains arrays of enums. Just use it as the item serializer:
#[Serialize(itemSerializer: new BackedEnumSerializer())]
protected array $backedEnumArray = [
TestBackedEnum::A,
];Full Changelog: 1.2.0...1.3.0
1.3.1
What's Changed
- Fix exception if another property appears after property using itemSerializer
- Add missing throws tag to JsonDeserializer
Full Changelog: 1.2.0...1.3.0
1.1.0
What's Changed
- Add custom serializers and deserializers for individual properties by @KurtThiemann
Serializer and Deserializer
A custom Serializer and Deserializer can be specified for a property.
This can be useful if you want to serialize a specific property in a different way.
#[Serialize(serializer: new Base64Serializer(), deserializer: new Base64Deserializer(TestClass::class))]
protected TestClass $example;Note that the custom Deserializer is responsible for returning the correct type.
If an incompatible type is returned, an IncorrectTypeException is thrown.
New Contributors
- @KurtThiemann made their first contribution in #2
Full Changelog: 1.0.0...v1.1.0
v1.3.0
What's Changed
- Support serializing and deserializing backed enums by @KurtThiemann in #4
Note
Serialization and deserialization of unit enums is not supported.
Full Changelog: 1.2.0...1.3.0
v1.2.0
What's Changed
- Add custom serializers and deserializers for array items by @KurtThiemann in #3
Item Serializer and Item Deserializer
Custom Serializers and Deserializers can now also be specified for array items.
#[Serialize(itemSerializer: new Base64Serializer(), itemDeserializer: new Base64Deserializer(TestClass::class))]
protected array $example = [];Full Changelog: v1.1.0...1.2.0