diff --git a/src/Cache/Handler/File.php b/src/Cache/Handler/File.php index bc0471c960..6be16a9441 100644 --- a/src/Cache/Handler/File.php +++ b/src/Cache/Handler/File.php @@ -374,9 +374,8 @@ protected function checkExpire($fileName) */ protected function writeExData($fileName, $ttl) { - $data = [ + file_put_contents($this->getExDataFileName($fileName), serialize([ 'ttl' => $ttl, - ]; - file_put_contents($this->getExDataFileName($fileName), serialize($data)); + ])); } } \ No newline at end of file diff --git a/src/Server/Http/Server.php b/src/Server/Http/Server.php index bdc95755f8..f601035a11 100644 --- a/src/Server/Http/Server.php +++ b/src/Server/Http/Server.php @@ -82,11 +82,9 @@ protected function bindEvents() { $this->swooleServer->handle('/', is_callable($event) ? $event : function(\Swoole\Http\Request $swooleRequest, \Swoole\Http\Response $swooleResponse){ try{ - $request = Request::getInstance($this, $swooleRequest); - $response = Response::getInstance($this, $swooleResponse); $this->trigger('request', [ - 'request' => $request, - 'response' => $response, + 'request' => Request::getInstance($this, $swooleRequest), + 'response' => Response::getInstance($this, $swooleResponse), ], $this, RequestEventParam::class); } catch(\Throwable $ex) @@ -125,11 +123,9 @@ protected function __bindEvents() { $server->on('request', is_callable($event) ? $event : function(\Swoole\Http\Request $swooleRequest, \Swoole\Http\Response $swooleResponse){ try{ - $request = Request::getInstance($this, $swooleRequest); - $response = Response::getInstance($this, $swooleResponse); $this->trigger('request', [ - 'request' => $request, - 'response' => $response, + 'request' => Request::getInstance($this, $swooleRequest), + 'response' => Response::getInstance($this, $swooleResponse), ], $this, RequestEventParam::class); } catch(\Throwable $ex) diff --git a/src/Server/WebSocket/Server.php b/src/Server/WebSocket/Server.php index c137e18bd7..7487dd73ad 100644 --- a/src/Server/WebSocket/Server.php +++ b/src/Server/WebSocket/Server.php @@ -64,11 +64,9 @@ protected function __bindEvents() { $server->on('handshake', is_callable($event) ? $event : function(\Swoole\Http\Request $swooleRequest, \Swoole\Http\Response $swooleResponse){ try{ - $request = new Request($this, $swooleRequest); - $response = new Response($this, $swooleResponse); $this->trigger('handShake', [ - 'request' => &$request, - 'response' => &$response, + 'request' => new Request($this, $swooleRequest), + 'response' => new Response($this, $swooleResponse), ], $this, HandShakeEventParam::class); } catch(\Throwable $ex)