Problem/Motivation

Following #3214234: Add core/class_aliases.php and further discussion with @alexpott in Slack, I propose merging class_aliases.php into bootstrap.inc for two reasons:

  1. Less IO - we already load bootstrap.inc so why add another file
  2. At the start of the 10.x cycle we hopefully will no longer need class aliases so we will have to remove this file again then anyway

Steps to reproduce

Proposed resolution

Merge class_aliases.php into bootstrap.inc.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave created an issue. See original summary.

longwave’s picture

Status: Active » Needs review
FileSize
2.18 KB
alexpott’s picture

+++ b/core/includes/bootstrap.inc
@@ -123,6 +123,14 @@
+/**
+ * Defines class aliases that will be added by the autoloader.
+ *
+ * @todo https://www.drupal.org/project/drupal/issues/3197482 Remove this class
+ *   alias once Drupal is running Symfony 5.3 or higher.
+ */
+class_alias('Drupal\Core\Http\KernelEvent', 'Symfony\Component\HttpKernel\Event\KernelEvent', TRUE);

Let's separate the comment from the @todo - in case we add more class_aliases here.

alexpott’s picture

We have existing test coverage of the class_alias being set by the autoloader in core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelLegacyTest.php

longwave’s picture

FileSize
2.17 KB

Also change Defines -> Declare

alexpott’s picture

Version: 9.3.x-dev » 9.2.x-dev
Status: Needs review » Reviewed & tested by the community

Looks good to go. We have test coverage and this results in less to tidy up and the improve autoloading situation from #3214234: Add core/class_aliases.php

Moving to 9.2.x since the other issue landed there too.

longwave’s picture

catch’s picture

Status: Reviewed & tested by the community » Fixed

This makes sense. I didn't really think about putting it in bootstrap.inc in the original issue, but it's better there than DrupalKernel, and saves the extra file (which could end up empty when 10.0.x is opened).

  • catch committed a471551 on 9.3.x
    Issue #3214308 by longwave, alexpott: Merge class_aliases.php into...

  • catch committed 06cdce7 on 9.2.x
    Issue #3214308 by longwave, alexpott: Merge class_aliases.php into...

Status: Fixed » Closed (fixed)

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