From d50315e07ddd26d0e0f94caf6d2d231c15f42ee2 Mon Sep 17 00:00:00 2001 From: Andrii Dembitskyi Date: Thu, 30 Sep 2021 15:05:41 +0300 Subject: [PATCH] Add explanation why we need to cast float to string in decimal type only starting from PHP 8.1 --- lib/Doctrine/DBAL/Types/DecimalType.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Doctrine/DBAL/Types/DecimalType.php b/lib/Doctrine/DBAL/Types/DecimalType.php index fbf53f3880a..f75d3db2c68 100644 --- a/lib/Doctrine/DBAL/Types/DecimalType.php +++ b/lib/Doctrine/DBAL/Types/DecimalType.php @@ -34,6 +34,8 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform) */ public function convertToPHPValue($value, AbstractPlatform $platform) { + // Some drivers starting from PHP 8.1 can represent decimals as float + // See also: https://github.com/doctrine/dbal/pull/4818 if (PHP_VERSION_ID >= 80100 && is_float($value)) { return (string) $value; }