diff --git a/src/Types/BigIntType.php b/src/Types/BigIntType.php index 1d068a42c2d..8489cf641e1 100644 --- a/src/Types/BigIntType.php +++ b/src/Types/BigIntType.php @@ -8,7 +8,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; /** - * Type that maps a database BIGINT to a PHP string. + * Type that maps a database BIGINT to a PHP int. */ class BigIntType extends Type implements PhpIntegerMappingType { @@ -22,18 +22,27 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st public function getBindingType(): ParameterType { - return ParameterType::STRING; + return ParameterType::INTEGER; } /** * @param T $value * - * @return (T is null ? null : string) + * @return (T is null ? null : int|string) * * @template T */ - public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?string + public function convertToPHPValue(mixed $value, AbstractPlatform $platform): int|string|null { - return $value === null ? null : (string) $value; + if (null === $value) { + return null; + } elseif ( + $value <= PHP_INT_MAX && + $value >= PHP_INT_MIN + ) { + return (int) $value; + } else { + return (string) $value; + } } }