Skip to content

Commit 621f8aa

Browse files
Miteugenekorotkov
and
korotkov
authored
fix return types for enums (#57)
* Add MixedValueToScalarConverter for fixing a problem with SQL binding of non-scalar values such as enums * fix return types --------- Co-authored-by: korotkov <[email protected]>
1 parent a921c98 commit 621f8aa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: src/Converters/MixedValueToScalarConverter.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
class MixedValueToScalarConverter
1010
{
11-
public function handle(mixed $value): int|float|bool|string
11+
public function handle(mixed $value): int|float|bool|string|null
1212
{
1313
if (is_scalar($value) || $value === null) {
1414
return $value;
1515
} elseif (is_object($value) && PHP_VERSION_ID >= 80100 && enum_exists(get_class($value))) {
1616
return $value->value;
1717
} elseif (is_object($value) && method_exists($value, '__toString')) {
1818
$value->__toString();
19-
} else {
20-
throw new BulkValueTypeIsNotSupported($value);
2119
}
20+
21+
throw new BulkValueTypeIsNotSupported($value);
2222
}
2323
}

0 commit comments

Comments
 (0)