Notable changes
PHP 8.4 support 🐘
Enjoy the upcoming PHP 8.4 version before it is even officially released!
Pretty JSON output
The JSON_PRETTY_PRINT
option is now supported by the JSON normalizer and will format the ouput with whitespaces and line breaks:
$input = [
'value' => 'foo',
'list' => [
'foo',
42,
['sub']
],
'associative' => [
'value' => 'foo',
'sub' => [
'string' => 'foo',
'integer' => 42,
],
],
];
(new \CuyZ\Valinor\MapperBuilder())
->normalizer(\CuyZ\Valinor\Normalizer\Format::json())
->withOptions(\JSON_PRETTY_PRINT)
->normalize($input);
// Result:
// {
// "value": "foo",
// "list": [
// "foo",
// 42,
// [
// "sub"
// ]
// ],
// "associative": {
// "value": "foo",
// "sub": {
// "string": "foo",
// "integer": 42
// }
// }
// }
Force array as object in JSON output
The JSON_FORCE_OBJECT
option is now supported by the JSON normalizer and will force the output of an array to be an object:
(new \CuyZ\Valinor\MapperBuilder())
->normalizer(Format::json())
->withOptions(JSON_FORCE_OBJECT)
->normalize(['foo', 'bar']);
// {"0":"foo","1":"bar"}
Features
- Add support for
JSON_FORCE_OBJECT
option in JSON normalizer (f3e8c1) - Add support for PHP 8.4 (07a06a)
- Handle
JSON_PRETTY_PRINT
option with the JSON normalizer (950395)
Bug Fixes
- Handle float type casting properly (8742b2)
- Handle namespace for Closure without class scope (7a0fc2)
- Prevent cache corruption when normalizing and mapping to enum (e695b2)
- Properly handle class sharing class name and namespace group name (6e68d6)