From 88a6d86e15e8560b4ae145fd110313f506295cf2 Mon Sep 17 00:00:00 2001 From: Bartosz Urbaniak Date: Thu, 31 Aug 2023 10:55:46 +0200 Subject: [PATCH] Add comments --- src/Service/Nelmio/DtoOADescriber.php | 3 ++- src/Service/Validation/TypeValidationHelper.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Service/Nelmio/DtoOADescriber.php b/src/Service/Nelmio/DtoOADescriber.php index b70fbc4..cfac802 100644 --- a/src/Service/Nelmio/DtoOADescriber.php +++ b/src/Service/Nelmio/DtoOADescriber.php @@ -230,6 +230,7 @@ private function resolveProperties( ]); if (is_array($model)) { + // checking whether there is an empty index by which you can distinguish whether the model is a collection of objects or a flat object if (is_array($model[''] ?? null)) { $property->type = "array"; $property->items = new Items([]); @@ -345,7 +346,7 @@ private function getClassBags( } if ($item instanceof DtoTypeModel) { - if ($item->isCollection()) { + if ($item->isCollection()) { // forces an empty index to make it easier to check whether an element is an array $propertyPath .= '.'; } $bags = DtoUtil::mergeRecursively($bags, $this->getClassBags($item, $propertyPath)); diff --git a/src/Service/Validation/TypeValidationHelper.php b/src/Service/Validation/TypeValidationHelper.php index a28714f..6d8af3b 100644 --- a/src/Service/Validation/TypeValidationHelper.php +++ b/src/Service/Validation/TypeValidationHelper.php @@ -42,6 +42,7 @@ public function validateType( } $list = new ConstraintViolationList(); + // coerce and copy sub-values foreach ($subValues as $key => $value) { if (null === ($result = $this->coercionService->coerce($key, $subProperties[$key], $value))) {