Skip to content

Commit 0a4a92b

Browse files
committed
bug symfony#20961 [Validator] phpize default option values (xabbuh)
This PR was merged into the 2.7 branch. Discussion ---------- [Validator] phpize default option values | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#13740 | License | MIT | Doc PR | This makes the behavior for default constraints inline with the behavior when the option is given explicitly. Commits ------- d65679b [Validator] phpize default option values
2 parents 2344c22 + d65679b commit 0a4a92b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function parseConstraints(\SimpleXMLElement $nodes)
8484
$options = array();
8585
}
8686
} elseif (strlen((string) $node) > 0) {
87-
$options = trim($node);
87+
$options = XmlUtils::phpize(trim($node));
8888
} else {
8989
$options = null;
9090
}

src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Validator\Constraints\Range;
2020
use Symfony\Component\Validator\Constraints\Regex;
2121
use Symfony\Component\Validator\Constraints\IsTrue;
22+
use Symfony\Component\Validator\Constraints\Traverse;
2223
use Symfony\Component\Validator\Exception\MappingException;
2324
use Symfony\Component\Validator\Mapping\ClassMetadata;
2425
use Symfony\Component\Validator\Mapping\Loader\XmlFileLoader;
@@ -57,6 +58,7 @@ public function testLoadClassMetadata()
5758
$expected->addConstraint(new Callback('validateMe'));
5859
$expected->addConstraint(new Callback('validateMeStatic'));
5960
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
61+
$expected->addConstraint(new Traverse(false));
6062
$expected->addPropertyConstraint('firstName', new NotNull());
6163
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));
6264
$expected->addPropertyConstraint('firstName', new Choice(array('A', 'B')));

src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
<value>callback</value>
3232
</constraint>
3333

34+
<!-- Traverse with boolean default option -->
35+
<constraint name="Traverse">
36+
false
37+
</constraint>
38+
3439
<!-- PROPERTY CONSTRAINTS -->
3540

3641
<property name="firstName">

0 commit comments

Comments
 (0)