WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#37816 closed enhancement (duplicate)

spl_autoload_register() has a shim since 4.6, wp_maybe_use_it()

Reported by: wonderboymusic Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: Bootstrap/Load Keywords:
Focuses: Cc:

Description

WordPress is one of the few remaining PHP projects on this green Earth that doesn't lean on Composer in any way. That's fine (?), but since 4.6, and the introduction of Requests, there is now a shim for spl_autoload_register(). Previous arguments against autoloaders were mostly based around the fact that SPL can be disabled in PHP installs (it can).

4.6 introduced in autoloader for Requests, because autoloaders make a lot of sense. Our naming conventions for classes don't jive with PSR-0 nor PSR-4, but Composer generates classmaps when optimize-autoloader: true is set that just throw a map to the top of the stack that points Namespace\Class => 'file.php'. We can implement the said classmap approach for our classes.

Patch attached.

Attachments (1)

autoload.diff (15.6 KB) - added by wonderboymusic 4 years ago.

Download all attachments as: .zip

Change History (3)

#2 @jorbin
4 years ago

  • Milestone 4.7 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

As #36335 is still open and has some good discussion, let's defer discussion to that ticket.

Note: See TracTickets for help on using tickets.