X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fsymfony%2Fvalidator%2FValidator%2FRecursiveContextualValidator.php;fp=vendor%2Fsymfony%2Fvalidator%2FValidator%2FRecursiveContextualValidator.php;h=838d12b4033fdfd4870ffc41631a252796d33869;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=a9e9f7f0e8a12d174862a7543889c8842a4618eb;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/vendor/symfony/validator/Validator/RecursiveContextualValidator.php b/vendor/symfony/validator/Validator/RecursiveContextualValidator.php index a9e9f7f0e..838d12b40 100644 --- a/vendor/symfony/validator/Validator/RecursiveContextualValidator.php +++ b/vendor/symfony/validator/Validator/RecursiveContextualValidator.php @@ -27,7 +27,7 @@ use Symfony\Component\Validator\Mapping\GenericMetadata; use Symfony\Component\Validator\Mapping\MetadataInterface; use Symfony\Component\Validator\Mapping\PropertyMetadataInterface; use Symfony\Component\Validator\Mapping\TraversalStrategy; -use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; use Symfony\Component\Validator\ObjectInitializerInterface; use Symfony\Component\Validator\Util\PropertyPath; @@ -175,7 +175,6 @@ class RecursiveContextualValidator implements ContextualValidatorInterface $value, $this->defaultPropertyPath, $groups, - true, $this->context ); @@ -200,8 +199,6 @@ class RecursiveContextualValidator implements ContextualValidatorInterface $classMetadata = $this->metadataFactory->getMetadataFor($object); if (!$classMetadata instanceof ClassMetadataInterface) { - // Cannot be UnsupportedMetadataException because of BC with - // Symfony < 2.5 throw new ValidatorException(sprintf( 'The metadata factory should return instances of '. '"\Symfony\Component\Validator\Mapping\ClassMetadataInterface", '. @@ -227,7 +224,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface $this->validateGenericNode( $propertyValue, $object, - $cacheKey.':'.$propertyName, + $cacheKey.':'.get_class($object).':'.$propertyName, $propertyMetadata, $propertyPath, $groups, @@ -251,8 +248,6 @@ class RecursiveContextualValidator implements ContextualValidatorInterface $classMetadata = $this->metadataFactory->getMetadataFor($objectOrClass); if (!$classMetadata instanceof ClassMetadataInterface) { - // Cannot be UnsupportedMetadataException because of BC with - // Symfony < 2.5 throw new ValidatorException(sprintf( 'The metadata factory should return instances of '. '"\Symfony\Component\Validator\Mapping\ClassMetadataInterface", '. @@ -285,7 +280,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface $this->validateGenericNode( $value, $object, - $cacheKey.':'.$propertyName, + $cacheKey.':'.get_class($object).':'.$propertyName, $propertyMetadata, $propertyPath, $groups, @@ -387,7 +382,6 @@ class RecursiveContextualValidator implements ContextualValidatorInterface $object, $propertyPath, $groups, - $traversalStrategy & TraversalStrategy::STOP_RECURSION, $context ); } @@ -401,36 +395,24 @@ class RecursiveContextualValidator implements ContextualValidatorInterface * objects are iterated as well. Nested arrays are always iterated, * regardless of the value of $recursive. * - * @param array|\Traversable $collection The collection - * @param string $propertyPath The current property path - * @param string[] $groups The validated groups - * @param bool $stopRecursion Whether to disable - * recursive iteration. For - * backwards compatibility - * with Symfony < 2.5. - * @param ExecutionContextInterface $context The current execution context + * @param array|\Traversable $collection The collection + * @param string $propertyPath The current property path + * @param string[] $groups The validated groups + * @param ExecutionContextInterface $context The current execution context * * @see ClassNode * @see CollectionNode */ - private function validateEachObjectIn($collection, $propertyPath, array $groups, $stopRecursion, ExecutionContextInterface $context) + private function validateEachObjectIn($collection, $propertyPath, array $groups, ExecutionContextInterface $context) { - if ($stopRecursion) { - $traversalStrategy = TraversalStrategy::NONE; - } else { - $traversalStrategy = TraversalStrategy::IMPLICIT; - } - foreach ($collection as $key => $value) { if (is_array($value)) { // Arrays are always cascaded, independent of the specified // traversal strategy - // (BC with Symfony < 2.5) $this->validateEachObjectIn( $value, $propertyPath.'['.$key.']', $groups, - $stopRecursion, $context ); @@ -438,13 +420,12 @@ class RecursiveContextualValidator implements ContextualValidatorInterface } // Scalar and null values in the collection are ignored - // (BC with Symfony < 2.5) if (is_object($value)) { $this->validateObject( $value, $propertyPath.'['.$key.']', $groups, - $traversalStrategy, + TraversalStrategy::IMPLICIT, $context ); } @@ -608,7 +589,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface $this->validateGenericNode( $propertyValue, $object, - $cacheKey.':'.$propertyName, + $cacheKey.':'.get_class($object).':'.$propertyName, $propertyMetadata, PropertyPath::append($propertyPath, $propertyName), $groups, @@ -622,9 +603,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface // If no specific traversal strategy was requested when this method // was called, use the traversal strategy of the class' metadata if ($traversalStrategy & TraversalStrategy::IMPLICIT) { - // Keep the STOP_RECURSION flag, if it was set - $traversalStrategy = $metadata->getTraversalStrategy() - | ($traversalStrategy & TraversalStrategy::STOP_RECURSION); + $traversalStrategy = $metadata->getTraversalStrategy(); } // Traverse only if IMPLICIT or TRAVERSE @@ -639,8 +618,6 @@ class RecursiveContextualValidator implements ContextualValidatorInterface // If TRAVERSE, fail if we have no Traversable if (!$object instanceof \Traversable) { - // Must throw a ConstraintDefinitionException for backwards - // compatibility reasons with Symfony < 2.5 throw new ConstraintDefinitionException(sprintf( 'Traversal was enabled for "%s", but this class '. 'does not implement "\Traversable".', @@ -652,7 +629,6 @@ class RecursiveContextualValidator implements ContextualValidatorInterface $object, $propertyPath, $groups, - $traversalStrategy & TraversalStrategy::STOP_RECURSION, $context ); } @@ -738,9 +714,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface // If no specific traversal strategy was requested when this method // was called, use the traversal strategy of the node's metadata if ($traversalStrategy & TraversalStrategy::IMPLICIT) { - // Keep the STOP_RECURSION flag, if it was set - $traversalStrategy = $metadata->getTraversalStrategy() - | ($traversalStrategy & TraversalStrategy::STOP_RECURSION); + $traversalStrategy = $metadata->getTraversalStrategy(); } // The $cascadedGroups property is set, if the "Default" group is @@ -751,12 +725,10 @@ class RecursiveContextualValidator implements ContextualValidatorInterface if (is_array($value)) { // Arrays are always traversed, independent of the specified // traversal strategy - // (BC with Symfony < 2.5) $this->validateEachObjectIn( $value, $propertyPath, $cascadedGroups, - $traversalStrategy & TraversalStrategy::STOP_RECURSION, $context ); @@ -765,7 +737,6 @@ class RecursiveContextualValidator implements ContextualValidatorInterface // If the value is a scalar, pass it anyway, because we want // a NoSuchMetadataException to be thrown in that case - // (BC with Symfony < 2.5) $this->validateObject( $value, $propertyPath, @@ -811,7 +782,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface $cascadedGroups = $cascadedGroup ? array($cascadedGroup) : null; foreach ($groupSequence->groups as $groupInSequence) { - $groups = array($groupInSequence); + $groups = (array) $groupInSequence; if ($metadata instanceof ClassMetadataInterface) { $this->validateClassNode(