Skip to content

Commit 8df044d

Browse files
committed
remove bccomp call, fix cast
1 parent dc363be commit 8df044d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/Column.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,16 @@ public static function castIntegerSafely($value): string|int
117117
return $value;
118118
}
119119

120+
// string representation of a float
121+
elseif ((string) (float) $value === $value && (string) (int) $value !== $value) {
122+
return (int) $value;
123+
}
124+
120125
// If adding 0 to a string causes a float conversion,
121126
// we have a number over PHP_INT_MAX
122-
elseif (is_string($value) && 1 === bccomp($value, (string) PHP_INT_MAX)) {
123-
return $value;
127+
// @phpstan-ignore-next-line
128+
elseif (is_string($value) && is_float($value + 0)) {
129+
return (string) $value;
124130
}
125131

126132
// If a float was passed and is greater than PHP_INT_MAX

0 commit comments

Comments
 (0)