private function validateObject($object, $propertyPath, array $groups, $traversalStrategy, ExecutionContextInterface $context)
    {
        try {
            $classMetadata = $this->metadataFactory->getMetadataFor($object);

            if (!$classMetadata instanceof ClassMetadataInterface) {
                throw new UnsupportedMetadataException(sprintf('The metadata factory should return instances of "Symfony\Component\Validator\Mapping\ClassMetadataInterface", got: "%s".', \is_object($classMetadata) ? \get_class($classMetadata) : \gettype($classMetadata)));
            }

            $this->validateClassNode(
                $object,
                spl_object_hash($object),
                $classMetadata,
                $propertyPath,
                $groups,
                null,
                $traversalStrategy,
                $context
            );
        } catch (NoSuchMetadataException $e) {
            // Rethrow if not Traversable
            if (!$object instanceof \Traversable) {
                throw $e;
            }

            // Rethrow unless IMPLICIT or TRAVERSE
            if (!($traversalStrategy & (TraversalStrategy::IMPLICIT | TraversalStrategy::TRAVERSE))) {
                throw $e;
            }

            $this->validateEachObjectIn(
                $object,
                $propertyPath,
                $groups,
                $context
            );
        }
    }
private function validateObject($object, $propertyPath, array $groups, $traversalStrategy, ExecutionContextInterface $context)
    {
        try {
            $classMetadata = $this->metadataFactory->getMetadataFor($object);

            if (!$classMetadata instanceof ClassMetadataInterface) {
                throw new UnsupportedMetadataException(sprintf('The metadata factory should return instances of "Symfony\Component\Validator\Mapping\ClassMetadataInterface", got: "%s".', \is_object($classMetadata) ? \get_class($classMetadata) : \gettype($classMetadata)));
            }

            $this->validateClassNode(
                $object,
                spl_object_hash($object),
                $classMetadata,
                $propertyPath,
                $groups,
                null,
                $traversalStrategy,
                $context
            );
        } catch (NoSuchMetadataException $e) {
            // Rethrow if not Traversable
            if (!$object instanceof \Traversable) {
                throw $e;
            }

            // Rethrow unless IMPLICIT or TRAVERSE
            if (!($traversalStrategy & (TraversalStrategy::IMPLICIT | TraversalStrategy::TRAVERSE))) {
                throw $e;
            }

            $this->validateEachObjectIn(
                $object,
                $propertyPath,
                $groups,
                $context
            );
        }
    }
private function validateObject ( $ object , $ propertyPath , array $ groups , $ traversalStrategy , ExecutionContextInterface $ context ) { try { $ classMetadata = $ this -> metadataFactory -> getMetadataFor ( $ object ) ; if ( ! $ classMetadata instanceof ClassMetadataInterface ) { throw new UnsupportedMetadataException ( sprintf ( 'The metadata factory should return instances of "Symfony\Component\Validator\Mapping\ClassMetadataInterface", got: "%s".' , \ is_object ( $ classMetadata ) ? \ get_class ( $ classMetadata ) : \ gettype ( $ classMetadata ) ) ) ; } $ this -> validateClassNode ( $ object , spl_object_hash ( $ object ) , $ classMetadata , $ propertyPath , $ groups , null , $ traversalStrategy , $ context ) ; } catch ( NoSuchMetadataException $ e ) { // Rethrow if not Traversable if ( ! $ object instanceof \ Traversable ) { throw $ e ; } // Rethrow unless IMPLICIT or TRAVERSE if ( ! ( $ traversalStrategy & ( TraversalStrategy :: IMPLICIT | TraversalStrategy :: TRAVERSE ) ) ) { throw $ e ; } $ this -> validateEachObjectIn ( $ object , $ propertyPath , $ groups , $ context ) ; } }
Validates an object against the constraints defined for its class.

If no metadata is available for the class, but the class is an instance
of {@link \Traversable} and the selected traversal strategy allows
traversal, the object will be iterated and each nested object will be
validated instead.

@param object                    $object            The object to cascade
@param string                    $propertyPath      The current property path
@param (string|GroupSequence)[]  $groups            The validated groups
@param int                       $traversalStrategy The strategy for traversing the
cascaded object
@param ExecutionContextInterface $context           The current execution context

@throws NoSuchMetadataException      If the object has no associated metadata
and does not implement {@link \Traversable}
or if traversal is disabled via the
$traversalStrategy argument
@throws UnsupportedMetadataException If the metadata returned by the
metadata factory does not implement
{@link ClassMetadataInterface}
Validates an object against the constraints defined for its class .