Skip to content

Commit fb3149e

Browse files
[Runtime] Reuse the already created Request object when the app needs it as argument returns a kernel
1 parent 59933ca commit fb3149e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

SymfonyRuntime.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class SymfonyRuntime extends GenericRuntime
7070
private readonly ConsoleOutput $output;
7171
private readonly Application $console;
7272
private readonly Command $command;
73+
private readonly Request $request;
7374

7475
/**
7576
* @param array {
@@ -131,7 +132,7 @@ public function __construct(array $options = [])
131132
public function getRunner(?object $application): RunnerInterface
132133
{
133134
if ($application instanceof HttpKernelInterface) {
134-
return new HttpKernelRunner($application, Request::createFromGlobals(), $this->options['debug'] ?? false);
135+
return new HttpKernelRunner($application, $this->request ??= Request::createFromGlobals(), $this->options['debug'] ?? false);
135136
}
136137

137138
if ($application instanceof Response) {
@@ -179,7 +180,7 @@ public function getRunner(?object $application): RunnerInterface
179180
protected function getArgument(\ReflectionParameter $parameter, ?string $type): mixed
180181
{
181182
return match ($type) {
182-
Request::class => Request::createFromGlobals(),
183+
Request::class => $this->request ??= Request::createFromGlobals(),
183184
InputInterface::class => $this->getInput(),
184185
OutputInterface::class => $this->output ??= new ConsoleOutput(),
185186
Application::class => $this->console ??= new Application(),

0 commit comments

Comments
 (0)