Skip to content

[Validator] do not treat payload as callback #18298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct($options = null)
@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);
}

if (is_array($options) && !isset($options['callback']) && !isset($options['methods']) && !isset($options['groups'])) {
if (is_array($options) && !isset($options['callback']) && !isset($options['methods']) && !isset($options['groups']) && !isset($options['payload'])) {
if (is_callable($options) || !$options) {
$options = array('callback' => $options);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Tests/Fixtures/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getData()
}

/**
* @Assert\Callback
* @Assert\Callback(payload="foo")
*/
public function validateMe(ExecutionContextInterface $context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testLoadClassMetadata()
$expected->setGroupSequence(array('Foo', 'Entity'));
$expected->addConstraint(new ConstraintA());
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
$expected->addConstraint(new Callback('validateMe'));
$expected->addConstraint(new Callback(array('callback' => 'validateMe', 'payload' => 'foo')));
$expected->addConstraint(new Callback('validateMeStatic'));
$expected->addPropertyConstraint('firstName', new NotNull());
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));
Expand Down Expand Up @@ -123,7 +123,7 @@ public function testLoadClassMetadataAndMerge()
$expected->setGroupSequence(array('Foo', 'Entity'));
$expected->addConstraint(new ConstraintA());
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
$expected->addConstraint(new Callback('validateMe'));
$expected->addConstraint(new Callback(array('callback' => 'validateMe', 'payload' => 'foo')));
$expected->addConstraint(new Callback('validateMeStatic'));
$expected->addPropertyConstraint('firstName', new NotNull());
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));
Expand Down