-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 4.0.3 |
According to this code part:
symfony/src/Symfony/Bundle/FrameworkBundle/Client.php
Lines 42 to 50 in 332ad0a
/** | |
* Returns the container. | |
* | |
* @return ContainerInterface|null Returns null when the Kernel has been shutdown or not started yet | |
*/ | |
public function getContainer() | |
{ | |
return $this->kernel->getContainer(); | |
} |
The container may be null
if the kernel has been shutdown.
But this simply call $this->kernel->getContainer();
and according to the PHPDoc:
symfony/src/Symfony/Component/HttpKernel/KernelInterface.php
Lines 127 to 132 in 332ad0a
/** | |
* Gets the current container. | |
* | |
* @return ContainerInterface A ContainerInterface instance | |
*/ | |
public function getContainer(); |
It should never return null
, always a ContainerInterface
.
This also make PHPStan yelling on web tests:
Calling method get() on possibly null value of type Symfony\Component\DependencyInjection\ContainerInterface|null.
If am I right, the PHPDoc of the Client
must be corrected.
If it may return null, I suggest to throw an exception instead. This method should not called if the kernel is not booted AFAIK.
What do you think?
Metadata
Metadata
Assignees
Labels
No labels