8000 [Validator] add getConstraints to MetadataInterface · symfony/symfony@bd5f345 · GitHub
[go: up one dir, main page]

Skip to content

Commit bd5f345

Browse files
committed
[Validator] add getConstraints to MetadataInterface
1 parent 04eb61b commit bd5f345

File tree

6 files changed

+15
-31
lines changed

6 files changed

+15
-31
lines changed

src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\Form\Guess\ValueGuess;
1818
use Symfony\Component\Validator\Constraint;
1919
use Symfony\Component\Validator\Mapping\ClassMetadataInterface;
20-
use Symfony\Component\Validator\Mapping\GenericMetadata;
2120
use Symfony\Component\Validator\MetadataFactoryInterface;
2221

2322
class ValidatorTypeGuesser implements FormTypeGuesserInterface
@@ -270,10 +269,6 @@ protected function guess($class, $property, \Closure $closure, $defaultValue = n
270269
$memberMetadatas = $classMetadata->getPropertyMetadata($property);
271270

272271
foreach ($memberMetadatas as $memberMetadata) {
273-
if (!$memberMetadata instanceof GenericMetadata) {
274-
continue;
275-
}
276-
277272
$constraints = $memberMetadata->getConstraints();
278273

279274
foreach ($constraints as $constraint) {

src/Symfony/Component/Validator/Context/ExecutionContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class ExecutionContext implements ExecutionContextInterface
8989
/**
9090
* The current validation metadata.
9191
*
92-
* @var MetadataInterface
92+
* @var MetadataInterface|null
9393
*/
9494
private $metadata;
9595

src/Symfony/Component/Validator/Mapping/ClassMetadata.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,8 @@ public function mergeConstraints(ClassMetadata $source)
319319
foreach ($source->getPropertyMetadata($property) as $member) {
320320
$member = clone $member;
321321

322-
if ($member instanceof GenericMetadata) {
323-
foreach ($member->getConstraints() as $constraint) {
324-
$constraint->addImplicitGroupName($this->getDefaultGroup());
325-
}
322+
foreach ($member->getConstraints() as $constraint) {
323+
$constraint->addImplicitGroupName($this->getDefaultGroup());
326324
}
327325

328326
$this->addPropertyMetadata($member);

src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function __construct(LoaderInterface $loader = null, CacheInterface $cach
7474
}
7575

7676
/**
77-
* Returns the metadata for the given class name or object.
77+
* {@inheritdoc}
7878
*
7979
* If the method was called with the same class name (or an object of that
8080
* class) before, the same metadata instance is returned.
@@ -87,12 +87,6 @@ public function __construct(LoaderInterface $loader = null, CacheInterface $cach
8787
* configured with a loader, the metadata is passed to the
8888
* {@link LoaderInterface::loadClassMetadata()} method for further
8989
* configuration. At last, the new object is returned.
90-
*
91-
* @param string|object $value A class name or an object
92-
*
93-
* @return MetadataInterface The metadata for the value
94-
*
95-
* @throws NoSuchMetadataException If no metadata exists for the given value
9690
*/
9791
public function getMetadataFor($value)
9892
{
@@ -141,12 +135,7 @@ public function getMetadataFor($value)
141135
}
142136

143137
/**
144-
* Returns whether the factory is able to return metadata for the given
145-
* class name or object.
146-
*
147-
* @param string|object $value A class name or an object
148-
*
149-
* @return bool Whether metadata can be returned for that class
138+
* {@inheritdoc}
150139
*/
151140
public function hasMetadataFor($value)
152141
{

src/Symfony/Component/Validator/Mapping/GenericMetadata.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ public function addConstraints(array $constraints)
180180
}
181181

182182
/**
183-
* Returns all constraints of this element.
184-
*
185-
* @return Constraint[] A list of Constraint instances
183+
* {@inheritdoc}
186184
*/
187185
public function getConstraints()
188186
{
@@ -200,12 +198,9 @@ public function hasConstraints()
200198
}
201199

202200
/**
203-
* Returns the constraints of the given group and global ones (* group).
204-
*
205-
* @param string $group The group name
201+
* {@inheritdoc}
206202
*
207-
* @return Constraint[] An list of all the Constraint instances belonging
208-
* to the group
203+
* Aware of the global group (* group).
209204
*/
210205
public function findConstraints($group)
211206
{

src/Symfony/Component/Validator/Mapping/MetadataInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,11 @@ public function getCascadingStrategy();
4848
* @see TraversalStrategy
4949
*/
5050
public function getTraversalStrategy();
51+
52+
/**
53+
* Returns all constraints of this element.
54+
*
55+
* @return Constraint[] A list of Constraint instances
56+
*/
57+
public function getConstraints();
5158
}

0 commit comments

Comments
 (0)
0