diff --git a/Database/Mysql/Columns.php b/Database/Mysql/Columns.php index 9a5748a7..b235a021 100644 --- a/Database/Mysql/Columns.php +++ b/Database/Mysql/Columns.php @@ -371,7 +371,7 @@ class Columns extends Component return $type; } $replace = preg_replace('/\(\d+(,\d+)?\)(\s+\w+)*/', '', $type); - if (str_contains(' ', $replace)) { + if (str_contains($replace, ' ')) { $replace = explode(' ', $replace)[1]; } return $replace; diff --git a/HttpServer/Client/Client.php b/HttpServer/Client/Client.php index 62a42916..0ae1ff2f 100644 --- a/HttpServer/Client/Client.php +++ b/HttpServer/Client/Client.php @@ -10,7 +10,7 @@ declare(strict_types=1); namespace HttpServer\Client; use Exception; - +use JetBrains\PhpStorm\Pure; use Swoole\Coroutine\Http\Client as SClient; /** @@ -63,7 +63,7 @@ class Client extends ClientAbstracts } return $this->fail($client->getStatusCode(), $message, $body, $client->getHeaders()); } catch (\Throwable $exception) { - $this->addError($exception,'rpc'); + $this->addError($exception, 'rpc'); return $this->fail(500, $exception->getMessage(), [ 'file' => $exception->getFile(), 'line' => $exception->getLine() @@ -94,7 +94,7 @@ class Client extends ClientAbstracts } $client->setHeaders($this->getHeader()); $client->setMethod(strtoupper($this->getMethod())); - if (strtolower($this->getMethod()) == self::GET && !empty($data)) { + if ($this->isGet() && !empty($data)) { $path .= '?' . $data; } else { $this->setData($this->mergeParams($data)); @@ -111,7 +111,7 @@ class Client extends ClientAbstracts /** * @return array */ - private function settings(): array + #[Pure] private function settings(): array { $sslCert = $this->getSslCertFile(); $sslKey = $this->getSslKeyFile(); diff --git a/HttpServer/Client/Curl.php b/HttpServer/Client/Curl.php index b10dd647..81ddd214 100644 --- a/HttpServer/Client/Curl.php +++ b/HttpServer/Client/Curl.php @@ -19,10 +19,10 @@ class Curl extends ClientAbstracts * @param $method * @param $path * @param array $params - * @return Result|bool|array|string + * @return Result|array|string * @throws Exception */ - public function request($method, $path, $params = []): Result|bool|array|string + public function request($method, $path, $params = []): Result|array|string { if ($method == self::GET) { $path = $this->joinGetParams($path, $params); diff --git a/HttpServer/Client/HttpClient.php b/HttpServer/Client/HttpClient.php index 09400318..4b2bbdd1 100644 --- a/HttpServer/Client/HttpClient.php +++ b/HttpServer/Client/HttpClient.php @@ -4,7 +4,8 @@ namespace HttpServer\Client; - +use Exception; +use JetBrains\PhpStorm\Pure; use Snowflake\Abstracts\Component; use Snowflake\Snowflake; use Swoole\Coroutine; @@ -22,16 +23,17 @@ class HttpClient extends Component */ public static function NewRequest(): IClient { - return Coroutine::getCid() > 0 ? Client::NewRequest() : Curl::NewRequest(); + return Coroutine::getCid() > -1 ? Client::NewRequest() : Curl::NewRequest(); } /** * @return Http2 + * @throws Exception */ public static function http2(): Http2 { - return Snowflake::app()->http2; + return Snowflake::app()->get('http2'); } }