@@ -268,6 +268,9 @@ protected function normalizeGroups($groups)
268268 */
269269 private function traverseClassNode ($ value , ClassMetadataInterface $ metadata = null , $ propertyPath , array $ groups , $ cascadedGroups , $ traversalStrategy , ExecutionContextInterface $ context )
270270 {
271+ // Replace "Default" group by group sequence, if appropriate
272+ $ groups = $ this ->replaceDefaultGroup ($ value , $ metadata , $ groups );
273+
271274 $ groups = $ this ->validateNode ($ value , $ value , $ metadata , $ propertyPath , $ groups , $ traversalStrategy , $ context );
272275
273276 if (0 === count ($ groups )) {
@@ -566,10 +569,6 @@ public function validateNode($value, $object, MetadataInterface $metadata = null
566569 $ context ->setMetadata ($ metadata );
567570 $ context ->setPropertyPath ($ propertyPath );
568571
569- if ($ metadata instanceof ClassMetadataInterface) {
570- $ groups = $ this ->replaceDefaultGroup ($ value , $ metadata , $ groups );
571- }
572-
573572 $ objectHash = is_object ($ object ) ? spl_object_hash ($ object ) : null ;
574573
575574 // if group (=[<G1,G2>,G3,G4]) contains group sequence (=<G1,G2>)
@@ -599,18 +598,18 @@ public function validateNode($value, $object, MetadataInterface $metadata = null
599598 $ context ->markObjectAsValidatedForGroup ($ objectHash , $ groupHash );
600599 }
601600
602- // Validate normal group
603- if (!$ group instanceof GroupSequence) {
604- $ this ->validateNodeForGroup ($ value , $ objectHash , $ metadata , $ group , $ context );
601+ if ($ group instanceof GroupSequence) {
602+ // Traverse group sequence until a violation is generated
603+ $ this ->stepThroughGroupSequence ($ value , $ object , $ metadata , $ propertyPath , $ traversalStrategy , $ group , $ context );
604+
605+ // Skip the group sequence when validating successor nodes
606+ unset($ groups [$ key ]);
605607
606608 continue ;
607609 }
608610
609- // Traverse group sequence until a violation is generated
610- $ this ->stepThroughGroupSequence ($ value , $ object , $ metadata , $ propertyPath , $ traversalStrategy , $ group , $ context );
611-
612- // Skip the group sequence when validating successor nodes
613- unset($ groups [$ key ]);
611+ // Validate normal group
612+ $ this ->validateNodeForGroup ($ value , $ objectHash , $ metadata , $ group , $ context );
614613 }
615614
616615 return $ groups ;
0 commit comments