Skip to content

Commit

Permalink
Fixing batch casting
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 5, 2018
1 parent 1c04732 commit ca23d3f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/Database/FieldTypeConverter.php
Expand Up @@ -82,8 +82,8 @@ public function __construct(TypeMap $typeMap, Driver $driver)
// 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;
Expand Down
10 changes: 2 additions & 8 deletions src/Database/Type/DecimalType.php
Expand Up @@ -107,10 +107,7 @@ public function toPHP($value, Driver $driver)
return $value;
}

// Using coercion is faster than casting
// @codingStandardsIgnoreStart
return (float)+$value;
// @codingStandardsIgnoreEnd
return (float)$value;
}

/**
Expand All @@ -125,10 +122,7 @@ public function manyToPHP(array $values, array $fields, Driver $driver)
continue;
}

// Using coercion is faster than casting
// @codingStandardsIgnoreStart
$values[$field] = (float)+$values[$field];
// @codingStandardsIgnoreEnd
$values[$field] = (float)$values[$field];
}

return $values;
Expand Down
10 changes: 2 additions & 8 deletions src/Database/Type/IntegerType.php
Expand Up @@ -87,10 +87,7 @@ public function toPHP($value, Driver $driver)
return $value;
}

// Using coercion is faster than casting
// @codingStandardsIgnoreStart
return (int)+$value;
// @codingStandardsIgnoreEnd
return (int)$value;
}

/**
Expand All @@ -104,10 +101,7 @@ public function manyToPHP(array $values, array $fields, Driver $driver)
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;
Expand Down

0 comments on commit ca23d3f

Please sign in to comment.