engine/mysql: remove bitfield implementation as it's not used

This commit is contained in:
E. S 2025-04-28 14:55:13 +03:00
parent c0d40e6f97
commit c21619c429
4 changed files with 0 additions and 77 deletions

View File

@ -92,11 +92,6 @@ abstract class Model
$model_upd[$field->getModelName()] = $value; $model_upd[$field->getModelName()] = $value;
break; break;
case ModelFieldType::BITFIELD:
$db_upd[$name] = $value;
$model_upd[$field->getModelName()] = $value;
break;
default: default:
$value = (string)$value; $value = (string)$value;
$db_upd[$name] = $value; $db_upd[$name] = $value;
@ -179,9 +174,6 @@ abstract class Model
case 'bool': case 'bool':
$mytype = ModelFieldType::BOOLEAN; $mytype = ModelFieldType::BOOLEAN;
break; break;
case 'mysql_bitfield':
$mytype = ModelFieldType::BITFIELD;
break;
default: default:
if (enum_exists($typename)) { if (enum_exists($typename)) {
$mytype = ModelFieldType::BACKED_ENUM; $mytype = ModelFieldType::BACKED_ENUM;

View File

@ -11,6 +11,5 @@ enum ModelFieldType
case BOOLEAN; case BOOLEAN;
case JSON; case JSON;
case SERIALIZED; case SERIALIZED;
case BITFIELD;
case BACKED_ENUM; case BACKED_ENUM;
} }

View File

@ -57,9 +57,6 @@ class ModelProperty
$val = null; $val = null;
return $val; return $val;
case ModelFieldType::BITFIELD:
return new MySQLBitField($value);
case ModelFieldType::BACKED_ENUM: case ModelFieldType::BACKED_ENUM:
try { try {
return $this->realType::from($value); return $this->realType::from($value);

View File

@ -1,65 +0,0 @@
<?php
namespace engine;
use Exception;
use GMP;
class MySQLBitField
{
private GMP $value;
private int $size;
public function __construct($value, int $size = 64) {
$this->value = gmp_init($value);
$this->size = $size;
}
/**
* @throws Exception
*/
public function has(int $bit): bool {
$this->validateBit($bit);
return gmp_testbit($this->value, $bit);
}
/**
* @throws Exception
*/
public function set(int $bit): void {
$this->validateBit($bit);
gmp_setbit($this->value, $bit);
}
/**
* @throws Exception
*/
public function clear(int $bit): void {
$this->validateBit($bit);
gmp_clrbit($this->value, $bit);
}
public function isEmpty(): bool {
return !gmp_cmp($this->value, 0);
}
public function __toString(): string {
$buf = '';
for ($bit = $this->size - 1; $bit >= 0; --$bit)
$buf .= gmp_testbit($this->value, $bit) ? '1' : '0';
if (($pos = strpos($buf, '1')) !== false) {
$buf = substr($buf, $pos);
} else {
$buf = '0';
}
return $buf;
}
/**
* @throws Exception
*/
private function validateBit(int $bit): void {
if ($bit < 0 || $bit >= $this->size)
throw new Exception('invalid bit ' . $bit . ', allowed range: [0..' . $this->size . ')');
}
}