qqq
This commit is contained in:
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace Database\Base;
|
||||
|
||||
|
||||
use Database\ActiveQuery;
|
||||
use Database\ModelInterface;
|
||||
use Exception;
|
||||
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Base;
|
||||
|
||||
use Database\ModelInterface;
|
||||
|
||||
class Getter
|
||||
{
|
||||
|
||||
private array $getter = [];
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $className
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
public function write(string $name, string $className, string $method): void
|
||||
{
|
||||
if (!isset($this->getter[$className])) {
|
||||
$this->getter[$className] = [];
|
||||
}
|
||||
$this->getter[$className][$name] = $method;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @return array
|
||||
*/
|
||||
public function getAll(string $className): array
|
||||
{
|
||||
return $this->getter[$className] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function has(string $className, string $name): bool
|
||||
{
|
||||
return isset($this->getter[$className]) && isset($this->getter[$className][$name]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ModelInterface $class
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function override(ModelInterface $class, string $key, mixed $value): mixed
|
||||
{
|
||||
$method = $this->getter[$class::class][$key] ?? null;
|
||||
if ($method !== null) {
|
||||
return $class->{$method}($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $name
|
||||
* @return string|null
|
||||
*/
|
||||
public function get(string $className, string $name): ?string
|
||||
{
|
||||
if (!$this->has($className,$name)) {
|
||||
return null;
|
||||
}
|
||||
return $this->getter[$className][$name];
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -536,7 +536,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
|
||||
}
|
||||
$validate = $this->resolve($rule);
|
||||
if (!$validate->validation()) {
|
||||
return \Kiri::getLogger()->addError($validate->getError(), 'mysql');
|
||||
return \Kiri::getLogger()->failure($validate->getError(), 'mysql');
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Base;
|
||||
|
||||
use Database\ModelInterface;
|
||||
|
||||
class Setter
|
||||
{
|
||||
|
||||
private array $setter = [];
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $className
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
public function write(string $name, string $className, string $method): void
|
||||
{
|
||||
if (!isset($this->setter[$className])) {
|
||||
$this->setter[$className] = [];
|
||||
}
|
||||
$this->setter[$className][$name] = $method;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function has(string $className, string $name): bool
|
||||
{
|
||||
return isset($this->setter[$className]) && isset($this->setter[$className][$name]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @return array|null
|
||||
*/
|
||||
public function getAll(string $className): ?array
|
||||
{
|
||||
return $this->setter[$className] ?? null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ModelInterface $class
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function override(ModelInterface $class, string $key, mixed $value): mixed
|
||||
{
|
||||
$method = $this->setter[$class::class][$key] ?? null;
|
||||
if ($method !== null) {
|
||||
return $class->{$method}($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $name
|
||||
* @return string|null
|
||||
*/
|
||||
public function get(string $className, string $name): ?string
|
||||
{
|
||||
if (!$this->has($className, $name)) {
|
||||
return null;
|
||||
}
|
||||
return $this->setter[$className][$name];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+9
-12
@@ -59,16 +59,14 @@ class Collection extends AbstractCollection
|
||||
public function update(array $attributes): bool
|
||||
{
|
||||
$lists = [];
|
||||
$primary = $this->getModel()->getPrimary();
|
||||
$items = $this->getItems();
|
||||
if ($this->isEmpty() || !isset($items[0][$primary])) {
|
||||
return false;
|
||||
}
|
||||
foreach ($items as $item) {
|
||||
$lists[] = $item[$primary];
|
||||
}
|
||||
return $this->getModel()::query()->whereIn($primary, $lists)
|
||||
->update($attributes);
|
||||
$model = $this->getModel();
|
||||
if (!$this->isEmpty()) {
|
||||
foreach ($this->_item as $item) {
|
||||
$lists[] = $item[$model->getPrimary()];
|
||||
}
|
||||
return $model::query()->whereIn($model->getPrimary(), $lists)->update($attributes);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,8 +183,7 @@ class Collection extends AbstractCollection
|
||||
{
|
||||
$model = $this->getModel();
|
||||
if ($model->hasPrimary()) {
|
||||
$key = $model->getPrimary();
|
||||
return $model::query()->whereIn($key, $this->column($key))->delete();
|
||||
return $model::query()->whereIn($model->getPrimary(), $this->column($model->getPrimary()))->delete();
|
||||
}
|
||||
throw new Exception('Must set primary key. if you wante delete');
|
||||
}
|
||||
|
||||
+21
-27
@@ -15,6 +15,7 @@ use Kiri\Abstracts\Component;
|
||||
use Kiri\Di\Container;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
use ReflectionException;
|
||||
use Throwable;
|
||||
|
||||
@@ -77,12 +78,7 @@ class Command extends Component
|
||||
public function all(): bool|array
|
||||
{
|
||||
try {
|
||||
$client = $this->connection->getConnection();
|
||||
if (($prepare = $client->prepare($this->sql)) === false) {
|
||||
throw new Exception($client->errorInfo()[1]);
|
||||
}
|
||||
$prepare->execute($this->params);
|
||||
return $prepare->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $this->prepare()->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (Throwable $throwable) {
|
||||
if ($this->canReconnect($throwable->getMessage())) {
|
||||
return $this->all();
|
||||
@@ -100,12 +96,7 @@ class Command extends Component
|
||||
public function one(): null|bool|array
|
||||
{
|
||||
try {
|
||||
$client = $this->connection->getConnection();
|
||||
if (($prepare = $client->prepare($this->sql)) === false) {
|
||||
throw new Exception($client->errorInfo()[1]);
|
||||
}
|
||||
$prepare->execute($this->params);
|
||||
return $prepare->fetch(PDO::FETCH_ASSOC);
|
||||
return $this->prepare()->fetch(PDO::FETCH_ASSOC);
|
||||
} catch (Throwable $throwable) {
|
||||
if ($this->canReconnect($throwable->getMessage())) {
|
||||
return $this->one();
|
||||
@@ -123,12 +114,7 @@ class Command extends Component
|
||||
public function fetchColumn(): null|bool|array
|
||||
{
|
||||
try {
|
||||
$client = $this->connection->getConnection();
|
||||
if (($prepare = $client->prepare($this->sql)) === false) {
|
||||
throw new Exception($client->errorInfo()[1]);
|
||||
}
|
||||
$prepare->execute($this->params);
|
||||
return $prepare->fetchColumn(PDO::FETCH_ASSOC);
|
||||
return $this->prepare()->fetchColumn(PDO::FETCH_ASSOC);
|
||||
} catch (Throwable $throwable) {
|
||||
if ($this->canReconnect($throwable->getMessage())) {
|
||||
return $this->fetchColumn();
|
||||
@@ -146,12 +132,7 @@ class Command extends Component
|
||||
public function rowCount(): int|bool
|
||||
{
|
||||
try {
|
||||
$client = $this->connection->getConnection();
|
||||
if (($prepare = $client->prepare($this->sql)) === false) {
|
||||
throw new Exception($client->errorInfo()[1]);
|
||||
}
|
||||
$prepare->execute($this->params);
|
||||
return $prepare->rowCount();
|
||||
return $this->prepare()->rowCount();
|
||||
} catch (Throwable $throwable) {
|
||||
if ($this->canReconnect($throwable->getMessage())) {
|
||||
return $this->rowCount();
|
||||
@@ -163,6 +144,21 @@ class Command extends Component
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return PDOStatement
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function prepare(): PDOStatement
|
||||
{
|
||||
$client = $this->connection->getConnection();
|
||||
if (($prepare = $client->prepare($this->sql)) === false) {
|
||||
throw new Exception($client->errorInfo()[1]);
|
||||
}
|
||||
$prepare->execute($this->params);
|
||||
return $prepare;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int|bool
|
||||
* @throws Exception
|
||||
@@ -173,7 +169,6 @@ class Command extends Component
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return bool|int
|
||||
* @throws ConfigException
|
||||
@@ -230,8 +225,7 @@ class Command extends Component
|
||||
*/
|
||||
private function error(Throwable $throwable): bool
|
||||
{
|
||||
$message = $this->sql . '.' . json_encode($this->params, JSON_UNESCAPED_UNICODE) . PHP_EOL . jTraceEx($throwable);
|
||||
return addError($message, 'mysql');
|
||||
return trigger_print_error($this->sql . '.' . json_encode($this->params, JSON_UNESCAPED_UNICODE) . PHP_EOL . jTraceEx($throwable), 'mysql');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ use Kiri;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use ReflectionException;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@@ -56,7 +57,9 @@ class Db implements ISqlBuilder
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws Exception
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public static function beginTransaction(): void
|
||||
{
|
||||
@@ -78,8 +81,7 @@ class Db implements ISqlBuilder
|
||||
try {
|
||||
$result = call_user_func($closure, ...$params);
|
||||
} catch (Throwable $throwable) {
|
||||
error($throwable);
|
||||
$result = addError($throwable->getMessage(), 'mysql');
|
||||
$result = trigger_print_error($throwable->getMessage(), 'mysql');
|
||||
} finally {
|
||||
if ($result === false) {
|
||||
static::rollback();
|
||||
@@ -93,6 +95,9 @@ class Db implements ISqlBuilder
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public static function commit(): void
|
||||
{
|
||||
@@ -102,6 +107,9 @@ class Db implements ISqlBuilder
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public static function rollback(): void
|
||||
{
|
||||
|
||||
@@ -10,15 +10,10 @@ declare(strict_types=1);
|
||||
namespace Database;
|
||||
|
||||
|
||||
use Database\Base\Getter;
|
||||
use Database\Traits\HasBase;
|
||||
use Exception;
|
||||
use Kiri;
|
||||
use Kiri\Exception\NotFindClassException;
|
||||
use Kiri\Error\StdoutLoggerInterface;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use ReflectionException;
|
||||
|
||||
defined('SAVE_FAIL') or define('SAVE_FAIL', 3227);
|
||||
defined('FIND_OR_CREATE_MESSAGE') or define('FIND_OR_CREATE_MESSAGE', 'Create a new model, but the data cannot be empty.');
|
||||
@@ -185,7 +180,7 @@ class Model extends Base\Model
|
||||
public static function inserts(array $data): bool
|
||||
{
|
||||
if (empty($data)) {
|
||||
return addError('Insert data empty.', 'mysql');
|
||||
return trigger_print_error('Insert data empty.', 'mysql');
|
||||
}
|
||||
return static::query()->insert($data);
|
||||
}
|
||||
@@ -196,15 +191,15 @@ class Model extends Base\Model
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
if (!$this->beforeDelete()) {
|
||||
return false;
|
||||
if ($this->beforeDelete()) {
|
||||
if ($this->hasPrimary()) {
|
||||
$result = static::deleteByCondition("id = :id", [":id" => $this->getPrimaryValue()]);
|
||||
} else {
|
||||
$result = static::deleteByCondition($this->_attributes);
|
||||
}
|
||||
return $this->afterDelete($result);
|
||||
}
|
||||
if ($this->hasPrimary()) {
|
||||
$result = static::deleteByCondition("id = :id", [":id" => $this->getPrimaryValue()]);
|
||||
} else {
|
||||
$result = static::deleteByCondition($this->_attributes);
|
||||
}
|
||||
return $this->afterDelete($result);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -217,8 +212,7 @@ class Model extends Base\Model
|
||||
*/
|
||||
public static function updateAll(mixed $condition, array $attributes = []): bool
|
||||
{
|
||||
$condition = static::query()->where($condition);
|
||||
return $condition->update($attributes);
|
||||
return static::query()->where($condition)->update($attributes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+353
-350
@@ -25,382 +25,385 @@ use Kiri\Core\Json;
|
||||
class Columns extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* field types
|
||||
*/
|
||||
private array $columns = [];
|
||||
/**
|
||||
* @var array
|
||||
* field types
|
||||
*/
|
||||
private array $columns = [];
|
||||
|
||||
/**
|
||||
* @var Connection
|
||||
* Mysql client
|
||||
*/
|
||||
public Connection $db;
|
||||
/**
|
||||
* @var string
|
||||
* tableName
|
||||
*/
|
||||
public string $table = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* tableName
|
||||
*/
|
||||
public string $table = '';
|
||||
/**
|
||||
* @var array
|
||||
* field primary key
|
||||
*/
|
||||
private array $_primary = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* field primary key
|
||||
*/
|
||||
private array $_primary = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* by mysql field auto_increment
|
||||
*/
|
||||
private array $_auto_increment = [];
|
||||
/**
|
||||
* @var array
|
||||
* by mysql field auto_increment
|
||||
*/
|
||||
private array $_auto_increment = [];
|
||||
|
||||
|
||||
private array $_fields = [];
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
public function table(string $table): static
|
||||
{
|
||||
$this->structure($this->table = $table);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTable(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $val
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function fieldFormat($key, $val): mixed
|
||||
{
|
||||
return $this->encode($val, $this->get_fields($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return array
|
||||
* @throws
|
||||
*/
|
||||
public function populate($data): array
|
||||
{
|
||||
$column = $this->get_fields();
|
||||
foreach ($data as $key => $val) {
|
||||
if (!isset($column[$key])) {
|
||||
continue;
|
||||
}
|
||||
$data[$key] = $this->decode($val, $column[$key]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $val
|
||||
* @param null $format
|
||||
* @return mixed
|
||||
*/
|
||||
public function decode($val, $format = null): mixed
|
||||
{
|
||||
if (empty($format) || $val === null) {
|
||||
return $val;
|
||||
}
|
||||
$format = strtolower($format);
|
||||
if ($this->isInt($format)) {
|
||||
return (int)$val;
|
||||
} else if ($this->isJson($format)) {
|
||||
return Json::decode($val, true);
|
||||
} else if ($this->isFloat($format)) {
|
||||
return (float)$val;
|
||||
} else {
|
||||
return stripslashes((string)$val);
|
||||
}
|
||||
}
|
||||
private array $_fields = [];
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param $value
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function _decode(string $name, $value): mixed
|
||||
{
|
||||
return $this->decode($value, $this->get_fields($name));
|
||||
}
|
||||
/**
|
||||
* @param Connection $db
|
||||
*/
|
||||
public function __construct(public Connection $db)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
public function table(string $table): static
|
||||
{
|
||||
$this->structure($this->table = $table);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTable(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $val
|
||||
* @return string|int|bool|float
|
||||
* @throws Exception
|
||||
*/
|
||||
public function fieldFormat($key, $val): string|int|bool|float
|
||||
{
|
||||
return $this->encode($val, $this->get_fields($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return array
|
||||
* @throws
|
||||
*/
|
||||
public function populate($data): array
|
||||
{
|
||||
$column = $this->get_fields();
|
||||
foreach ($data as $key => $val) {
|
||||
if (!isset($column[$key])) {
|
||||
continue;
|
||||
}
|
||||
$data[$key] = $this->decode($val, $column[$key]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $val
|
||||
* @param null $format
|
||||
* @return mixed
|
||||
*/
|
||||
public function decode($val, $format = null): mixed
|
||||
{
|
||||
if (empty($format) || $val === null) {
|
||||
return $val;
|
||||
}
|
||||
$format = strtolower($format);
|
||||
if ($this->isInt($format)) {
|
||||
return (int)$val;
|
||||
} else if ($this->isJson($format)) {
|
||||
return Json::decode($val, true);
|
||||
} else if ($this->isFloat($format)) {
|
||||
return (float)$val;
|
||||
} else {
|
||||
return stripslashes((string)$val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $val
|
||||
* @param null $format
|
||||
* @return float|bool|int|string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function encode($val, $format = null): float|bool|int|string
|
||||
{
|
||||
if (empty($format)) {
|
||||
return $val;
|
||||
}
|
||||
$format = strtolower($format);
|
||||
if ($this->isInt($format)) {
|
||||
return (int)$val;
|
||||
} else if ($this->isJson($format)) {
|
||||
return Json::encode($val);
|
||||
} else if ($this->isFloat($format)) {
|
||||
return (float)$val;
|
||||
} else {
|
||||
return addslashes($val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $format
|
||||
* @return bool
|
||||
*/
|
||||
#[Pure] public function isInt($format): bool
|
||||
{
|
||||
return in_array($format, ['int', 'bigint', 'tinyint', 'smallint', 'mediumint']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $format
|
||||
* @return bool
|
||||
*/
|
||||
#[Pure] public function isFloat($format): bool
|
||||
{
|
||||
return in_array($format, ['float', 'double', 'decimal']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $format
|
||||
* @return bool
|
||||
*/
|
||||
#[Pure] public function isJson($format): bool
|
||||
{
|
||||
return $format == 'json';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $format
|
||||
* @return bool
|
||||
*/
|
||||
#[Pure] public function isString($format): bool
|
||||
{
|
||||
return in_array($format, ['varchar', 'char', 'text', 'longtext', 'tinytext', 'mediumtext']);
|
||||
}
|
||||
/**
|
||||
* @param string $name
|
||||
* @param $value
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function _decode(string $name, $value): mixed
|
||||
{
|
||||
return $this->decode($value, $this->get_fields($name));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws
|
||||
*/
|
||||
public function format(): array
|
||||
{
|
||||
return $this->columns('Default', 'Field');
|
||||
}
|
||||
/**
|
||||
* @param $val
|
||||
* @param null $format
|
||||
* @return float|bool|int|string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function encode($val, $format = null): float|bool|int|string
|
||||
{
|
||||
if (empty($format)) {
|
||||
return $val;
|
||||
}
|
||||
$format = strtolower($format);
|
||||
if ($this->isInt($format)) {
|
||||
return (int)$val;
|
||||
} else if ($this->isJson($format)) {
|
||||
return Json::encode($val);
|
||||
} else if ($this->isFloat($format)) {
|
||||
return (float)$val;
|
||||
} else {
|
||||
return addslashes($val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $format
|
||||
* @return bool
|
||||
*/
|
||||
#[Pure] public function isInt($format): bool
|
||||
{
|
||||
return in_array($format, ['int', 'bigint', 'tinyint', 'smallint', 'mediumint']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $format
|
||||
* @return bool
|
||||
*/
|
||||
#[Pure] public function isFloat($format): bool
|
||||
{
|
||||
return in_array($format, ['float', 'double', 'decimal']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $format
|
||||
* @return bool
|
||||
*/
|
||||
#[Pure] public function isJson($format): bool
|
||||
{
|
||||
return $format == 'json';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $format
|
||||
* @return bool
|
||||
*/
|
||||
#[Pure] public function isString($format): bool
|
||||
{
|
||||
return in_array($format, ['varchar', 'char', 'text', 'longtext', 'tinytext', 'mediumtext']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getFields(): array
|
||||
{
|
||||
if (empty($this->_fields)) {
|
||||
$this->structure($this->table);
|
||||
}
|
||||
return $this->_fields[$this->table];
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
* @throws
|
||||
*/
|
||||
public function format(): array
|
||||
{
|
||||
return $this->columns('Default', 'Field');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function hasField(string $name): bool
|
||||
{
|
||||
return array_key_exists($name, $this->getFields());
|
||||
}
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getFields(): array
|
||||
{
|
||||
if (empty($this->_fields)) {
|
||||
$this->structure($this->table);
|
||||
}
|
||||
return $this->_fields[$this->table];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int|string|null
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAutoIncrement(): int|string|null
|
||||
{
|
||||
return $this->_auto_increment[$this->table] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null|string
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPrimaryKeys(): array|string|null
|
||||
{
|
||||
if (isset($this->_auto_increment[$this->table])) {
|
||||
return $this->_auto_increment[$this->table];
|
||||
}
|
||||
return $this->_primary[$this->table] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null|string
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
#[Pure] public function getFirstPrimary(): array|string|null
|
||||
{
|
||||
if (isset($this->_auto_increment[$this->table])) {
|
||||
return $this->_auto_increment[$this->table];
|
||||
}
|
||||
if (isset($this->_primary[$this->table])) {
|
||||
return current($this->_primary[$this->table]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $index
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function columns($name, $index = null): array
|
||||
{
|
||||
if (empty($index)) {
|
||||
return array_column($this->getColumns(), $name);
|
||||
} else {
|
||||
return array_column($this->getColumns(), $name, $index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|static
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getColumns(): array|static
|
||||
{
|
||||
return $this->structure($this->getTable());
|
||||
}
|
||||
/**
|
||||
* @param string $name
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function hasField(string $name): bool
|
||||
{
|
||||
return array_key_exists($name, $this->getFields());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $table
|
||||
* @return array|Columns
|
||||
* @throws Exception
|
||||
*/
|
||||
private function structure($table): array|static
|
||||
{
|
||||
if (!isset($this->columns[$table]) || empty($this->columns[$table])) {
|
||||
$column = $this->db->createCommand(SqlBuilder::builder(null)->columns($table))->all();
|
||||
if (empty($column)) {
|
||||
throw new Exception("The table " . $table . " not exists.");
|
||||
}
|
||||
return $this->columns[$table] = $this->resolve($column, $table);
|
||||
}
|
||||
return $this->columns[$table];
|
||||
}
|
||||
/**
|
||||
* @return int|string|null
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAutoIncrement(): int|string|null
|
||||
{
|
||||
return $this->_auto_increment[$this->table] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null|string
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPrimaryKeys(): array|string|null
|
||||
{
|
||||
if (isset($this->_auto_increment[$this->table])) {
|
||||
return $this->_auto_increment[$this->table];
|
||||
}
|
||||
return $this->_primary[$this->table] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null|string
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
#[Pure] public function getFirstPrimary(): array|string|null
|
||||
{
|
||||
if (isset($this->_auto_increment[$this->table])) {
|
||||
return $this->_auto_increment[$this->table];
|
||||
}
|
||||
if (isset($this->_primary[$this->table])) {
|
||||
return current($this->_primary[$this->table]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $index
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function columns($name, $index = null): array
|
||||
{
|
||||
if (empty($index)) {
|
||||
return array_column($this->getColumns(), $name);
|
||||
} else {
|
||||
return array_column($this->getColumns(), $name, $index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|static
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getColumns(): array|static
|
||||
{
|
||||
return $this->structure($this->getTable());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $column
|
||||
* @param $table
|
||||
* @return array
|
||||
*/
|
||||
private function resolve(array $column, $table): array
|
||||
{
|
||||
foreach ($column as $key => $item) {
|
||||
$this->addPrimary($item, $table);
|
||||
$column[$key]['Type'] = $this->clean($item['Type']);
|
||||
}
|
||||
|
||||
$this->_fields[$table] = array_column($column, 'Default', 'Field');
|
||||
|
||||
return $column;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $item
|
||||
* @param $table
|
||||
*/
|
||||
private function addPrimary($item, $table)
|
||||
{
|
||||
if (!isset($this->_primary[$table])) {
|
||||
$this->_primary[$table] = [];
|
||||
}
|
||||
if ($item['Key'] === 'PRI') {
|
||||
$this->_primary[$table][] = $item['Field'];
|
||||
}
|
||||
$this->addIncrement($item, $table);
|
||||
}
|
||||
/**
|
||||
* @param $table
|
||||
* @return array|Columns
|
||||
* @throws Exception
|
||||
*/
|
||||
private function structure($table): array|static
|
||||
{
|
||||
if (!isset($this->columns[$table]) || empty($this->columns[$table])) {
|
||||
$column = $this->db->createCommand(SqlBuilder::builder(null)->columns($table))->all();
|
||||
if (empty($column)) {
|
||||
throw new Exception("The table " . $table . " not exists.");
|
||||
}
|
||||
return $this->columns[$table] = $this->resolve($column, $table);
|
||||
}
|
||||
return $this->columns[$table];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $item
|
||||
* @param $table
|
||||
*/
|
||||
private function addIncrement($item, $table)
|
||||
{
|
||||
if ($item['Extra'] !== 'auto_increment') {
|
||||
return;
|
||||
}
|
||||
$this->_auto_increment[$table] = $item['Field'];
|
||||
}
|
||||
/**
|
||||
* @param array $column
|
||||
* @param $table
|
||||
* @return array
|
||||
*/
|
||||
private function resolve(array $column, $table): array
|
||||
{
|
||||
foreach ($column as $key => $item) {
|
||||
$this->addPrimary($item, $table);
|
||||
$column[$key]['Type'] = $this->clean($item['Type']);
|
||||
}
|
||||
|
||||
$this->_fields[$table] = array_column($column, 'Default', 'Field');
|
||||
|
||||
return $column;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $item
|
||||
* @param $table
|
||||
*/
|
||||
private function addPrimary($item, $table)
|
||||
{
|
||||
if (!isset($this->_primary[$table])) {
|
||||
$this->_primary[$table] = [];
|
||||
}
|
||||
if ($item['Key'] === 'PRI') {
|
||||
$this->_primary[$table][] = $item['Field'];
|
||||
}
|
||||
$this->addIncrement($item, $table);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $type
|
||||
* @return string
|
||||
*/
|
||||
public function clean($type): string
|
||||
{
|
||||
if (!str_contains($type, ')')) {
|
||||
return $type;
|
||||
}
|
||||
$replace = preg_replace('/\(\d+(,\d+)?\)(\s+\w+)*/', '', $type);
|
||||
if (str_contains($replace, ' ')) {
|
||||
$replace = explode(' ', $replace)[1];
|
||||
}
|
||||
return $replace;
|
||||
}
|
||||
/**
|
||||
* @param $item
|
||||
* @param $table
|
||||
*/
|
||||
private function addIncrement($item, $table)
|
||||
{
|
||||
if ($item['Extra'] !== 'auto_increment') {
|
||||
return;
|
||||
}
|
||||
$this->_auto_increment[$table] = $item['Field'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $field
|
||||
* @return array|string|null
|
||||
* @throws Exception
|
||||
*/
|
||||
public function get_fields($field = null): array|string|null
|
||||
{
|
||||
$fields = $this->getAllField();
|
||||
if (empty($field)) {
|
||||
return $fields;
|
||||
}
|
||||
if (isset($fields[$field])) {
|
||||
return strtolower($fields[$field]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAllField(): array
|
||||
{
|
||||
return $this->columns('Type', 'Field');
|
||||
}
|
||||
/**
|
||||
* @param $type
|
||||
* @return string
|
||||
*/
|
||||
public function clean($type): string
|
||||
{
|
||||
if (!str_contains($type, ')')) {
|
||||
return $type;
|
||||
}
|
||||
$replace = preg_replace('/\(\d+(,\d+)?\)(\s+\w+)*/', '', $type);
|
||||
if (str_contains($replace, ' ')) {
|
||||
$replace = explode(' ', $replace)[1];
|
||||
}
|
||||
return $replace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $field
|
||||
* @return array|string|null
|
||||
* @throws Exception
|
||||
*/
|
||||
public function get_fields($field = null): array|string|null
|
||||
{
|
||||
$fields = $this->getAllField();
|
||||
if (empty($field)) {
|
||||
return $fields;
|
||||
}
|
||||
if (isset($fields[$field])) {
|
||||
return strtolower($fields[$field]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAllField(): array
|
||||
{
|
||||
return $this->columns('Type', 'Field');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ class Schema extends Component
|
||||
public function getColumns(): ?Columns
|
||||
{
|
||||
if ($this->_column === null) {
|
||||
$this->_column = new Columns(['db' => $this->db]);
|
||||
$this->_column = new Columns($this->db);
|
||||
}
|
||||
|
||||
return $this->_column;
|
||||
|
||||
+162
-158
@@ -15,193 +15,197 @@ use Kiri\Abstracts\Component;
|
||||
class Pagination extends Component
|
||||
{
|
||||
|
||||
/** @var ActiveQuery */
|
||||
private ActiveQuery $activeQuery;
|
||||
/** @var ActiveQuery */
|
||||
private ActiveQuery $activeQuery;
|
||||
|
||||
/** @var int 从第几个开始查 */
|
||||
private int $_offset = 0;
|
||||
/** @var int 从第几个开始查 */
|
||||
private int $_offset = 0;
|
||||
|
||||
/** @var int 每页数量 */
|
||||
private int $_limit = 100;
|
||||
/** @var int 每页数量 */
|
||||
private int $_limit = 100;
|
||||
|
||||
/** @var int 最大查询数量 */
|
||||
private int $_max = 0;
|
||||
/** @var int 最大查询数量 */
|
||||
private int $_max = 0;
|
||||
|
||||
/** @var int 当前已查询数量 */
|
||||
private int $_length = 0;
|
||||
/** @var int 当前已查询数量 */
|
||||
private int $_length = 0;
|
||||
|
||||
/** @var Closure */
|
||||
private Closure $_callback;
|
||||
/** @var Closure */
|
||||
private Closure $_callback;
|
||||
|
||||
|
||||
/**
|
||||
* PaginationIteration constructor.
|
||||
* @param ActiveQuery $activeQuery
|
||||
* @param array $config
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(ActiveQuery $activeQuery, array $config = [])
|
||||
{
|
||||
parent::__construct();
|
||||
$this->activeQuery = $activeQuery;
|
||||
}
|
||||
/**
|
||||
* PaginationIteration constructor.
|
||||
* @param ActiveQuery $activeQuery
|
||||
* @param array $config
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(ActiveQuery $activeQuery, array $config = [])
|
||||
{
|
||||
parent::__construct();
|
||||
$this->activeQuery = $activeQuery;
|
||||
}
|
||||
|
||||
|
||||
public function clean()
|
||||
{
|
||||
unset($this->activeQuery, $this->_callback, $this->_group);
|
||||
$this->_offset = 0;
|
||||
$this->_limit = 100;
|
||||
$this->_max = 0;
|
||||
$this->_length = 0;;
|
||||
}
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function clean(): void
|
||||
{
|
||||
unset($this->activeQuery, $this->_callback, $this->_group);
|
||||
$this->_offset = 0;
|
||||
$this->_limit = 100;
|
||||
$this->_max = 0;
|
||||
$this->_length = 0;;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* recover class by clone
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->clean();
|
||||
}
|
||||
/**
|
||||
* recover class by clone
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->clean();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array|Closure $callback
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setCallback(array|Closure $callback)
|
||||
{
|
||||
if (!is_callable($callback, true)) {
|
||||
throw new Exception('非法回调函数~');
|
||||
}
|
||||
$this->_callback = $callback;
|
||||
}
|
||||
/**
|
||||
* @param array|Closure $callback
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setCallback(array|Closure $callback)
|
||||
{
|
||||
if (!is_callable($callback, true)) {
|
||||
throw new Exception('非法回调函数~');
|
||||
}
|
||||
$this->_callback = $callback;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $number
|
||||
* @return Pagination
|
||||
*/
|
||||
public function setOffset(int $number): static
|
||||
{
|
||||
if ($number < 0) {
|
||||
$number = 0;
|
||||
}
|
||||
$this->_offset = $number;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @param int $number
|
||||
* @return Pagination
|
||||
*/
|
||||
public function setOffset(int $number): static
|
||||
{
|
||||
if ($number < 0) {
|
||||
$number = 0;
|
||||
}
|
||||
$this->_offset = $number;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $number
|
||||
* @return Pagination
|
||||
*/
|
||||
public function setLimit(int $number): static
|
||||
{
|
||||
if ($number < 1) {
|
||||
$number = 100;
|
||||
} else if ($number > 5000) {
|
||||
$number = 5000;
|
||||
}
|
||||
$this->_limit = $number;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @param int $number
|
||||
* @return Pagination
|
||||
*/
|
||||
public function setLimit(int $number): static
|
||||
{
|
||||
if ($number < 1) {
|
||||
$number = 100;
|
||||
} else if ($number > 5000) {
|
||||
$number = 5000;
|
||||
}
|
||||
$this->_limit = $number;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $number
|
||||
* @return Pagination
|
||||
*/
|
||||
public function setMax(int $number): static
|
||||
{
|
||||
if ($number < 0) {
|
||||
return $this;
|
||||
}
|
||||
$this->_max = $number;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @param int $number
|
||||
* @return Pagination
|
||||
*/
|
||||
public function setMax(int $number): static
|
||||
{
|
||||
if ($number < 0) {
|
||||
return $this;
|
||||
}
|
||||
$this->_max = $number;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $param
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function plunk(array $param = []): void
|
||||
{
|
||||
$this->loop($param);
|
||||
}
|
||||
/**
|
||||
* @param array $param
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function plunk(array $param = []): void
|
||||
{
|
||||
$this->loop($param);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 轮训
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function loop($param): array
|
||||
{
|
||||
if ($this->_max > 0 && $this->_length >= $this->_max) {
|
||||
return $this->output();
|
||||
}
|
||||
[$length, $data] = $this->get();
|
||||
try {
|
||||
call_user_func($this->_callback, $data, $param);
|
||||
} catch (\Throwable $exception) {
|
||||
error($exception);
|
||||
} finally {
|
||||
$data = null;
|
||||
}
|
||||
if ($length < $this->_limit) {
|
||||
return $this->output();
|
||||
}
|
||||
return $this->loop($param);
|
||||
}
|
||||
/**
|
||||
* 轮训
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function loop($param): array
|
||||
{
|
||||
if ($this->_max > 0 && $this->_length >= $this->_max) {
|
||||
return $this->output();
|
||||
}
|
||||
[$length, $data] = $this->get();
|
||||
try {
|
||||
call_user_func($this->_callback, $data, $param);
|
||||
} catch (\Throwable $exception) {
|
||||
error($exception);
|
||||
} finally {
|
||||
$data = null;
|
||||
}
|
||||
if ($length < $this->_limit) {
|
||||
return $this->output();
|
||||
}
|
||||
return $this->loop($param);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function output(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function output(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $param
|
||||
* @throws Exception
|
||||
*/
|
||||
private function executed($data, $param): void
|
||||
{
|
||||
try {
|
||||
call_user_func($this->_callback, $data, $param);
|
||||
} catch (\Throwable $exception) {
|
||||
error($exception);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param $data
|
||||
* @param $param
|
||||
* @throws Exception
|
||||
*/
|
||||
private function executed($data, $param): void
|
||||
{
|
||||
try {
|
||||
call_user_func($this->_callback, $data, $param);
|
||||
} catch (\Throwable $exception) {
|
||||
error($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array|Collection
|
||||
*/
|
||||
private function get(): Collection|array
|
||||
{
|
||||
if ($this->_max > 0 && $this->_length + $this->_limit > $this->_max) {
|
||||
$this->_limit = $this->_length + $this->_limit - $this->_max;
|
||||
}
|
||||
$data = $this->activeQuery->offset($this->_offset)->limit($this->_limit)->get();
|
||||
$this->_offset += $this->_limit;
|
||||
/**
|
||||
* @return array|Collection
|
||||
* @throws Exception
|
||||
*/
|
||||
private function get(): Collection|array
|
||||
{
|
||||
if ($this->_max > 0 && $this->_length + $this->_limit > $this->_max) {
|
||||
$this->_limit = $this->_length + $this->_limit - $this->_max;
|
||||
}
|
||||
$data = $this->activeQuery->offset($this->_offset)->limit($this->_limit)->get();
|
||||
$this->_offset += $this->_limit;
|
||||
|
||||
if (is_array($data)) {
|
||||
$size = count($data);
|
||||
} else {
|
||||
$size = $data->size();
|
||||
}
|
||||
$this->_length += $size;
|
||||
return [$size, $data];
|
||||
}
|
||||
if (is_array($data)) {
|
||||
$size = count($data);
|
||||
} else {
|
||||
$size = $data->size();
|
||||
}
|
||||
$this->_length += $size;
|
||||
return [$size, $data];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-2
@@ -105,9 +105,8 @@ class SqlBuilder extends Component
|
||||
private function __updateBuilder(array $string): string|bool
|
||||
{
|
||||
if (empty($string)) {
|
||||
return \Kiri::getLogger()->addError('None data update.');
|
||||
return \Kiri::getLogger()->failure('None data update.');
|
||||
}
|
||||
|
||||
return 'UPDATE ' . $this->query->from . ' SET ' . implode(',', $string) . $this->_prefix();
|
||||
}
|
||||
|
||||
|
||||
+2
-12
@@ -112,23 +112,13 @@ trait Builder
|
||||
/**
|
||||
* @param array $where
|
||||
* @return string
|
||||
* @throws NotFindClassException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
*/
|
||||
private function where(array $where): string
|
||||
{
|
||||
if (count($where) < 1) {
|
||||
return '';
|
||||
}
|
||||
$_tmp = [];
|
||||
foreach ($where as $key => $value) {
|
||||
$_tmp[] = $this->resolveCondition($key, $value, $_tmp);
|
||||
}
|
||||
if (count($_tmp) > 0) {
|
||||
return implode(' AND ', $_tmp);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
return implode(' AND ', $where);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+761
-872
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -54,8 +54,8 @@ class When
|
||||
/**
|
||||
* @param string $alias
|
||||
*/
|
||||
public function else(string $alias)
|
||||
{
|
||||
public function else(string $alias): void
|
||||
{
|
||||
$this->else = $alias;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user