Repository navigation
Release 1.11
What's Changed
Bug Fixes
-
Fix TypeError when a parent DTO has an invalid enum and a valid non-nullable typed array on the same level — the shared denormalizer instance (singleton in
TypeResolver) reused$this->errorsacross recursivedenormalize()calls. An error from a parent property (e.g. invalid enum value) leaked into nestedObjectType/ArrayTypeelement processing, was re-thrown as aValidationException, caught asnull, and then assigned to a non-nullable property — producing a PHPTypeError(HTTP 500) instead of the expectedValidationException(HTTP 422) with the real field path.Concretely: sending
{"client": {"entityType": "Legal Entity", "addresses": [...]}}with a badentityTypewould fail withCannot assign null to property ClientSimpleRequest::$addresses of type arrayinstead of a clean validation error onclient.entityType.The fix isolates errors produced inside each
denormalize()invocation from errors inherited from a parent invocation (snapshot +array_diff_key), switchessetPropertyValue()from count-based to value-aware error detection (catches same-key overwrites), and adds a defensive guard against assigningnullto non-nullable properties.
Tests
- Add
EnumWithArrayErrorIsolationTestwith 11 regression cases covering:- invalid enum + valid nested array (top-level and nested DTO)
- valid enum + invalid nested element
- invalid enum + invalid nested element (both errors surfaced)
- empty / missing /
nullnested arrays - deep recursion error isolation
- constructor-based DTO reproduction
- exact production reproduction via
fromJson
Affected files
src/Denormalizer/Denormalizer.php—denormalize(),createWithConstructor(),setPropertyValue()
Full Changelog: v1.10...v1.11