Most code using the container builder are wrongly type-hinted

Created on 1 December 2016, about 8 years ago
Updated 18 September 2023, over 1 year ago

Drupal 8 most code using the container builder are type-hinting using Drupal\Core\DependencyInjection\ContainerBuilder which makes the container builder non-replaceable.

Believe it or not, but in a specific project I'm switching back the base kernel implementation and container builder implemetation to Symfony's native ones (and yes, it works) but I have found a few problems, wrong type hinting is one of them.

The Drupal ContainerBuilder is a sub-class of Symfony's Symfony\Component\DependencyInjection\ContainerBuilder, is API compatible, and does not add additional methods, so all Drupal code using it should type hint with Symfony class instead, making it replaceable.

It's flexibility at a free cost, I think this should be seriously considered.

Writing the patch right now.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated 1 day ago

Created by

πŸ‡«πŸ‡·France pounard

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
Production build 0.71.5 2024