Browse Source

Don't marshal arrays to 1.

ADmad 7 years ago
parent
commit
a7e21d3bcc

+ 1 - 4
src/Database/Type/IntegerType.php

@@ -130,12 +130,9 @@ class IntegerType extends Type implements TypeInterface, BatchCastingInterface
         if ($value === null || $value === '') {
             return null;
         }
-        if (is_numeric($value) || ctype_digit($value)) {
+        if (is_numeric($value)) {
             return (int)$value;
         }
-        if (is_array($value)) {
-            return 1;
-        }
 
         return null;
     }

+ 4 - 1
tests/TestCase/Database/Type/IntegerTypeTest.php

@@ -159,7 +159,10 @@ class IntegerTypeTest extends TestCase
         $this->assertNull($result);
 
         $result = $this->type->marshal(['3', '4']);
-        $this->assertSame(1, $result);
+        $this->assertNull($result);
+
+        $result = $this->type->marshal('+0123.45e2');
+        $this->assertSame(12345, $result);
     }
 
     /**