8000 minor #35816 [Validator] Remove specific check for Valid targets (ogi… · symfony/symfony@f75be00 · GitHub
[go: up one dir, main page]

Skip to content

Commit f75be00

Browse files
minor #35816 [Validator] Remove specific check for Valid targets (ogizanagi)
This PR was merged into the 3.4 branch. Discussion ---------- [Validator] Remove specific check for Valid targets | Q | A | ------------- | --- | Branch? | 3.4 <!-- see below --> | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | N/A <!-- prefix each issue number with "Fix #", if any --> | License | MIT | Doc PR | N/A As covered by `ClassMetadataTest::testAddConstraintDoesNotAcceptValid`, this check is useless, as `Valid` already accepts only properties as targets. This check is a [leftover of a time](9b07b0c) `Valid` was extending `Traverse` which was allowing classes & properties. The `Valid` targets are properly checked by the lines above, the same way as other constraints. Commits ------- 0086562 [Validator] Remove specific check for Valid targets
2 parents 1676e3a + 0086562 commit f75be00

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\Constraints\GroupSequence;
1616
use Symfony\Component\Validator\Constraints\Traverse;
17-
use Symfony\Component\Validator\Constraints\Valid;
1817
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
1918
use Symfony\Component\Validator\Exception\GroupDefinitionException;
2019

@@ -183,10 +182,6 @@ public function addConstraint(Constraint $constraint)
183182
throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on classes.', \get_class($constraint)));
184183
}
185184

186-
if ($constraint instanceof Valid) {
187-
throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on classes.', \get_class($constraint)));
188-
}
189-
190185
if ($constraint instanceof Traverse) {
191186
if ($constraint->traverse) {
192187
// If traverse is true, traversal should be explicitly enabled

0 commit comments

Comments
 (0)
0