diff --git a/app/Task/FooTask.php b/app/Task/FooTask.php index 5a8042d..fdd0ab9 100644 --- a/app/Task/FooTask.php +++ b/app/Task/FooTask.php @@ -23,7 +23,7 @@ final class FooTask { #[Inject] - private StdoutLoggerInterface $logger; + private readonly StdoutLoggerInterface $logger; public function execute() { diff --git a/bin/hyperf.php b/bin/hyperf.php index 89e1acc..9fd7ec6 100644 --- a/bin/hyperf.php +++ b/bin/hyperf.php @@ -9,15 +9,15 @@ * @document https://wiki.cloud-admin.jayjay.cn * @license https://github.com/swow-cloud/swow-admin/blob/master/LICENSE */ -use SwowCloud\SDB\Config\ServerConfig; -use SwowCloud\SDB\Config\SslConfig; -use SwowCloud\SDB\WebSocketDebugger; use Hyperf\Contract\ApplicationInterface; use Hyperf\Di\ClassLoader; use Hyperf\Di\ScanHandler\ProcScanHandler; use Psr\Container\ContainerInterface; use Swow\Coroutine; use Swow\Debug\Debugger\Debugger; +use SwowCloud\SDB\Config\ServerConfig; +use SwowCloud\SDB\Config\SslConfig; +use SwowCloud\SDB\WebSocketDebugger; use Symfony\Component\Console\Application; function initialize(): void @@ -53,7 +53,7 @@ function initialize(): void } else { [$serverOptions, $sslOptions] = \array_values($debuggerOptions['options']); - $serverConfig = new \SwowCloud\SDB\Config\ServerConfig( + $serverConfig = new ServerConfig( host: $serverOptions['host'], port: $serverOptions['port'] ); diff --git a/cloud-admin/Http2/HPack/HPack.php b/cloud-admin/Http2/HPack/HPack.php index 1b50b76..45f2e1d 100644 --- a/cloud-admin/Http2/HPack/HPack.php +++ b/cloud-admin/Http2/HPack/HPack.php @@ -496,7 +496,7 @@ public function decode(string $input, int $maxSize): ?array /* : ?array */ if ($dynamic) { array_unshift($this->headers, $header); - $this->size += 32 + strlen($header[0]) + strlen($header[1]); + $this->size += 32 + strlen((string) $header[0]) + strlen($header[1]); if ($this->currentMaxSize < $this->size) { $this->resizeTable(); } @@ -522,7 +522,7 @@ public function decode(string $input, int $maxSize): ?array /* : ?array */ continue; } - $size += strlen($name) + strlen($value); + $size += strlen((string) $name) + strlen($value); if ($size > $maxSize) { return null; diff --git a/cloud-admin/Http2/Parser/Request.php b/cloud-admin/Http2/Parser/Request.php index b4423df..4ba0778 100644 --- a/cloud-admin/Http2/Parser/Request.php +++ b/cloud-admin/Http2/Parser/Request.php @@ -11,6 +11,7 @@ namespace CloudAdmin\Http2\Parser; +use JsonException; use function explode; use function file_put_contents; use function is_array; @@ -80,7 +81,7 @@ public function post($name = null, $default = null): mixed if (!isset($this->data['post'])) { try { $this->parsePost(); - } catch (\JsonException $e) { + } catch (JsonException) { } } if ($name === null) { @@ -168,9 +169,9 @@ protected function parsePost(): void return; } if (preg_match('/\bjson\b/i', $content_type)) { - $this->data['post'] = (array)json_decode($this->rawBody, true, 512, JSON_THROW_ON_ERROR); + $this->data['post'] = (array)json_decode((string) $this->rawBody, true, 512, JSON_THROW_ON_ERROR); } else { - parse_str($this->rawBody, $this->data['post']); + parse_str((string) $this->rawBody, $this->data['post']); } } diff --git a/cloud-admin/Http2/Server/Server.php b/cloud-admin/Http2/Server/Server.php index a3db4e6..5d866d2 100644 --- a/cloud-admin/Http2/Server/Server.php +++ b/cloud-admin/Http2/Server/Server.php @@ -12,6 +12,7 @@ namespace Hyperf\Engine\Http; +use function Hyperf\Config\config; use CloudAdmin\Http2\Config\Ssl; use CloudAdmin\Http2\Parser\Http2Connection; use CloudAdmin\Http2\Parser\Http2Parser; @@ -72,7 +73,7 @@ public function __construct(protected LoggerInterface $logger) parent::__construct(); /** @var array{certificate:string,certificate_key:string,verify_peer:bool,verify_peer_name:bool,allow_self_signed:bool} $config */ - $config = \Hyperf\Config\config('ssl'); + $config = config('ssl'); if ($config['enable'] ?? false) { if (! Extension::isBuiltWith('ssl')) { @@ -110,12 +111,11 @@ public function start(): void if ($this->ssl) { $options = $this->sslConfig->toArray(); } - $this->onRequest = function (Request $request, Http2Connection $connection) { + $this->onRequest = fn(Request $request, Http2Connection $connection) => //http2太难了 ,等作者实现吧 -// $handler = $this->handler; -// $handler($request, $connection->connection); - return new Response(200, ['A' => 'hello world'], "