Skip to content

Commit 45000ec

Browse files
author
symfonyaml
committed
Add that the callable in the error message
1 parent 2e391d3 commit 45000ec

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function validate($value, Constraint $constraint)
5656
$choices = iterator_to_array($choices);
5757
}
5858
if (!\is_array($choices)) {
59-
throw new ConstraintDefinitionException(\sprintf('The Choice constraint expects the callback to return an iterable value, got "%s".', get_debug_type($choices)));
59+
throw new ConstraintDefinitionException(\sprintf('The Choice constraint expects the callback %s to return an iterable value, got "%s".', $this->formatValue($constraint->callback), get_debug_type($choices)));
6060
}
6161
} else {
6262
$choices = $constraint->choices;

src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function staticCallbackInvalid()
3939
return null;
4040
}
4141

42-
public static function staticCallbackIterable()
42+
public static function staticCallbackTraversable()
4343
{
4444
yield 1;
4545
yield 2;
@@ -200,7 +200,7 @@ public function testInvalidChoice(Choice $constraint)
200200
public function testInvalidChoiceCallbackContextMethod()
201201
{
202202
$this->expectException(ConstraintDefinitionException::class);
203-
$this->expectExceptionMessage('The Choice constraint expects the callback to return an iterable value, got "null".');
203+
$this->expectExceptionMessage('The Choice constraint expects the callback "staticCallbackInvalid" to return an iterable value, got "null".');
204204
// search $this for "staticCallbackInvalid"
205205
$this->setObject($this);
206206

@@ -209,12 +209,12 @@ public function testInvalidChoiceCallbackContextMethod()
209209
$this->validator->validate('bar', $constraint);
210210
}
211211

212-
public function testValidChoiceCallbackContextMethodIterable()
212+
public function testValidChoiceCallbackContextMethodTraversable()
213213
{
214-
// search $this for "staticCallbackIterable"
214+
// search $this for "staticCallbackTraversable"
215215
$this->setObject($this);
216216

217-
$constraint = new Choice(['callback' => 'staticCallbackIterable']);
217+
$constraint = new Choice(['callback' => 'staticCallbackTraversable']);
218218

219219
$this->validator->validate(1, $constraint);
220220

0 commit comments

Comments
 (0)