Remove checks for Symfony's DI Container#100
Remove checks for Symfony's DI Container#100mbabker wants to merge 1 commit intoschmittjoh:masterfrom
Conversation
W0rma
left a comment
There was a problem hiding this comment.
Since Symfony 3.3, the DI component's ContainerInterface has extended the PSR-11 ContainerInterface. So unless Symfony 3.2 and older are still being supported here, there isn't a need to explicitly check for the Symfony container in the lazy driver.
Do you think we should add a "conflict" for "symfony/dependency-injection": "<3.3" to the composer.json?
| * @param ContainerInterface|PsrContainerInterface $container | ||
| * @param ContainerInterface $container | ||
| */ | ||
| public function __construct($container, string $realDriverId) |
There was a problem hiding this comment.
Couldn't we just use a native php type hint here?
| public function __construct($container, string $realDriverId) | |
| public function __construct(ContainerInterface $container, string $realDriverId) |
There was a problem hiding this comment.
Technically adding a typehint is a B/C break, though the typehint would match up with the runtime check in the constructor (it just changes the error type). If it’s OK with the maintainers, we can add the typehint and remove the inline check.
I don't think it needs to go that far. IMO the Symfony container check is a bit of a special case for legacy support (the class originally only supported the Symfony container interface then added PSR-11 support), I think we're far enough past the PSR being accepted and it being widely adopted enough that there doesn't need to be any extra checks or conflicts. |
|
What is the advantage of this change? is the current code not working? |
|
It’s a redundant check when using Symfony 3.3 and later as their container interface implements the PSR interface. The current code works, but it’s really only necessary now for legacy Symfony support. |
Since Symfony 3.3, the DI component's
ContainerInterfacehas extended the PSR-11ContainerInterface. So unless Symfony 3.2 and older are still being supported here, there isn't a need to explicitly check for the Symfony container in the lazy driver.