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
@@ -16,7 +16,7 @@ use HttpServer\Http\Request;
use HttpServer\Http\Response;
use HttpServer\Route\Router;
use HttpServer\Server;
use JetBrains\PhpStorm\Pure;
use Kafka\Producer;
use Annotation\Annotation as SAnnotation;
use Snowflake\Cache\Redis;
@@ -139,7 +139,7 @@ abstract class BaseApplication extends Service
*
* @return bool
*/
#[Pure] protected function looksLikeSetter(string $line): bool
protected function looksLikeSetter(string $line): bool
{
return str_contains($line, '=');
}
+2 -2
View File
@@ -10,7 +10,7 @@ declare(strict_types=1);
namespace Snowflake\Abstracts;
use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Error\Logger;
use Snowflake\Snowflake;
@@ -45,7 +45,7 @@ class BaseObject implements Configure
/**
* @return string
*/
#[Pure] public static function className(): string
public static function className(): string
{
return get_called_class();
}
+2 -2
View File
@@ -11,7 +11,7 @@ namespace Snowflake\Abstracts;
use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Snowflake;
/**
@@ -50,7 +50,7 @@ class Component extends BaseObject
* @param null $callback
* @return bool
*/
#[Pure] public function hasEvent($name, $callback = null): bool
public function hasEvent($name, $callback = null): bool
{
if (!isset($this->_events[$name])) {
return false;
+2 -2
View File
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace Snowflake\Abstracts;
use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Exception\ConfigException;
use Snowflake\Abstracts\Component;
use Snowflake\Snowflake;
@@ -94,7 +94,7 @@ class Config extends Component
* @param bool $must_not_null
* @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;
if (!isset($config->data[$key])) {
+2 -2
View File
@@ -5,7 +5,7 @@ namespace Snowflake\Abstracts;
use Exception;
use JetBrains\PhpStorm\Pure;
use Swoole\Coroutine;
use Swoole\Coroutine\Channel;
@@ -57,7 +57,7 @@ abstract class Pool extends Component
* @param false $isMaster
* @return string
*/
#[Pure] public function name($cds, $isMaster = false): string
public function name($cds, $isMaster = false): string
{
if ($isMaster === true) {
return hash('sha256', $cds . 'master');
+2 -2
View File
@@ -11,7 +11,7 @@ namespace Snowflake\Cache;
use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\Component;
use Swoole\Coroutine\System;
@@ -119,7 +119,7 @@ class File extends Component implements ICache
* @param $key
* @return bool
*/
#[Pure] public function exists($key): bool
public function exists($key): bool
{
return file_exists($key);
}
+2 -2
View File
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace Snowflake\Core;
use JetBrains\PhpStorm\Pure;
/**
* Class DateFormat
@@ -96,7 +96,7 @@ class DateFormat
* @param null $endTime
* @return string
*/
#[Pure] public static function mtime($startTime, $endTime = null)
public static function mtime($startTime, $endTime = null)
{
if ($endTime === null) {
$endTime = microtime(true);
+2 -2
View File
@@ -6,7 +6,7 @@ namespace Snowflake\Core;
use Exception;
use JetBrains\PhpStorm\Pure;
/**
* Class Help
@@ -19,7 +19,7 @@ class Help
* @param array $data
* @return string
*/
#[Pure] public static function toXml(array $data)
public static function toXml(array $data)
{
$xml = "<xml>";
foreach ($data as $key => $val) {
+6 -6
View File
@@ -5,7 +5,7 @@ namespace Snowflake\Core;
use Exception;
use JetBrains\PhpStorm\Pure;
/**
* Class Str
@@ -24,7 +24,7 @@ class Str
* @return string
* 获取随机字符串
*/
#[Pure] public static function rand(int $length = 20): string
public static function rand(int $length = 20): string
{
$string = '';
if ($length < 1) $length = 20;
@@ -42,7 +42,7 @@ class Str
* @return int|string 获取随机数字
* 获取随机数字
*/
#[Pure] public static function random(int $length = 20): int|string
public static function random(int $length = 20): int|string
{
$number = '';
$default = str_split(self::NUMBER);
@@ -119,7 +119,7 @@ class Str
* @param string $append
* @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)) {
return '';
@@ -167,7 +167,7 @@ class Str
* @param $type
* @return string
*/
#[Pure] public static function filename($file, $type): string
public static function filename($file, $type): string
{
switch ($type) {
case 'image/png':
@@ -218,7 +218,7 @@ class Str
* @param string $string
* @return string
*/
#[Pure] public static function encode(string $string): string
public static function encode(string $string): string
{
return addslashes($string);
}
+2 -2
View File
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Snowflake\Exception;
use JetBrains\PhpStorm\Pure;
use Throwable;
/**
@@ -21,7 +21,7 @@ class AuthException extends \Exception
* @param int $code
* @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);
}
+2 -2
View File
@@ -10,7 +10,7 @@ declare(strict_types=1);
namespace Snowflake\Exception;
use JetBrains\PhpStorm\Pure;
use Throwable;
/**
@@ -27,7 +27,7 @@ class ComponentException extends \Exception
* @param int $code
* @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);
}
+2 -2
View File
@@ -10,7 +10,7 @@ declare(strict_types=1);
namespace Snowflake\Exception;
use JetBrains\PhpStorm\Pure;
use Throwable;
/**
@@ -26,7 +26,7 @@ class NotFindClassException extends \Exception
* @param int $code
* @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";
parent::__construct($message, 404, $previous);
+3 -3
View File
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Snowflake\Pool;
use JetBrains\PhpStorm\Pure;
use Snowflake\Snowflake;
/**
@@ -21,7 +21,7 @@ class Pool extends \Snowflake\Abstracts\Pool
/**
* @return Redis
*/
#[Pure] public function getRedis(): Redis
public function getRedis(): Redis
{
return Snowflake::app()->redis_connections;
}
@@ -29,7 +29,7 @@ class Pool extends \Snowflake\Abstracts\Pool
/**
* @return Connection
*/
#[Pure] public function getDb(): Connection
public function getDb(): Connection
{
return Snowflake::app()->connections;
}
+4 -4
View File
@@ -7,7 +7,7 @@ namespace Snowflake;
use Exception;
use HttpServer\IInterface\Task;
use JetBrains\PhpStorm\Pure;
use ReflectionException;
use Snowflake\Abstracts\Config;
use Snowflake\Core\JSON;
@@ -222,7 +222,7 @@ class Snowflake
* @return Server|null
* @throws
*/
#[Pure] public static function getWebSocket(): ?Server
public static function getWebSocket(): ?Server
{
$server = static::app()->server->getServer();
if (!($server instanceof Server)) {
@@ -319,7 +319,7 @@ class Snowflake
/**
* @return bool
*/
#[Pure] public static function isMac(): bool
public static function isMac(): bool
{
$output = strtolower(PHP_OS | PHP_OS_FAMILY);
if (str_contains('mac', $output)) {
@@ -334,7 +334,7 @@ class Snowflake
/**
* @return bool
*/
#[Pure] public static function isLinux(): bool
public static function isLinux(): bool
{
if (!static::isMac()) {
return true;