Skip to content

Commit e906a37

Browse files
authored
Fix the unsigned BIGINT check for PHP 8.5 (#7180)
| Q | A |------------- | ----------- | Type | bug | Fixed issues | Replaces #7179 #### Summary This PR simplifies our check for `UNSIGNED BIGINT` in a way that we avoid the new warning triggered by PHP 8.5 if we cause an integer overflow by casting a string to int.
1 parent 823aed0 commit e906a37

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/Types/BigIntType.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99

1010
use function assert;
1111
use function is_int;
12+
use function is_numeric;
1213
use function is_string;
1314

14-
use const PHP_INT_MAX;
15-
use const PHP_INT_MIN;
16-
1715
/**
1816
* Type that attempts to map a database BIGINT to a PHP int.
1917
*
@@ -48,15 +46,13 @@ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): int
4846
}
4947

5048
assert(
51-
is_string($value),
49+
is_string($value) && is_numeric($value),
5250
'DBAL assumes values outside of the integer range to be returned as string by the database driver.',
5351
);
5452

55-
if (
56-
($value > PHP_INT_MIN && $value < PHP_INT_MAX)
57-
|| $value === (string) (int) $value
58-
) {
59-
return (int) $value;
53+
$intValue = 0 + $value;
54+
if (is_int($intValue)) {
55+
return $intValue;
6056
}
6157

6258
return $value;

0 commit comments

Comments
 (0)