diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php index e8444ced9b..5a97b3fd14 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php @@ -17,7 +17,6 @@ use Symfony\Component\Form\Guess\TypeGuess; use Symfony\Component\Form\Guess\ValueGuess; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Mapping\ClassMetadataInterface; -use Symfony\Component\Validator\Mapping\GenericMetadata; use Symfony\Component\Validator\MetadataFactoryInterface; class ValidatorTypeGuesser implements FormTypeGuesserInterface @@ -270,10 +269,6 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface $memberMetadatas = $classMetadata->getPropertyMetadata($property); foreach ($memberMetadatas as $memberMetadata) { - if (!$memberMetadata instanceof GenericMetadata) { - continue; - } - $constraints = $memberMetadata->getConstraints(); foreach ($constraints as $constraint) { diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index 5ae30d4699..eac44859d4 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -11,6 +11,7 @@ CHANGELOG * deprecated `ClassMetadata::hasMemberMetadatas()` * deprecated `ClassMetadata::getMemberMetadatas()` * deprecated `ClassMetadata::addMemberMetadata()` + * [BC BREAK] added `Mapping\MetadataInterface::getConstraints()` 2.5.0 ----- diff --git a/src/Symfony/Component/Validator/Context/ExecutionContext.php b/src/Symfony/Component/Validator/Context/ExecutionContext.php index c38490739d..8934a42e62 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContext.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContext.php @@ -89,7 +89,7 @@ class ExecutionContext implements ExecutionContextInterface /** * The current validation metadata. * - * @var MetadataInterface + * @var MetadataInterface|null */ private $metadata; diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index f65133c773..bd6ac3c5c5 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -319,10 +319,8 @@ class ClassMetadata extends ElementMetadata implements LegacyMetadataInterface, foreach ($source->getPropertyMetadata($property) as $member) { $member = clone $member; - if ($member instanceof GenericMetadata) { - foreach ($member->getConstraints() as $constraint) { - $constraint->addImplicitGroupName($this->getDefaultGroup()); - } + foreach ($member->getConstraints() as $constraint) { + $constraint->addImplicitGroupName($this->getDefaultGroup()); } $this->addPropertyMetadata($member); diff --git a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php index dc84824c6c..a5bec217d0 100644 --- a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php +++ b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php @@ -74,7 +74,7 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface } /** - * Returns the metadata for the given class name or object. + * {@inheritdoc} * * If the method was called with the same class name (or an object of that * class) before, the same metadata instance is returned. @@ -87,12 +87,6 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface * configured with a loader, the metadata is passed to the * {@link LoaderInterface::loadClassMetadata()} method for further * configuration. At last, the new object is returned. - * - * @param string|object $value A class name or an object - * - * @return MetadataInterface The metadata for the value - * - * @throws NoSuchMetadataException If no metadata exists for the given value */ public function getMetadataFor($value) { @@ -141,12 +135,7 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface } /** - * Returns whether the factory is able to return metadata for the given - * class name or object. - * - * @param string|object $value A class name or an object - * - * @return bool Whether metadata can be returned for that class + * {@inheritdoc} */ public function hasMetadataFor($value) { diff --git a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php index 01a6c3226a..904dcd7688 100644 --- a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php @@ -180,9 +180,7 @@ class GenericMetadata implements MetadataInterface } /** - * Returns all constraints of this element. - * - * @return Constraint[] A list of Constraint instances + * {@inheritdoc} */ public function getConstraints() { @@ -200,12 +198,9 @@ class GenericMetadata implements MetadataInterface } /** - * Returns the constraints of the given group and global ones (* group). + * {@inheritdoc} * - * @param string $group The group name - * - * @return Constraint[] An list of all the Constraint instances belonging - * to the group + * Aware of the global group (* group). */ public function findConstraints($group) { diff --git a/src/Symfony/Component/Validator/Mapping/MetadataInterface.php b/src/Symfony/Component/Validator/Mapping/MetadataInterface.php index a72d4a5801..28c355df71 100644 --- a/src/Symfony/Component/Validator/Mapping/MetadataInterface.php +++ b/src/Symfony/Component/Validator/Mapping/MetadataInterface.php @@ -48,4 +48,11 @@ interface MetadataInterface extends LegacyMetadataInterface * @see TraversalStrategy */ public function getTraversalStrategy(); + + /** + * Returns all constraints of this element. + * + * @return Constraint[] A list of Constraint instances + */ + public function getConstraints(); }