This commit is contained in:
2020-12-17 14:12:44 +08:00
parent 9516baef92
commit 33e5416dda
38 changed files with 100 additions and 101 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ namespace Database\Base;
use ArrayIterator; use ArrayIterator;
use Database\ActiveQuery; use Database\ActiveQuery;
use JetBrains\PhpStorm\Pure;
use ReflectionException; use ReflectionException;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
use Database\ActiveRecord; use Database\ActiveRecord;
@@ -55,7 +55,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
/** /**
* @return int * @return int
*/ */
#[Pure] public function getLength(): int public function getLength(): int
{ {
return count($this->_item); return count($this->_item);
} }
+4 -5
View File
@@ -11,7 +11,6 @@ namespace Database;
use Database\Base\AbstractCollection; use Database\Base\AbstractCollection;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
/** /**
* Class Collection * Class Collection
@@ -80,7 +79,7 @@ class Collection extends AbstractCollection
* *
* @return array * @return array
*/ */
#[Pure] public function slice($start = 0, $length = 20): array public function slice($start = 0, $length = 20): array
{ {
if (empty($this->_item) || !is_array($this->_item)) { if (empty($this->_item) || !is_array($this->_item)) {
return []; return [];
@@ -128,7 +127,7 @@ class Collection extends AbstractCollection
/** /**
* @return ActiveRecord|array * @return ActiveRecord|array
*/ */
#[Pure] public function current(): ActiveRecord|array public function current(): ActiveRecord|array
{ {
return current($this->_item); return current($this->_item);
} }
@@ -136,7 +135,7 @@ class Collection extends AbstractCollection
/** /**
* @return int * @return int
*/ */
#[Pure] public function size(): int public function size(): int
{ {
return (int)count($this->_item); return (int)count($this->_item);
} }
@@ -240,7 +239,7 @@ class Collection extends AbstractCollection
/** /**
* @return bool * @return bool
*/ */
#[Pure] public function isEmpty(): bool public function isEmpty(): bool
{ {
return $this->size() < 1; return $this->size() < 1;
} }
+2 -2
View File
@@ -7,7 +7,7 @@ namespace Database\Condition;
use Database\ActiveQuery; use Database\ActiveQuery;
use Database\Base\ConditionClassMap; use Database\Base\ConditionClassMap;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Core\Str; use Snowflake\Core\Str;
use Snowflake\Snowflake; use Snowflake\Snowflake;
@@ -59,7 +59,7 @@ class ArrayCondition extends Condition
* @param $value * @param $value
* @return bool * @return bool
*/ */
#[Pure] private function isMath($value): bool private function isMath($value): bool
{ {
return isset($value[0]) && in_array($value[0], $this->math); return isset($value[0]) && in_array($value[0], $this->math);
} }
+2 -2
View File
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Database\Condition; namespace Database\Condition;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\BaseObject; use Snowflake\Abstracts\BaseObject;
use Snowflake\Core\Str; use Snowflake\Core\Str;
@@ -127,7 +127,7 @@ abstract class Condition extends BaseObject
* @param string $oprea * @param string $oprea
* @return string * @return string
*/ */
#[Pure] public function typeBuilder($column, $value = null, $oprea = '='): string public function typeBuilder($column, $value = null, $oprea = '='): string
{ {
if (is_numeric($value)) { if (is_numeric($value)) {
if ($value != (int)$value) { if ($value != (int)$value) {
+2 -2
View File
@@ -11,7 +11,7 @@ declare(strict_types=1);
namespace Database; namespace Database;
use JetBrains\PhpStorm\Pure;
use ReflectionException; use ReflectionException;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
use Database\Mysql\Schema; use Database\Mysql\Schema;
@@ -152,7 +152,7 @@ class Connection extends Component
* @param $sql * @param $sql
* @return bool * @return bool
*/ */
#[Pure] public function isWrite($sql): bool public function isWrite($sql): bool
{ {
if (empty($sql)) return false; if (empty($sql)) return false;
+6 -6
View File
@@ -11,7 +11,7 @@ declare(strict_types=1);
namespace Database\Mysql; namespace Database\Mysql;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
use Database\Connection; use Database\Connection;
use Exception; use Exception;
@@ -163,7 +163,7 @@ class Columns extends Component
* @param $format * @param $format
* @return bool * @return bool
*/ */
#[Pure] public function isInt($format): bool public function isInt($format): bool
{ {
return in_array($format, ['int', 'bigint', 'tinyint', 'smallint', 'mediumint']); return in_array($format, ['int', 'bigint', 'tinyint', 'smallint', 'mediumint']);
} }
@@ -172,7 +172,7 @@ class Columns extends Component
* @param $format * @param $format
* @return bool * @return bool
*/ */
#[Pure] public function isFloat($format): bool public function isFloat($format): bool
{ {
return in_array($format, ['float', 'double', 'decimal']); return in_array($format, ['float', 'double', 'decimal']);
} }
@@ -181,7 +181,7 @@ class Columns extends Component
* @param $format * @param $format
* @return bool * @return bool
*/ */
#[Pure] public function isJson($format): bool public function isJson($format): bool
{ {
return in_array($format, ['json']); return in_array($format, ['json']);
} }
@@ -190,7 +190,7 @@ class Columns extends Component
* @param $format * @param $format
* @return bool * @return bool
*/ */
#[Pure] public function isString($format): bool public function isString($format): bool
{ {
return in_array($format, ['varchar', 'char', 'text', 'longtext', 'tinytext', 'mediumtext']); return in_array($format, ['varchar', 'char', 'text', 'longtext', 'tinytext', 'mediumtext']);
} }
@@ -232,7 +232,7 @@ class Columns extends Component
* *
* @throws Exception * @throws Exception
*/ */
#[Pure] public function getFirstPrimary(): array|string|null public function getFirstPrimary(): array|string|null
{ {
if (isset($this->_auto_increment[$this->table])) { if (isset($this->_auto_increment[$this->table])) {
return $this->_auto_increment[$this->table]; return $this->_auto_increment[$this->table];
+2 -2
View File
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Database\Orm; namespace Database\Orm;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\BaseObject; use Snowflake\Abstracts\BaseObject;
use Database\ActiveQuery; use Database\ActiveQuery;
use Exception; use Exception;
@@ -206,7 +206,7 @@ class Change extends BaseObject
* @return string * @return string
* 构建SQL语句 * 构建SQL语句
*/ */
#[Pure] private function inserts($table, $fields, $data): string private function inserts($table, $fields, $data): string
{ {
$query = [ $query = [
'INSERT IGNORE INTO', '%s', '(%s)', 'VALUES %s' 'INSERT IGNORE INTO', '%s', '(%s)', 'VALUES %s'
+2 -2
View File
@@ -3,7 +3,7 @@ declare(strict_types=1);
namespace Database\Orm; namespace Database\Orm;
use JetBrains\PhpStorm\Pure;
use ReflectionException; use ReflectionException;
use Snowflake\Core\JSON; use Snowflake\Core\JSON;
use Snowflake\Core\Str; use Snowflake\Core\Str;
@@ -61,7 +61,7 @@ trait Condition
* @param $join * @param $join
* @return string * @return string
*/ */
#[Pure] private function builderJoin($join): string private function builderJoin($join): string
{ {
if (!empty($join)) { if (!empty($join)) {
return ' ' . implode(' ', $join); return ' ' . implode(' ', $join);
+2 -2
View File
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Database\Orm; namespace Database\Orm;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\BaseObject; use Snowflake\Abstracts\BaseObject;
use Database\ActiveQuery; use Database\ActiveQuery;
use Database\Sql; use Database\Sql;
@@ -79,7 +79,7 @@ class Select extends BaseObject
* @param bool $isCount * @param bool $isCount
* @return string * @return string
*/ */
#[Pure] private function builderSelect($select = NULL, $isCount = false): string private function builderSelect($select = NULL, $isCount = false): string
{ {
if ($isCount === true) { if ($isCount === true) {
return 'SELECT COUNT(*)'; return 'SELECT COUNT(*)';
+2 -2
View File
@@ -13,7 +13,7 @@ use Database\Connection;
use Database\Db; use Database\Db;
use Exception; use Exception;
use JetBrains\PhpStorm\ArrayShape; use JetBrains\PhpStorm\ArrayShape;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\Input; use Snowflake\Abstracts\Input;
use Snowflake\Exception\ComponentException; use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException; use Snowflake\Exception\ConfigException;
@@ -304,7 +304,7 @@ class Gii
* @return string * @return string
* 暂时不知道干嘛用的 * 暂时不知道干嘛用的
*/ */
#[Pure] private function createSetFunc($field, $comment): string private function createSetFunc($field, $comment): string
{ {
return ' return '
' . str_pad('\'' . $field . '\'', 20, ' ', STR_PAD_RIGHT) . '=> \'' . (empty($comment) ? ucfirst($field) : $comment) . '\','; ' . str_pad('\'' . $field . '\'', 20, ' ', STR_PAD_RIGHT) . '=> \'' . (empty($comment) ? ucfirst($field) : $comment) . '\',';
+2 -2
View File
@@ -7,7 +7,7 @@ namespace Gii;
use Database\Connection; use Database\Connection;
use JetBrains\PhpStorm\ArrayShape; use JetBrains\PhpStorm\ArrayShape;
use JetBrains\PhpStorm\Pure;
use ReflectionClass; use ReflectionClass;
use Snowflake\Abstracts\Input; use Snowflake\Abstracts\Input;
@@ -219,7 +219,7 @@ abstract class GiiBase
* @param $val * @param $val
* @return string * @return string
*/ */
#[Pure] protected function checkIsRequired($val): string protected function checkIsRequired($val): string
{ {
return strtolower($val['Null']) == 'no' && $val['Default'] === NULL ? 'true' : 'false'; return strtolower($val['Null']) == 'no' && $val['Default'] === NULL ? 'true' : 'false';
} }
+2 -2
View File
@@ -5,7 +5,7 @@ namespace HttpServer;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\Input; use Snowflake\Abstracts\Input;
use Snowflake\Exception\ComponentException; use Snowflake\Exception\ComponentException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
@@ -111,7 +111,7 @@ trait Action
/** /**
* @return string * @return string
*/ */
#[Pure] private function getWorkerPath(): string private function getWorkerPath(): string
{ {
return "glob://" . ltrim(APP_PATH, '/') . '/storage/worker/*.sock'; return "glob://" . ltrim(APP_PATH, '/') . '/storage/worker/*.sock';
} }
+2 -2
View File
@@ -10,7 +10,7 @@ declare(strict_types=1);
namespace HttpServer\Client; namespace HttpServer\Client;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
use Swoole\Coroutine\Http\Client as SClient; use Swoole\Coroutine\Http\Client as SClient;
/** /**
@@ -112,7 +112,7 @@ class Client extends ClientAbstracts
/** /**
* @return array * @return array
*/ */
#[Pure] private function settings(): array private function settings(): array
{ {
$sslCert = $this->getSslCertFile(); $sslCert = $this->getSslCertFile();
$sslKey = $this->getSslKeyFile(); $sslKey = $this->getSslKeyFile();
+9 -9
View File
@@ -6,7 +6,7 @@ namespace HttpServer\Client;
use Closure; use Closure;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
use Snowflake\Core\Help; use Snowflake\Core\Help;
use Snowflake\Core\JSON; use Snowflake\Core\JSON;
@@ -58,7 +58,7 @@ abstract class ClientAbstracts extends Component implements IClient
/** /**
* @return static * @return static
*/ */
#[Pure] public static function NewRequest(): static public static function NewRequest(): static
{ {
return new static(); return new static();
} }
@@ -415,7 +415,7 @@ abstract class ClientAbstracts extends Component implements IClient
/** /**
* @return int * @return int
*/ */
#[Pure] public function getPort(): int public function getPort(): int
{ {
if ($this->isSSL()) { if ($this->isSSL()) {
return 443; return 443;
@@ -512,7 +512,7 @@ abstract class ClientAbstracts extends Component implements IClient
* @param $url * @param $url
* @return bool * @return bool
*/ */
#[Pure] protected function isHttp($url): bool protected function isHttp($url): bool
{ {
return str_starts_with($url, 'http://'); return str_starts_with($url, 'http://');
} }
@@ -521,7 +521,7 @@ abstract class ClientAbstracts extends Component implements IClient
* @param $url * @param $url
* @return bool * @return bool
*/ */
#[Pure] protected function isHttps($url): bool protected function isHttps($url): bool
{ {
return str_starts_with($url, 'https://'); return str_starts_with($url, 'https://');
} }
@@ -673,7 +673,7 @@ abstract class ClientAbstracts extends Component implements IClient
* @return bool * @return bool
* check isPost Request * check isPost Request
*/ */
#[Pure] public function isPost(): bool public function isPost(): bool
{ {
return strtolower($this->method) === self::POST; return strtolower($this->method) === self::POST;
} }
@@ -684,7 +684,7 @@ abstract class ClientAbstracts extends Component implements IClient
* *
* check isGet Request * check isGet Request
*/ */
#[Pure] public function isGet(): bool public function isGet(): bool
{ {
return strtolower($this->method) === self::GET; return strtolower($this->method) === self::GET;
} }
@@ -695,7 +695,7 @@ abstract class ClientAbstracts extends Component implements IClient
* @return array|string * @return array|string
* 将请求参数进行编码 * 将请求参数进行编码
*/ */
#[Pure] protected function paramEncode($arr): array|string protected function paramEncode($arr): array|string
{ {
if (!is_array($arr)) { if (!is_array($arr)) {
return $arr; return $arr;
@@ -761,7 +761,7 @@ abstract class ClientAbstracts extends Component implements IClient
* @param $params * @param $params
* @return string * @return string
*/ */
#[Pure] protected function joinGetParams($path, $params): string protected function joinGetParams($path, $params): string
{ {
if (empty($params)) { if (empty($params)) {
return $path; return $path;
+2 -2
View File
@@ -5,7 +5,7 @@ namespace HttpServer\Client;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
/** /**
* Class Curl * Class Curl
@@ -209,7 +209,7 @@ class Curl extends ClientAbstracts
/** /**
* @return array * @return array
*/ */
#[Pure] private function parseHeaderMat(): array private function parseHeaderMat(): array
{ {
$headers = []; $headers = [];
foreach ($this->getHeader() as $key => $val) { foreach ($this->getHeader() as $key => $val) {
+2 -2
View File
@@ -4,7 +4,7 @@
namespace HttpServer\Client; namespace HttpServer\Client;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
use Snowflake\Snowflake; use Snowflake\Snowflake;
use Swoole\Coroutine; use Swoole\Coroutine;
@@ -29,7 +29,7 @@ class HttpClient extends Component
/** /**
* @return Http2 * @return Http2
*/ */
#[Pure] public static function http2(): Http2 public static function http2(): Http2
{ {
return Snowflake::app()->http2; return Snowflake::app()->http2;
} }
+2 -2
View File
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace HttpServer\Client; namespace HttpServer\Client;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
/** /**
* Class Result * Class Result
@@ -143,7 +143,7 @@ class Result
/** /**
* @return bool * @return bool
*/ */
#[Pure] public function httpIsOk(): bool public function httpIsOk(): bool
{ {
return in_array($this->httpStatus, [100, 101, 200, 201, 202, 203, 204, 205, 206]); return in_array($this->httpStatus, [100, 101, 200, 201, 202, 203, 204, 205, 206]);
} }
+2 -2
View File
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace HttpServer\Exception; namespace HttpServer\Exception;
use JetBrains\PhpStorm\Pure;
use Throwable; use Throwable;
/** /**
@@ -26,7 +26,7 @@ class AuthException extends \Exception
* @param int $code * @param int $code
* @param Throwable|null $previous * @param Throwable|null $previous
*/ */
#[Pure] public function __construct($message = "", $code = 0, Throwable $previous = NULL) public function __construct($message = "", $code = 0, Throwable $previous = NULL)
{ {
parent::__construct($message, 7000, $previous); parent::__construct($message, 7000, $previous);
} }
+2 -2
View File
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace HttpServer\Exception; namespace HttpServer\Exception;
use JetBrains\PhpStorm\Pure;
use Throwable; use Throwable;
/** /**
@@ -20,7 +20,7 @@ class ExitException extends \Exception
* @param int $code * @param int $code
* @param Throwable|null $previous * @param Throwable|null $previous
*/ */
#[Pure] public function __construct($message = "", $code = 0, Throwable $previous = null) public function __construct($message = "", $code = 0, Throwable $previous = null)
{ {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }
+4 -4
View File
@@ -6,7 +6,7 @@ namespace HttpServer\Http;
use Exception; use Exception;
use HttpServer\Application; use HttpServer\Application;
use HttpServer\IInterface\AuthIdentity; use HttpServer\IInterface\AuthIdentity;
use JetBrains\PhpStorm\Pure;
use ReflectionException; use ReflectionException;
use Snowflake\Core\JSON; use Snowflake\Core\JSON;
use Snowflake\Exception\ComponentException; use Snowflake\Exception\ComponentException;
@@ -186,7 +186,7 @@ class Request extends Application
/** /**
* @return string * @return string
*/ */
#[Pure] public function getCurrent(): string public function getCurrent(): string
{ {
return current($this->explode); return current($this->explode);
} }
@@ -360,7 +360,7 @@ class Request extends Application
/** /**
* @return mixed|null * @return mixed|null
*/ */
#[Pure] public function getIp() public function getIp()
{ {
$headers = $this->headers->getHeaders(); $headers = $this->headers->getHeaders();
if (!empty($headers['x-forwarded-for'])) return $headers['x-forwarded-for']; if (!empty($headers['x-forwarded-for'])) return $headers['x-forwarded-for'];
@@ -372,7 +372,7 @@ class Request extends Application
/** /**
* @return string * @return string
*/ */
#[Pure] public function getRuntime(): string public function getRuntime(): string
{ {
return sprintf('%.5f', microtime(TRUE) - $this->startTime); return sprintf('%.5f', microtime(TRUE) - $this->startTime);
} }
+2 -2
View File
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace HttpServer\Route\Filter; namespace HttpServer\Route\Filter;
use JetBrains\PhpStorm\Pure;
use Throwable; use Throwable;
class FilterException extends \Exception class FilterException extends \Exception
@@ -18,7 +18,7 @@ class FilterException extends \Exception
* @param int $code * @param int $code
* @param Throwable|null $previous * @param Throwable|null $previous
*/ */
#[Pure] public function __construct($message = "", $code = 0, Throwable $previous = null) public function __construct($message = "", $code = 0, Throwable $previous = null)
{ {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }
+4 -4
View File
@@ -9,7 +9,7 @@ use Closure;
use HttpServer\Http\Request; use HttpServer\Http\Request;
use Exception; use Exception;
use HttpServer\Application; use HttpServer\Application;
use JetBrains\PhpStorm\Pure;
use ReflectionException; use ReflectionException;
use Snowflake\Core\JSON; use Snowflake\Core\JSON;
use Snowflake\Exception\NotFindClassException; use Snowflake\Exception\NotFindClassException;
@@ -81,7 +81,7 @@ class Node extends Application
/** /**
* @return bool * @return bool
*/ */
#[Pure] public function hasInterceptor(): bool public function hasInterceptor(): bool
{ {
return count($this->_interceptors) > 0; return count($this->_interceptors) > 0;
} }
@@ -90,7 +90,7 @@ class Node extends Application
/** /**
* @return bool * @return bool
*/ */
#[Pure] public function hasLimits(): bool public function hasLimits(): bool
{ {
return count($this->_limits) > 0; return count($this->_limits) > 0;
} }
@@ -129,7 +129,7 @@ class Node extends Application
/** /**
* @return bool * @return bool
*/ */
#[Pure] public function hasAfter(): bool public function hasAfter(): bool
{ {
return count($this->_after) > 0; return count($this->_after) > 0;
} }
+2 -2
View File
@@ -8,7 +8,7 @@ use Exception;
use HttpServer\Http\Request; use HttpServer\Http\Request;
use HttpServer\IInterface\RouterInterface; use HttpServer\IInterface\RouterInterface;
use HttpServer\Application; use HttpServer\Application;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\Config; use Snowflake\Abstracts\Config;
use Snowflake\Exception\ComponentException; use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException; use Snowflake\Exception\ConfigException;
@@ -109,7 +109,7 @@ class Router extends Application implements RouterInterface
* @param $path * @param $path
* @return string * @return string
*/ */
#[Pure] private function resolve($path): string private function resolve($path): string
{ {
$paths = array_column($this->groupTacks, 'prefix'); $paths = array_column($this->groupTacks, 'prefix');
if (empty($paths)) { if (empty($paths)) {
+2 -2
View File
@@ -16,7 +16,7 @@ use HttpServer\Http\Request;
use HttpServer\Http\Response; use HttpServer\Http\Response;
use HttpServer\Route\Router; use HttpServer\Route\Router;
use HttpServer\Server; use HttpServer\Server;
use JetBrains\PhpStorm\Pure;
use Kafka\Producer; use Kafka\Producer;
use Annotation\Annotation as SAnnotation; use Annotation\Annotation as SAnnotation;
use Snowflake\Cache\Redis; use Snowflake\Cache\Redis;
@@ -139,7 +139,7 @@ abstract class BaseApplication extends Service
* *
* @return bool * @return bool
*/ */
#[Pure] protected function looksLikeSetter(string $line): bool protected function looksLikeSetter(string $line): bool
{ {
return str_contains($line, '='); return str_contains($line, '=');
} }
+2 -2
View File
@@ -10,7 +10,7 @@ declare(strict_types=1);
namespace Snowflake\Abstracts; namespace Snowflake\Abstracts;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Error\Logger; use Snowflake\Error\Logger;
use Snowflake\Snowflake; use Snowflake\Snowflake;
@@ -45,7 +45,7 @@ class BaseObject implements Configure
/** /**
* @return string * @return string
*/ */
#[Pure] public static function className(): string public static function className(): string
{ {
return get_called_class(); return get_called_class();
} }
+2 -2
View File
@@ -11,7 +11,7 @@ namespace Snowflake\Abstracts;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Snowflake; use Snowflake\Snowflake;
/** /**
@@ -50,7 +50,7 @@ class Component extends BaseObject
* @param null $callback * @param null $callback
* @return bool * @return bool
*/ */
#[Pure] public function hasEvent($name, $callback = null): bool public function hasEvent($name, $callback = null): bool
{ {
if (!isset($this->_events[$name])) { if (!isset($this->_events[$name])) {
return false; return false;
+2 -2
View File
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace Snowflake\Abstracts; namespace Snowflake\Abstracts;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Exception\ConfigException; use Snowflake\Exception\ConfigException;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
use Snowflake\Snowflake; use Snowflake\Snowflake;
@@ -94,7 +94,7 @@ class Config extends Component
* @param bool $must_not_null * @param bool $must_not_null
* @return bool * @return bool
*/ */
#[Pure] public static function has($key, $must_not_null = false): bool public static function has($key, $must_not_null = false): bool
{ {
$config = Snowflake::app()->config; $config = Snowflake::app()->config;
if (!isset($config->data[$key])) { if (!isset($config->data[$key])) {
+2 -2
View File
@@ -5,7 +5,7 @@ namespace Snowflake\Abstracts;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
use Swoole\Coroutine; use Swoole\Coroutine;
use Swoole\Coroutine\Channel; use Swoole\Coroutine\Channel;
@@ -57,7 +57,7 @@ abstract class Pool extends Component
* @param false $isMaster * @param false $isMaster
* @return string * @return string
*/ */
#[Pure] public function name($cds, $isMaster = false): string public function name($cds, $isMaster = false): string
{ {
if ($isMaster === true) { if ($isMaster === true) {
return hash('sha256', $cds . 'master'); return hash('sha256', $cds . 'master');
+2 -2
View File
@@ -11,7 +11,7 @@ namespace Snowflake\Cache;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
use Swoole\Coroutine\System; use Swoole\Coroutine\System;
@@ -119,7 +119,7 @@ class File extends Component implements ICache
* @param $key * @param $key
* @return bool * @return bool
*/ */
#[Pure] public function exists($key): bool public function exists($key): bool
{ {
return file_exists($key); return file_exists($key);
} }
+2 -2
View File
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace Snowflake\Core; namespace Snowflake\Core;
use JetBrains\PhpStorm\Pure;
/** /**
* Class DateFormat * Class DateFormat
@@ -96,7 +96,7 @@ class DateFormat
* @param null $endTime * @param null $endTime
* @return string * @return string
*/ */
#[Pure] public static function mtime($startTime, $endTime = null) public static function mtime($startTime, $endTime = null)
{ {
if ($endTime === null) { if ($endTime === null) {
$endTime = microtime(true); $endTime = microtime(true);
+2 -2
View File
@@ -6,7 +6,7 @@ namespace Snowflake\Core;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
/** /**
* Class Help * Class Help
@@ -19,7 +19,7 @@ class Help
* @param array $data * @param array $data
* @return string * @return string
*/ */
#[Pure] public static function toXml(array $data) public static function toXml(array $data)
{ {
$xml = "<xml>"; $xml = "<xml>";
foreach ($data as $key => $val) { foreach ($data as $key => $val) {
+6 -6
View File
@@ -5,7 +5,7 @@ namespace Snowflake\Core;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure;
/** /**
* Class Str * Class Str
@@ -24,7 +24,7 @@ class Str
* @return string * @return string
* 获取随机字符串 * 获取随机字符串
*/ */
#[Pure] public static function rand(int $length = 20): string public static function rand(int $length = 20): string
{ {
$string = ''; $string = '';
if ($length < 1) $length = 20; if ($length < 1) $length = 20;
@@ -42,7 +42,7 @@ class Str
* @return int|string 获取随机数字 * @return int|string 获取随机数字
* 获取随机数字 * 获取随机数字
*/ */
#[Pure] public static function random(int $length = 20): int|string public static function random(int $length = 20): int|string
{ {
$number = ''; $number = '';
$default = str_split(self::NUMBER); $default = str_split(self::NUMBER);
@@ -119,7 +119,7 @@ class Str
* @param string $append * @param string $append
* @return string * @return string
*/ */
#[Pure] public static function cut($string, int $length = 20, $append = '...'): string public static function cut($string, int $length = 20, $append = '...'): string
{ {
if (empty($string)) { if (empty($string)) {
return ''; return '';
@@ -167,7 +167,7 @@ class Str
* @param $type * @param $type
* @return string * @return string
*/ */
#[Pure] public static function filename($file, $type): string public static function filename($file, $type): string
{ {
switch ($type) { switch ($type) {
case 'image/png': case 'image/png':
@@ -218,7 +218,7 @@ class Str
* @param string $string * @param string $string
* @return string * @return string
*/ */
#[Pure] public static function encode(string $string): string public static function encode(string $string): string
{ {
return addslashes($string); return addslashes($string);
} }
+2 -2
View File
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Snowflake\Exception; namespace Snowflake\Exception;
use JetBrains\PhpStorm\Pure;
use Throwable; use Throwable;
/** /**
@@ -21,7 +21,7 @@ class AuthException extends \Exception
* @param int $code * @param int $code
* @param Throwable|null $previous * @param Throwable|null $previous
*/ */
#[Pure] public function __construct($message = "", $code = 0, Throwable $previous = null) public function __construct($message = "", $code = 0, Throwable $previous = null)
{ {
parent::__construct($message, 401, $previous); parent::__construct($message, 401, $previous);
} }
+2 -2
View File
@@ -10,7 +10,7 @@ declare(strict_types=1);
namespace Snowflake\Exception; namespace Snowflake\Exception;
use JetBrains\PhpStorm\Pure;
use Throwable; use Throwable;
/** /**
@@ -27,7 +27,7 @@ class ComponentException extends \Exception
* @param int $code * @param int $code
* @param Throwable|null $previous * @param Throwable|null $previous
*/ */
#[Pure] public function __construct(string $message = "", int $code = 0, Throwable $previous = NULL) public function __construct(string $message = "", int $code = 0, Throwable $previous = NULL)
{ {
parent::__construct($message, 5000, $previous); parent::__construct($message, 5000, $previous);
} }
+2 -2
View File
@@ -10,7 +10,7 @@ declare(strict_types=1);
namespace Snowflake\Exception; namespace Snowflake\Exception;
use JetBrains\PhpStorm\Pure;
use Throwable; use Throwable;
/** /**
@@ -26,7 +26,7 @@ class NotFindClassException extends \Exception
* @param int $code * @param int $code
* @param Throwable|null $previous * @param Throwable|null $previous
*/ */
#[Pure] public function __construct(string $message = "", int $code = 0, Throwable $previous = null) public function __construct(string $message = "", int $code = 0, Throwable $previous = null)
{ {
$message = "No class named `$message` was found, please check if the class name is correct"; $message = "No class named `$message` was found, please check if the class name is correct";
parent::__construct($message, 404, $previous); parent::__construct($message, 404, $previous);
+3 -3
View File
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Snowflake\Pool; namespace Snowflake\Pool;
use JetBrains\PhpStorm\Pure;
use Snowflake\Snowflake; use Snowflake\Snowflake;
/** /**
@@ -21,7 +21,7 @@ class Pool extends \Snowflake\Abstracts\Pool
/** /**
* @return Redis * @return Redis
*/ */
#[Pure] public function getRedis(): Redis public function getRedis(): Redis
{ {
return Snowflake::app()->redis_connections; return Snowflake::app()->redis_connections;
} }
@@ -29,7 +29,7 @@ class Pool extends \Snowflake\Abstracts\Pool
/** /**
* @return Connection * @return Connection
*/ */
#[Pure] public function getDb(): Connection public function getDb(): Connection
{ {
return Snowflake::app()->connections; return Snowflake::app()->connections;
} }
+4 -4
View File
@@ -7,7 +7,7 @@ namespace Snowflake;
use Exception; use Exception;
use HttpServer\IInterface\Task; use HttpServer\IInterface\Task;
use JetBrains\PhpStorm\Pure;
use ReflectionException; use ReflectionException;
use Snowflake\Abstracts\Config; use Snowflake\Abstracts\Config;
use Snowflake\Core\JSON; use Snowflake\Core\JSON;
@@ -222,7 +222,7 @@ class Snowflake
* @return Server|null * @return Server|null
* @throws * @throws
*/ */
#[Pure] public static function getWebSocket(): ?Server public static function getWebSocket(): ?Server
{ {
$server = static::app()->server->getServer(); $server = static::app()->server->getServer();
if (!($server instanceof Server)) { if (!($server instanceof Server)) {
@@ -319,7 +319,7 @@ class Snowflake
/** /**
* @return bool * @return bool
*/ */
#[Pure] public static function isMac(): bool public static function isMac(): bool
{ {
$output = strtolower(PHP_OS | PHP_OS_FAMILY); $output = strtolower(PHP_OS | PHP_OS_FAMILY);
if (str_contains('mac', $output)) { if (str_contains('mac', $output)) {
@@ -334,7 +334,7 @@ class Snowflake
/** /**
* @return bool * @return bool
*/ */
#[Pure] public static function isLinux(): bool public static function isLinux(): bool
{ {
if (!static::isMac()) { if (!static::isMac()) {
return true; return true;
+2 -2
View File
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace validator; namespace validator;
use JetBrains\PhpStorm\Pure;
/** /**
* Class EnumValidator * Class EnumValidator
@@ -42,7 +42,7 @@ class EnumValidator extends BaseValidator
/** /**
* @return string * @return string
*/ */
#[Pure] private function i(): string private function i(): string
{ {
return 'The param :attribute value only in ' . implode(',', $this->value); return 'The param :attribute value only in ' . implode(',', $this->value);
} }