Repository navigation
Release 1.13
What's Changed
Security Fixes
#[OutputOnly]/#[Ignore]bypass via constructor — a plain (non-promoted) constructor parameter assigned to
a property in the constructor body was hydrated from input even when the property carried#[OutputOnly]or
#[Ignore]:A constructor parameter is now excluded from input when the same-named property carriesclass UserDto { #[OutputOnly] public string $role; public function __construct(public string $name, string $role = 'user') { $this->role = $role; } } // {"name": "x", "role": "admin"} → $dto->role === 'admin'
#[Ignore]or
#[OutputOnly].- PHP 8.4 asymmetric visibility bypassed
publicPropertiesOnly—public private(set)and
public protected(set)properties (including promoted constructor parameters) were hydrated from input, because
ReflectionProperty::isPublic()reports only read visibility. In public-only mode they are now treated as
non-public for input (opt-in with#[MapProperty]still works) and remain in output.public readonlyproperties
are hydrated as before. publicPropertiesOnlyandsymmetricPropertyPathsdid not apply to nested objects (introduced in 1.12) —
nested objects and arrays of objects are (de)normalized by type handlers with their ownNormalizer/
sharedDenormalizer, which never received the new options. WithpublicPropertiesOnly: true, private properties
of nested DTOs still leaked to output and were hydrated from input
({"inner": {"secret": "HACKED"}}). Options are now propagated throughTypeResolverto all nesting levels,
including strict-mode unknown-key detection (inner.secret).
Bug Fixes
symmetricPropertyPathssilently dropped fields on key collisions — a plain property and a path sharing the
same output location ($metaand#[MapProperty(path: 'meta.source')]), or two properties with the same path,
overwrote each other depending on declaration order. Now throwsLogicExceptionnaming the property and the
output location (configuration error).- Index paths produced JSON objects instead of lists —
#[MapProperty(path: 'items[1].name')]normalized to
{"items": {"1": {...}}}. Missing lower indexes are now filled withnull, so the output is a JSON list
({"items": [null, {...}]}), also when indexes are written out of order. toCsv()withsymmetricPropertyPathswrote nested arrays into cells (Array to string conversion,
literalArray). CSV output now always uses flat columns.PropertyPathResolver::set()no longer overwrites an existing scalar when descending into it — throws
InvalidArgumentExceptioninstead.
Behaviour Changes
- Strict mode accepts
#[OutputOnly]keys — they are part of the public contract, so posting a fetched
resource back (PUT round-trip) no longer fails withUnknown key 'id'. The value is discarded, never hydrated.
#[Ignore]and non-public keys (in public-only mode) are still reported as unknown. Applies tomerge()too. - List input to
fromArray()is rejected afterPreDenormalizeEvent— listeners can now reshape list input
(e.g. wrap it into an object) before validation, and the rejection dispatchesDenormalizationErrorEventlike any
other mapping error.PreDenormalizeEvent::$dataandDenormalizationErrorEvent::$dataare documented as
array<mixed>(input is untrusted). - Excluded variadic constructor parameter (
#[Ignore] string ...$tags) threwLogicException/ receivednull.
It now receives no arguments.
Performance
- Visibility/direction decisions (
PropertyVisibilityResolver) are memoized per class member instead of re-reading
attributes via reflection on every mapping call: ~9 % faster normalization, ~20 % faster denormalization
(20k objects, public-only + strict mode).
Remaining overhead:Normalizer/Denormalizerstill re-run reflection per object instead of using
ClassMetadataFactorymetadata — candidate for a follow-up refactor.