This commit is contained in:
2020-12-24 11:12:23 +08:00
parent 5a7c7176dc
commit f18031c2c0
18 changed files with 39 additions and 39 deletions
+1 -1
View File
@@ -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;
+3 -3
View File
@@ -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 {
+2 -2
View File
@@ -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) . '\'';
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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);
}
+2 -2
View File
@@ -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');
}
}
+3 -3
View File
@@ -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);
}
+2 -2
View File
@@ -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;
+4 -4
View File
@@ -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);
}
/**
+2 -2
View File
@@ -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.');
}
+2 -2
View File
@@ -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) {
+4 -4
View File
@@ -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' => [
+2 -2
View File
@@ -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);
}
}
+1 -1
View File
@@ -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;
@@ -16,7 +16,7 @@ use Exception;
* Class JSON
* @package Snowflake\Snowflake\Core
*/
class JSON
class Json
{
/**
+3 -3
View File
@@ -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);
+2 -2
View File
@@ -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()
]);
+2 -2
View File
@@ -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);
}