From 1339d2d94930ef8ab46d02a3fb9c5583ca1ef365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 30 Oct 2023 15:51:19 +0100 Subject: [PATCH] frankenphp-symfony: tiny refactoring (#151) Tiny refactoring as suggested in https://github.com/php-runtime/runtime/pull/148#discussion_r1375910285 --- src/Runner.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Runner.php b/src/Runner.php index 0de2c89..d5f08c2 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -22,16 +22,15 @@ public function __construct(private HttpKernelInterface $kernel) public function run(): int { - $kernel = $this->kernel; $server = array_filter($_SERVER, static fn (string $key) => !str_starts_with($key, 'HTTP_'), ARRAY_FILTER_USE_KEY); $server['APP_RUNTIME_MODE'] = 'web=1&worker=1'; - $handler = static function () use ($kernel, $server, &$sfRequest, &$sfResponse): void { + $handler = function () use ($server, &$sfRequest, &$sfResponse): void { // Merge the environment variables coming from DotEnv with the ones tied to the current request $_SERVER += $server; $sfRequest = Request::createFromGlobals(); - $sfResponse = $kernel->handle($sfRequest); + $sfResponse = $this->kernel->handle($sfRequest); $sfResponse->send(); }; @@ -39,8 +38,8 @@ public function run(): int do { $ret = \frankenphp_handle_request($handler); - if ($kernel instanceof TerminableInterface && $sfRequest && $sfResponse) { - $kernel->terminate($sfRequest, $sfResponse); + if ($this->kernel instanceof TerminableInterface && $sfRequest && $sfResponse) { + $this->kernel->terminate($sfRequest, $sfResponse); } gc_collect_cycles();