2121class Symfony extends HttpKernelBrowser
2222{
2323 private bool $ hasPerformedRequest = false ;
24-
2524 private ?ContainerInterface $ container ;
2625
27- /**
28- * Constructor.
29- *
30- * @param Kernel $kernel A booted HttpKernel instance
31- * @param array $persistentServices An injected services
32- */
3326 public function __construct (
3427 Kernel $ kernel ,
3528 public array $ persistentServices = [],
@@ -74,14 +67,12 @@ public function rebootKernel(): void
7467
7568 $ this ->persistDoctrineConnections ();
7669 $ this ->kernel ->reboot (null );
77-
7870 $ this ->container = $ this ->getContainer ();
7971
8072 foreach ($ this ->persistentServices as $ serviceName => $ service ) {
8173 try {
8274 $ this ->container ->set ($ serviceName , $ service );
8375 } catch (InvalidArgumentException $ e ) {
84- //Private services can't be set in Symfony 4
8576 codecept_debug ("[Symfony] Can't set persistent service {$ serviceName }: " . $ e ->getMessage ());
8677 }
8778 }
@@ -95,31 +86,23 @@ private function getContainer(): ?ContainerInterface
9586 {
9687 /** @var ContainerInterface $container */
9788 $ container = $ this ->kernel ->getContainer ();
98- if ($ container ->has ('test.service_container ' )) {
99- $ container = $ container ->get ('test.service_container ' );
100- }
101-
102- return $ container ;
89+ return $ container ->has ('test.service_container ' )
90+ ? $ container ->get ('test.service_container ' )
91+ : $ container ;
10392 }
10493
10594 private function getProfiler (): ?Profiler
10695 {
107- if ($ this ->container ->has ('profiler ' )) {
108- /** @var Profiler $profiler */
109- $ profiler = $ this ->container ->get ('profiler ' );
110- return $ profiler ;
111- }
112-
113- return null ;
96+ return $ this ->container ->has ('profiler ' )
97+ ? $ this ->container ->get ('profiler ' )
98+ : null ;
11499 }
115100
116101 private function getService (string $ serviceName ): ?object
117102 {
118- if ($ this ->container ->has ($ serviceName )) {
119- return $ this ->container ->get ($ serviceName );
120- }
121-
122- return null ;
103+ return $ this ->container ->has ($ serviceName )
104+ ? $ this ->container ->get ($ serviceName )
105+ : null ;
123106 }
124107
125108 private function persistDoctrineConnections (): void
0 commit comments