@@ -31,7 +31,7 @@ public function __construct(
3131 parent ::__construct ($ kernel );
3232 $ this ->followRedirects ();
3333 $ this ->container = $ this ->getContainer ();
34- $ this ->rebootKernel (); // Ensure the profiler exists
34+ $ this ->rebootKernel ();
3535 }
3636
3737 /** @param Request $request */
@@ -47,7 +47,7 @@ protected function doRequest(object $request): Response
4747 }
4848
4949 /**
50- * Reboot kernel
50+ * Reboots the kernel.
5151 *
5252 * Services from the list of persistent services
5353 * are updated from service container before kernel shutdown
@@ -64,8 +64,7 @@ public function rebootKernel(): void
6464 }
6565
6666 $ this ->persistDoctrineConnections ();
67- $ this ->kernel ->boot ();
68- $ this ->kernel ->shutdown ();
67+ $ this ->ensureKernelShutdown ();
6968 $ this ->kernel ->boot ();
7069 $ this ->container = $ this ->getContainer ();
7170
@@ -82,6 +81,12 @@ public function rebootKernel(): void
8281 }
8382 }
8483
84+ protected function ensureKernelShutdown (): void
85+ {
86+ $ this ->kernel ->boot ();
87+ $ this ->kernel ->shutdown ();
88+ }
89+
8590 private function getContainer (): ?ContainerInterface
8691 {
8792 /** @var ContainerInterface $container */
@@ -120,7 +125,9 @@ private function persistDoctrineConnections(): void
120125 }
121126
122127 $ reflectedContainer = new ReflectionClass ($ publicContainer );
123- $ reflectionTarget = $ reflectedContainer ->hasProperty ('parameters ' ) ? $ publicContainer : $ publicContainer ->getParameterBag ();
128+ $ reflectionTarget = $ reflectedContainer ->hasProperty ('parameters ' )
129+ ? $ publicContainer
130+ : $ publicContainer ->getParameterBag ();
124131
125132 $ reflectedParameters = new ReflectionProperty ($ reflectionTarget , 'parameters ' );
126133 $ reflectedParameters ->setAccessible (true );
0 commit comments