Skip to content

Commit 3c1738a

Browse files
committed
bug #18298 [Validator] do not treat payload as callback (xabbuh)
This PR was merged into the 2.7 branch. Discussion ---------- [Validator] do not treat payload as callback | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | see http://stackoverflow.com/a/36140305/2289865 Commits ------- 2066fc0 [Validator] do not treat payload as callback
2 parents 831de7a + 2066fc0 commit 3c1738a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/Symfony/Component/Validator/Constraints/Callback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct($options = null)
4949
@trigger_error('The "methods" option of the '.__CLASS__.' class is deprecated since version 2.4 and will be removed in 3.0. Use the "callback" option instead.', E_USER_DEPRECATED);
5050
}
5151

52-
if (is_array($options) && !isset($options['callback']) && !isset($options['methods']) && !isset($options['groups'])) {
52+
if (is_array($options) && !isset($options['callback']) && !isset($options['methods']) && !isset($options['groups']) && !isset($options['payload'])) {
5353
if (is_callable($options) || !$options) {
5454
$options = array('callback' => $options);
5555
} else {

src/Symfony/Component/Validator/Tests/Fixtures/Entity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function getData()
8585
}
8686

8787
/**
88-
* @Assert\Callback
88+
* @Assert\Callback(payload="foo")
8989
*/
9090
public function validateMe(ExecutionContextInterface $context)
9191
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testLoadClassMetadata()
5353
$expected->setGroupSequence(array('Foo', 'Entity'));
5454
$expected->addConstraint(new ConstraintA());
5555
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
56-
$expected->addConstraint(new Callback('validateMe'));
56+
$expected->addConstraint(new Callback(array('callback' => 'validateMe', 'payload' => 'foo')));
5757
$expected->addConstraint(new Callback('validateMeStatic'));
5858
$expected->addPropertyConstraint('firstName', new NotNull());
5959
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));
@@ -123,7 +123,7 @@ public function testLoadClassMetadataAndMerge()
123123
$expected->setGroupSequence(array('Foo', 'Entity'));
124124
$expected->addConstraint(new ConstraintA());
125125
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
126-
$expected->addConstraint(new Callback('validateMe'));
126+
$expected->addConstraint(new Callback(array('callback' => 'validateMe', 'payload' => 'foo')));
127127
$expected->addConstraint(new Callback('validateMeStatic'));
128128
$expected->addPropertyConstraint('firstName', new NotNull());
129129
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));

0 commit comments

Comments
 (0)