File tree 4 files changed +26
-1
lines changed
src/Symfony/Component/HttpKernel
4 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ CHANGELOG
25
25
* renamed ` PostResponseEvent ` to ` TerminateEvent `
26
26
* added ` HttpClientKernel ` for handling requests with an ` HttpClientInterface ` instance
27
27
* added ` trace_header ` and ` trace_level ` configuration options to ` HttpCache `
28
+ * Getting the container from a non-booted kernel Sis deprecated.
28
29
29
30
4.2.0
30
31
-----
Original file line number Diff line number Diff line change @@ -361,6 +361,10 @@ public function getProjectDir()
361
361
*/
362
362
public function getContainer ()
363
363
{
364
+ if (null === $ this ->container ) {
365
+ @trigger_error ('Getting the container from a non-booted kernel is deprecated since Symfony 4.3 and will throw an exceptions in Symfony 5.0. ' , E_USER_DEPRECATED );
366
+ }
367
+
364
368
return $ this ->container ;
365
369
}
366
370
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ public function getRootDir();
133
133
/**
134
134
* Gets the current container.
135
135
*
136
- * @return ContainerInterface|null A ContainerInterface instance or null when the Kernel is shutdown
136
+ * @return ContainerInterface A ContainerInterface instance or null when the Kernel is shutdown
137
137
*/
138
138
public function getContainer ();
139
139
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ public static function tearDownAfterClass()
36
36
$ fs ->remove (__DIR__ .'/Fixtures/var ' );
37
37
}
38
38
39
+ /**
40
+ * @group legacy
41
+ * @expectedDeprecation Getting the container from a non-booted kernel is deprecated since Symfony 4.3 and will throw an exceptions in Symfony 5.0.
42
+ */
39
43
public function testConstructor ()
40
44
{
41
45
$ env = 'test_env ' ;
@@ -49,6 +53,10 @@ public function testConstructor()
49
53
$ this ->assertNull ($ kernel ->getContainer ());
50
54
}
51
55
56
+ /**
57
+ * @group legacy
58
+ * @expectedDeprecation Getting the container from a non-booted kernel is deprecated since Symfony 4.3 and will throw an exceptions in Symfony 5.0.
59
+ */
52
60
public function testClone ()
53
61
{
54
62
$ env = 'test_env ' ;
@@ -486,6 +494,18 @@ public function testTerminateReturnsSilentlyIfKernelIsNotBooted()
486
494
$ kernel ->terminate (Request::create ('/ ' ), new Response ());
487
495
}
488
496
497
+ /**
498
+ * @group legacy
499
+ * @expectedDeprecation Getting the container from a non-booted kernel is deprecated since Symfony 4.3 and will throw an exceptions in Symfony 5.0.
500
+ */
501
+ public function testDeprecatedNullKernel ()
502
+ {
503
+ $ kernel = $ this ->getKernel ();
504
+ $ kernel ->shutdown ();
505
+
506
+ $ this ->assertNull ($ kernel ->getContainer ());
507
+ }
508
+
489
509
public function testTerminateDelegatesTerminationOnlyForTerminableInterface ()
490
510
{
491
511
// does not implement TerminableInterface
You can’t perform that action at this time.
0 commit comments