8000 Return always the name of enum in formatValue · symfony/symfony@ae9ca65 · GitHub
[go: up one dir, main page]

Skip to content

Commit ae9ca65

Browse files
committed
Return always the name of enum in formatValue
1 parent ad18743 commit ae9ca65

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/Symfony/Component/Validator/ConstraintValidator.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ protected function formatValue(mixed $value, int $format = 0): string
8989
}
9090

9191
if ($value instanceof \UnitEnum) {
92-
if ($format & self::OBJECT_TO_STRING) {
93-
return $value->name;
94-
}
95-
96-
return 'enum';
92+
return $value->name;
9793
}
9894

9995
if (\is_object($value)) {

src/Symfony/Component/Validator/Tests/ConstraintValidatorTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public static function formatValueProvider()
4141
['array', []],
4242
['object', $toString = new TestToStringObject()],
4343
['ccc', $toString, ConstraintValidator::OBJECT_TO_STRING],
44-
['enum', $toString = TestEnum::FirstCase],
45-
['FirstCase', $toString, ConstraintValidator::OBJECT_TO_STRING],
44+
['FirstCase', $toString = TestEnum::FirstCase],
4645
['object', $dateTime = new \DateTimeImmutable('1971-02-02T08:00:00UTC')],
4746
[class_exists(\IntlDateFormatter::class) ? 'Oct 4, 2019, 11:02 AM' : '2019-10-04 11:02:03', new \DateTimeImmutable('2019-10-04T11:02:03+09:00'), ConstraintValidator::PRETTY_DATE],
4847
[class_exists(\IntlDateFormatter::class) ? 'Feb 2, 1971, 8:00 AM' : '1971-02-02 08:00:00', $dateTime, ConstraintValidator::PRETTY_DATE],

0 commit comments

Comments
 (0)
0