Skip to content

Commit e83cd2d

Browse files
committed
Fixed issues with strict type added by the code style
1 parent e19f95f commit e83cd2d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Enum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function getLabel($value): string
7171
{
7272
$this->init();
7373

74-
$label = \array_search($value, $this->choices, true);
74+
$label = \array_search($value, $this->choices, false);
7575
if ($label === false) {
7676
throw InvalidArgumentException::enumMissingValue($this, $value);
7777
}

src/Exception/InvalidArgumentException.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@ public static function unregisteredEnum(string $name): self
1919
));
2020
}
2121

22-
public static function enumMissingValue(EnumInterface $enum, string $value): self
22+
public static function enumMissingValue(EnumInterface $enum, mixed $value): self
2323
{
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+
2431
return new self(\sprintf(
2532
'Enum "%s" does not have "%s" value.',
2633
$enum->getName(),

0 commit comments

Comments
 (0)