Skip to content

Commit

Permalink
Merge branch 'yiisoft:column_type_classes2' into column_type_classes2
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov authored May 6, 2024
2 parents 78806d7 + cb0a28b commit ece7157
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Schema/Column/BigIntColumnSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Schema\SchemaInterface;

use function is_int;

use const PHP_INT_MAX;
use const PHP_INT_MIN;

Expand All @@ -23,18 +21,20 @@ public function __construct(

public function dbTypecast(mixed $value): int|string|ExpressionInterface|null
{
if (is_int($value)) {
return $value;
}

return match ($value) {
null, '' => null,
false => 0,
default => $value instanceof ExpressionInterface
? $value
: (($val = (string) $value) <= PHP_INT_MAX && $val >= PHP_INT_MIN
return match (gettype($value)) {
'string' => $value === '' ? null : (
$value <= PHP_INT_MAX && $value >= PHP_INT_MIN
? (int) $value
: $value
),
'NULL' => null,
'integer' => $value,
'boolean' => $value ? 1 : 0,
default => $value instanceof ExpressionInterface ? $value : (
($val = (string) $value) <= PHP_INT_MAX && $val >= PHP_INT_MIN
? (int) $val
: $val),
: $val
),
};
}

Expand Down

0 comments on commit ece7157

Please sign in to comment.