Skip to content

Commit 3d11b16

Browse files
committed
[FrameworkBundle] WebTestCase KernelBrowser::getContainer null return type
1 parent 7e56ef1 commit 3d11b16

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ CHANGELOG
3232
* Added a `InMemoryTransport` to Messenger. Use it with a DSN starting with `in-memory://`.
3333
* Added `framework.property_access.throw_exception_on_invalid_property_path` config option.
3434
* Added `cache:pool:list` command to list all available cache pools.
35-
35+
* Getting the container from a non-booted kernel is deprecated.
36+
3637
4.2.0
3738
-----
3839

src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ public function __construct(KernelInterface $kernel, array $server = [], History
4646
*/
4747
public function getContainer()
4848
{
49-
return $this->kernel->getContainer();
49+
if (null === ($container = $this->kernel->getContainer())) {
50+
@trigger_error('Getting the container from a non-booted kernel is deprecated since 4.3.', E_USER_DEPRECATED);
51+
}
52+
53+
return $container;
5054
}
5155

5256
/**

src/Symfony/Bundle/FrameworkBundle/Tests/KernelBrowserTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,17 @@ private function getKernelMock()
6262

6363
return $mock;
6464
}
65+
66+
/**
67+
* @group legacy
68+
* @expectedDeprecation Getting the container from a non-booted kernel is deprecated since 4.3
69+
*/
70+
public function testDeprecatedNullKernel()
71+
{
72+
$mock = $this->getKernelMock();
73+
$client = new KernelBrowser($mock);
74+
$client->getKernel()->shutdown();
75+
76+
$this->assertNull($client->getContainer());
77+
}
6578
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy