From ad3452163ee27bf343b35439f92bb99b0083d11a Mon Sep 17 00:00:00 2001 From: Philipp Cordes Date: Sat, 12 Jan 2019 18:24:44 +0100 Subject: [PATCH] Clarify misleading comments regarding traversal of arrays --- .../Validator/RecursiveContextualValidator.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php index a751a3d73ef34..dc139c36d4254 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php @@ -352,9 +352,7 @@ private function validateObject($object, $propertyPath, array $groups, $traversa * Validates each object in a collection against the constraints defined * for their classes. * - * If the parameter $recursive is set to true, nested {@link \Traversable} - * objects are iterated as well. Nested arrays are always iterated, - * regardless of the value of $recursive. + * Nested arrays are also iterated. * * @param iterable $collection The collection * @param string $propertyPath The current property path @@ -365,8 +363,7 @@ private function validateEachObjectIn($collection, $propertyPath, array $groups, { foreach ($collection as $key => $value) { if (\is_array($value)) { - // Arrays are always cascaded, independent of the specified - // traversal strategy + // Also traverse nested arrays $this->validateEachObjectIn( $value, $propertyPath.'['.$key.']', @@ -596,7 +593,8 @@ private function validateClassNode($object, $cacheKey, ClassMetadataInterface $m * in the passed metadata object. Then, if the value is an instance of * {@link \Traversable} and the selected traversal strategy permits it, * the value is traversed and each nested object validated against its own - * constraints. Arrays are always traversed. + * constraints. If the value is an array, it is traversed regardless of + * the given strategy. * * @param mixed $value The validated value * @param object|null $object The current object