@@ -352,24 +352,18 @@ private function validateObject($object, $propertyPath, array $groups, $traversa
352
352
* Validates each object in a collection against the constraints defined
353
353
* for their classes.
354
354
*
355
- * If the parameter $recursive is set to true, nested {@link \Traversable}
356
- * objects are iterated as well. Nested arrays are always iterated,
357
- * regardless of the value of $recursive.
355
+ * Nested arrays are also iterated.
358
356
*
359
357
* @param iterable $collection The collection
360
358
* @param string $propertyPath The current property path
361
359
* @param (string|GroupSequence)[] $groups The validated groups
362
360
* @param ExecutionContextInterface $context The current execution context
363
- *
364
- * @see ClassNode
365
- * @see CollectionNode
366
361
*/
367
362
private function validateEachObjectIn ($ collection , $ propertyPath , array $ groups , ExecutionContextInterface $ context )
368
363
{
369
364
foreach ($ collection as $ key => $ value ) {
370
365
if (\is_array ($ value )) {
371
- // Arrays are always cascaded, independent of the specified
372
- // traversal strategy
366
+ // Also traverse nested arrays
373
367
$ this ->validateEachObjectIn (
374
368
$ value ,
375
369
$ propertyPath .'[ ' .$ key .'] ' ,
@@ -599,7 +593,8 @@ private function validateClassNode($object, $cacheKey, ClassMetadataInterface $m
599
593
* in the passed metadata object. Then, if the value is an instance of
600
594
* {@link \Traversable} and the selected traversal strategy permits it,
601
595
* the value is traversed and each nested object validated against its own
602
- * constraints. Arrays are always traversed.
596
+ * constraints. If the value is an array, it is traversed regardless of
597
+ * the given strategy.
603
598
*
604
599
* @param mixed $value The validated value
605
600
* @param object|null $object The current object
@@ -658,8 +653,8 @@ private function validateGenericNode($value, $object, $cacheKey, MetadataInterfa
658
653
659
654
$ cascadingStrategy = $ metadata ->getCascadingStrategy ();
660
655
661
- // Quit unless we have an array or a cascaded object
662
- if (!\is_array ( $ value ) && ! ($ cascadingStrategy & CascadingStrategy::CASCADE )) {
656
+ // Quit unless we cascade
657
+ if (!($ cascadingStrategy & CascadingStrategy::CASCADE )) {
663
658
return ;
664
659
}
665
660
0 commit comments