Browse Source

Fixing batch casting

Jose Lorenzo Rodriguez 8 years ago
parent
commit
ca23d3f477

+ 2 - 2
src/Database/FieldTypeConverter.php

@@ -82,8 +82,8 @@ class FieldTypeConverter
             // the interface. Users can implement the TypeInterface instead to have
             // access to this feature.
             $batchingType = $type instanceof BatchCastingInterface &&
-                $type instanceof Type &&
-                strpos(get_class($type), 'Cake\Database\Type') === false;
+                !($type instanceof Type &&
+                strpos(get_class($type), 'Cake\Database\Type') === false);
 
             if ($batchingType) {
                 $batchingMap[$k] = $type;

+ 2 - 8
src/Database/Type/DecimalType.php

@@ -107,10 +107,7 @@ class DecimalType extends Type implements TypeInterface, BatchCastingInterface
             return $value;
         }
 
-        // Using coercion is faster than casting
-        // @codingStandardsIgnoreStart
-        return (float)+$value;
-        // @codingStandardsIgnoreEnd
+        return (float)$value;
     }
 
     /**
@@ -125,10 +122,7 @@ class DecimalType extends Type implements TypeInterface, BatchCastingInterface
                 continue;
             }
 
-            // Using coercion is faster than casting
-            // @codingStandardsIgnoreStart
-            $values[$field] = (float)+$values[$field];
-            // @codingStandardsIgnoreEnd
+            $values[$field] = (float)$values[$field];
         }
 
         return $values;

+ 2 - 8
src/Database/Type/IntegerType.php

@@ -87,10 +87,7 @@ class IntegerType extends Type implements TypeInterface, BatchCastingInterface
             return $value;
         }
 
-        // Using coercion is faster than casting
-        // @codingStandardsIgnoreStart
-        return (int)+$value;
-        // @codingStandardsIgnoreEnd
+        return (int)$value;
     }
 
     /**
@@ -104,10 +101,7 @@ class IntegerType extends Type implements TypeInterface, BatchCastingInterface
             if (!isset($values[$field])) {
                 continue;
             }
-            // Using coercion is faster than casting
-            // @codingStandardsIgnoreStart
-            $values[$field] = (int)+$values[$field];
-            // @codingStandardsIgnoreEnd
+            $values[$field] = (int)$values[$field];
         }
 
         return $values;