Opened 8 years ago
Closed 8 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.
See also #36335, especially https://core.trac.wordpress.org/ticket/36335#comment:14 and related comments.