diff --git a/HttpServer/Client/Curl.php b/HttpServer/Client/Curl.php index 81ddd214..030746bb 100644 --- a/HttpServer/Client/Curl.php +++ b/HttpServer/Client/Curl.php @@ -136,9 +136,7 @@ class Curl extends ClientAbstracts */ private function execute($curl): Result|bool|array|string { - defer(function () { - $this->cleanData(); - }); + defer(fn() => $this->cleanData()); $output = curl_exec($curl); if ($output === false) { return $this->fail(400, curl_error($curl)); diff --git a/HttpServer/Client/Http2.php b/HttpServer/Client/Http2.php index 1141c120..7080d72f 100644 --- a/HttpServer/Client/Http2.php +++ b/HttpServer/Client/Http2.php @@ -185,9 +185,7 @@ class Http2 extends Component $request->headers = array_merge($request->headers, [ 'Host' => $domain ]); - defer(function () use ($domain, $path, $request, $method) { - $this->channel->push($request, 'request.' . $method . $path); - }); + defer(fn() => $this->channel->push($request, 'request.' . $method . $path)); return $this->doRequest($request, $domain, $isSsl, $timeout); } @@ -217,9 +215,7 @@ class Http2 extends Component private function doRequest(Request $request, $domain, $ssl, $timeout): mixed { $client = $this->getClient($domain, $ssl, $timeout); - defer(function () use ($client, $domain) { - $this->channel->push($client, 'http2.' . $domain); - }); + defer(fn() => $this->channel->push($client, 'http2.' . $domain)); $client->send($request); if (Context::getContext('http2isRecv') === false) { return null; diff --git a/Rpc/Client.php b/Rpc/Client.php index 32ed3fdc..ee639652 100644 --- a/Rpc/Client.php +++ b/Rpc/Client.php @@ -50,9 +50,7 @@ class Client extends Component if ($isSend === false) { return $this->addError($this->client->errMsg . '(' . $this->client->errCode . ')'); } - defer(function () { - $this->clientRecover(); - }); + defer(fn() => $this->clientRecover()); if (is_bool($unpack = Json::decode($this->client->recv()))) { $unpack = $this->addError('Service return data format error(500)'); }