File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ public function getLabel($value): string
71
71
{
72
72
$ this ->init ();
73
73
74
- $ label = \array_search ($ value , $ this ->choices , true );
74
+ $ label = \array_search ($ value , $ this ->choices , false );
75
75
if ($ label === false ) {
76
76
throw InvalidArgumentException::enumMissingValue ($ this , $ value );
77
77
}
Original file line number Diff line number Diff line change @@ -19,8 +19,15 @@ public static function unregisteredEnum(string $name): self
19
19
));
20
20
}
21
21
22
- public static function enumMissingValue (EnumInterface $ enum , string $ value ): self
22
+ public static function enumMissingValue (EnumInterface $ enum , mixed $ value ): self
23
23
{
24
+ if (\is_object ($ value ) && \method_exists ($ value , '__toString ' )) {
25
+ $ value = (string )$ value ;
26
+ }
27
+ if (!\is_string ($ value )) {
28
+ $ value = \get_debug_type ($ value );
29
+ }
30
+
24
31
return new self (\sprintf (
25
32
'Enum "%s" does not have "%s" value. ' ,
26
33
$ enum ->getName (),
You can’t perform that action at this time.
0 commit comments