diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index e351b78f..871b8627 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -13,7 +13,7 @@ namespace Database\Base; use HttpServer\Http\Context; use ReflectionException; use Snowflake\Abstracts\Component; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use Database\ActiveQuery; use Database\ActiveRecord; use Database\Connection; diff --git a/Database/Mysql/Columns.php b/Database/Mysql/Columns.php index d1387ef8..0cc8029a 100644 --- a/Database/Mysql/Columns.php +++ b/Database/Mysql/Columns.php @@ -15,7 +15,7 @@ namespace Database\Mysql; use Snowflake\Abstracts\Component; use Database\Connection; use Exception; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; /** * Class Columns @@ -115,7 +115,7 @@ class Columns extends Component if ($this->isInt($format)) { return (int)$val; } else if ($this->isJson($format)) { - return JSON::decode($val, true); + return Json::decode($val, true); } else if ($this->isFloat($format)) { return (float)$val; } else { @@ -151,7 +151,7 @@ class Columns extends Component if ($this->isInt($format)) { return (int)$val; } else if ($this->isJson($format)) { - return JSON::encode($val); + return Json::encode($val); } else if ($this->isFloat($format)) { return (float)$val; } else { diff --git a/Database/Orm/Condition.php b/Database/Orm/Condition.php index c3e949ff..693f5620 100644 --- a/Database/Orm/Condition.php +++ b/Database/Orm/Condition.php @@ -5,7 +5,7 @@ namespace Database\Orm; use ReflectionException; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use Snowflake\Core\Str; use Snowflake\Exception\NotFindClassException; use Snowflake\Snowflake; @@ -205,7 +205,7 @@ trait Condition if (is_numeric($value)) { return $value; } else { - if (!is_null(JSON::decode($value))) { + if (!is_null(Json::decode($value))) { return $value; } return '\'' . Str::encode($value) . '\''; diff --git a/HttpServer/Client/ClientAbstracts.php b/HttpServer/Client/ClientAbstracts.php index 5ae3ab75..b8644195 100644 --- a/HttpServer/Client/ClientAbstracts.php +++ b/HttpServer/Client/ClientAbstracts.php @@ -9,7 +9,7 @@ use Exception; use Snowflake\Abstracts\Component; use Snowflake\Core\Help; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use Swoole\Coroutine\System; diff --git a/HttpServer/Client/Http2.php b/HttpServer/Client/Http2.php index d4c119f3..e93afcfa 100644 --- a/HttpServer/Client/Http2.php +++ b/HttpServer/Client/Http2.php @@ -8,7 +8,7 @@ use Exception; use HttpServer\Http\Context; use Snowflake\Abstracts\Component; use Snowflake\Core\Help; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use Swoole\Http2\Request; use Swoole\Coroutine\Http2\Client as H2Client; @@ -107,7 +107,7 @@ class Http2 extends Component 'accept-encoding' => 'gzip' ]; if (!is_string($params)) { - $params = JSON::encode($params); + $params = Json::encode($params); } Context::setContext($domain . $path, $req); } diff --git a/HttpServer/Events/OnRequest.php b/HttpServer/Events/OnRequest.php index f1366aca..c53197f7 100644 --- a/HttpServer/Events/OnRequest.php +++ b/HttpServer/Events/OnRequest.php @@ -10,7 +10,7 @@ use HttpServer\Exception\ExitException; use HttpServer\Http\Request as HRequest; use HttpServer\Http\Response as HResponse; use ReflectionException; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use Snowflake\Event; use Snowflake\Exception\ComponentException; use Snowflake\Exception\NotFindClassException; @@ -68,7 +68,7 @@ class OnRequest extends Callback $request = get_object_vars($request); - $logger->write(JSON::encode($request), 'request'); + $logger->write(Json::encode($request), 'request'); } } diff --git a/HttpServer/Events/Utility/DataResolve.php b/HttpServer/Events/Utility/DataResolve.php index 064ad094..db275759 100644 --- a/HttpServer/Events/Utility/DataResolve.php +++ b/HttpServer/Events/Utility/DataResolve.php @@ -7,7 +7,7 @@ namespace HttpServer\Events\Utility; use Closure; use Exception; use ReflectionException; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use Snowflake\Exception\NotFindClassException; use Snowflake\Snowflake; @@ -26,7 +26,7 @@ class DataResolve public static function pack($unpack, $data) { if (empty($unpack)) { - $params = JSON::encode($data); + $params = Json::encode($data); } else { $params = self::callbackResolve($unpack, null, null, $data); } @@ -49,7 +49,7 @@ class DataResolve public static function unpack($unpack, $address, $port, $data) { if (empty($unpack)) { - $params = JSON::decode($data); + $params = Json::decode($data); } else { $params = self::callbackResolve($unpack, $address, $port, $data); } diff --git a/HttpServer/Http/Formatter/HtmlFormatter.php b/HttpServer/Http/Formatter/HtmlFormatter.php index 200145ca..324aa790 100644 --- a/HttpServer/Http/Formatter/HtmlFormatter.php +++ b/HttpServer/Http/Formatter/HtmlFormatter.php @@ -11,7 +11,7 @@ namespace HttpServer\Http\Formatter; use Exception; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use HttpServer\Application; use Swoole\Http\Response; use HttpServer\IInterface\IFormatter; @@ -38,7 +38,7 @@ class HtmlFormatter extends Application implements IFormatter public function send($context): static { if (!is_string($context)) { - $context = JSON::encode($context); + $context = Json::encode($context); } $this->data = $context; return $this; diff --git a/HttpServer/Http/HttpParams.php b/HttpServer/Http/HttpParams.php index 89a94cb2..c91089bb 100644 --- a/HttpServer/Http/HttpParams.php +++ b/HttpServer/Http/HttpParams.php @@ -12,7 +12,7 @@ namespace HttpServer\Http; use Exception; use HttpServer\Exception\RequestException; use Snowflake\Core\Help; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use Snowflake\Snowflake; /** @@ -130,11 +130,11 @@ class HttpParams { $data = $this->array($name); if (empty($data)) { - return JSON::encode([]); + return Json::encode([]); } else if (!is_array($data)) { - return JSON::encode([]); + return Json::encode([]); } - return JSON::encode($data); + return Json::encode($data); } /** diff --git a/HttpServer/Http/Request.php b/HttpServer/Http/Request.php index 1c06f2a4..b40f39ee 100644 --- a/HttpServer/Http/Request.php +++ b/HttpServer/Http/Request.php @@ -8,7 +8,7 @@ use HttpServer\Application; use HttpServer\IInterface\AuthIdentity; use ReflectionException; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use Snowflake\Exception\ComponentException; use Snowflake\Exception\NotFindClassException; use Snowflake\Snowflake; @@ -415,7 +415,7 @@ class Request extends Application */ public function isNotFound(): bool { - return JSON::to(404, 'Page ' . $this->getUri() . ' not found.'); + return Json::to(404, 'Page ' . $this->getUri() . ' not found.'); } diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index afc91050..00edbba0 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -11,7 +11,7 @@ use Exception; use HttpServer\Application; use ReflectionException; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use Snowflake\Exception\NotFindClassException; use Snowflake\Snowflake; use Swoole\Coroutine; @@ -440,7 +440,7 @@ class Node extends Application { $this->restructure(); if (empty($this->callback)) { - return JSON::to(404, $node->_error ?? 'Page not found.'); + return Json::to(404, $node->_error ?? 'Page not found.'); } $requestParams = func_get_args(); if (func_num_args() > 0) { diff --git a/HttpServer/config.php b/HttpServer/config.php index db07c886..5ac7fb81 100644 --- a/HttpServer/config.php +++ b/HttpServer/config.php @@ -37,10 +37,10 @@ return [ ], 'message' => [ 'pack' => function ($data) { - return \Snowflake\Core\JSON::encode($data); + return \Snowflake\Core\Json::encode($data); }, 'unpack' => function ($data) { - return \Snowflake\Core\JSON::decode($data); + return \Snowflake\Core\Json::decode($data); }, ], 'events' => [ @@ -57,10 +57,10 @@ return [ ], 'message' => [ 'pack' => function ($data) { - return \Snowflake\Core\JSON::encode($data); + return \Snowflake\Core\Json::encode($data); }, 'unpack' => function ($data) { - return \Snowflake\Core\JSON::decode($data); + return \Snowflake\Core\Json::decode($data); }, ], 'events' => [ diff --git a/System/Abstracts/BaseGoto.php b/System/Abstracts/BaseGoto.php index 979a405b..d45eda5b 100644 --- a/System/Abstracts/BaseGoto.php +++ b/System/Abstracts/BaseGoto.php @@ -6,7 +6,7 @@ namespace Snowflake\Abstracts; use Exception; use HttpServer\Exception\ExitException; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; /** * Class BaseGoto @@ -23,7 +23,7 @@ class BaseGoto extends Component */ public function end(string $message, $statusCode = 200): mixed { - throw new ExitException(JSON::to(12350, $message), $statusCode); + throw new ExitException(Json::to(12350, $message), $statusCode); } } diff --git a/System/Core/Help.php b/System/Core/Help.php index bb0a040f..fb2a805d 100644 --- a/System/Core/Help.php +++ b/System/Core/Help.php @@ -93,7 +93,7 @@ class Help if (!is_string($parameter)) { $parameter = ArrayAccess::toArray($parameter); if (is_array($parameter)) { - $parameter = JSON::encode($parameter); + $parameter = Json::encode($parameter); } } return $parameter; diff --git a/System/Core/JSON.php b/System/Core/Json.php similarity index 99% rename from System/Core/JSON.php rename to System/Core/Json.php index 987144d9..040f6c05 100644 --- a/System/Core/JSON.php +++ b/System/Core/Json.php @@ -16,7 +16,7 @@ use Exception; * Class JSON * @package Snowflake\Snowflake\Core */ -class JSON +class Json { /** diff --git a/System/Error/ErrorHandler.php b/System/Error/ErrorHandler.php index e2fd3eb6..d40e83c4 100644 --- a/System/Error/ErrorHandler.php +++ b/System/Error/ErrorHandler.php @@ -12,7 +12,7 @@ namespace Snowflake\Error; use Exception; use HttpServer\IInterface\IFormatter; use Snowflake\Abstracts\Component; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use Snowflake\Event; use Snowflake\Snowflake; @@ -98,7 +98,7 @@ class ErrorHandler extends Component implements ErrorInterface $error[0] = 500; } - $data = JSON::to(500, $error[1], $path); + $data = Json::to(500, $error[1], $path); logger()->error($data, 'error'); @@ -120,7 +120,7 @@ class ErrorHandler extends Component implements ErrorInterface { $path = ['file' => $file, 'line' => $line]; - $data = JSON::to($code, $this->category . ': ' . $message, $path); + $data = Json::to($code, $this->category . ': ' . $message, $path); logger()->trance($data, $this->category); diff --git a/System/Error/Logger.php b/System/Error/Logger.php index 335b0069..eb6e8285 100644 --- a/System/Error/Logger.php +++ b/System/Error/Logger.php @@ -12,7 +12,7 @@ namespace Snowflake\Error; use Exception; use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Config; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use Snowflake\Snowflake; use Swoole\Process; use Throwable; @@ -258,7 +258,7 @@ class Logger extends Component $logger->write($string . $exception->getTraceAsString(), 'trace'); $logger->write(jTraceEx($exception), 'exception'); - return JSON::to($code, $errorInfo['message'], [ + return Json::to($code, $errorInfo['message'], [ 'file' => $exception->getFile(), 'line' => $exception->getLine() ]); diff --git a/System/Snowflake.php b/System/Snowflake.php index 35c7351c..cd19b3fc 100644 --- a/System/Snowflake.php +++ b/System/Snowflake.php @@ -10,7 +10,7 @@ use HttpServer\IInterface\Task; use ReflectionException; use Snowflake\Abstracts\Config; -use Snowflake\Core\JSON; +use Snowflake\Core\Json; use Snowflake\Di\Container; use Snowflake\Exception\ComponentException; use Snowflake\Exception\NotFindClassException; @@ -257,7 +257,7 @@ class Snowflake return false; } if (!is_string($data)) { - $data = JSON::encode($data); + $data = Json::encode($data); } return $server->push($fd, $data); }