Problem/Motivation

\Drupal::getContainer() can only return a new \Symfony\Component\DependencyInjection\ContainerInterface or throw a new \Drupal\Core\DependencyInjection\ContainerNotInitializedException. The type hint incorrectly notes that a NULL could potentially be returned.

Proposed resolution

Update the type hint to remove |null.

Remaining tasks

Contributor tasks needed
Task Novice task? Contributor instructions Complete?
Create a patch Yes Instructions Yes
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards No Instructions

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

  • Resolved an incorrect type hint on \Drupal::getContainer().
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cyb.tachyon created an issue. See original summary.

cyb_tachyon’s picture

Status: Active » Needs review
FileSize
513 bytes

Adding patch. Ready for review.

shreyal999’s picture

Assigned: Unassigned » shreyal999

The Above patch looks good, can move it further as the return is now just ContainerInterface.

borisson_’s picture

Assigned: shreyal999 » Unassigned
Status: Needs review » Reviewed & tested by the community

Not sure what else actually needs to be done on this.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed e56e16e156 to 8.8.x and f1a175f4d6 to 8.7.x. Thanks!

Backported to 8.7.x as this is a docs fix.

  • alexpott committed e56e16e on 8.8.x
    Issue #3061564 by cyb.tachyon: Fix null type hint on \Drupal::...

  • alexpott committed f1a175f on 8.7.x
    Issue #3061564 by cyb.tachyon: Fix null type hint on \Drupal::...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.