Changes between Initial Version and Version 1 of Ticket #36335
- Timestamp:
- 03/25/2016 07:52:43 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #36335 – Description
initial v1 1 1 Hello WordPress community. With this ticket I would like to get the debate of the last days about how to attract WordPress to developers (or the other way around?) to a concrete discussion on how a class autoloader could look like in WordPress core. 2 2 3 So when we start to think about some major improvements like in https://core.trac.wordpress.org/ticket/36292, whe should also take some time and talking about autoloading.3 So when we start to think about some major improvements like in #36292, we should also take some time and talking about autoloading. 4 4 5 5 == Abstract == … … 7 7 A class autoloader is a basic tool to separate code writing form code organization. It takes care about providing class declaration at the point they are needed. The fact that WordPress lacks of a core autoloader was one point mentioned in the debate on what developers [https://www.alainschlesser.com/attracting-developers-wordpress/ missing most with WordPress]. 8 8 9 == Why we need an aut loader ==9 == Why we need an autoloader == 10 10 11 11 Plugin authors using autoloaders these days. They even use composer for dependency management and ship their plugins with this dependencies. This practice [https://github.com/composer/composer/issues/3852 leads to trouble right now]. I'm convinced that in a long-range plan we even have to talk about how to deal with proper dependency management to overcome collisions. Having an autoloader in core is a precondition for this. … … 15 15 The following proposal follows a concept of separating the file locating and file loading process to avoid a violation of the single responsibility principle and to gain flexibility. All classes and interfaces are prefixed with `WP_Autoload_` to apply a pseudo namespace. 16 16 17 The main instance of this concept is the interface `WP_Autol aod_Rule`. Aautoload rule is against the client responsible for locating and loading a given class. The class is provided by its full qualified name. This leads to this interface signature:17 The main instance of this concept is the interface `WP_Autoload_Rule`. An autoload rule is against the client responsible for locating and loading a given class. The class is provided by its full qualified name. This leads to this interface signature: 18 18 19 19 {{{#!php … … 112 112 }}} 113 113 114 The main implementation should be `WP_Autoload_ AutoloadSpl` which connects to PHP standard library autoload:114 The main implementation should be `WP_Autoload_SplAutoload` which connects to PHP standard library autoload: 115 115 116 116 {{{#!php