WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #36335


Ignore:
Timestamp:
03/25/2016 07:52:43 PM (4 years ago)
Author:
ocean90
Comment:

Previously: #21300, #30203

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #36335 – Description

    initial v1  
    11Hello 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.
    22
    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.
     3So when we start to think about some major improvements like in #36292, we should also take some time and talking about autoloading.
    44
    55== Abstract ==
     
    77A 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].
    88
    9 == Why we need an autloader ==
     9== Why we need an autoloader ==
    1010
    1111Plugin 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.
     
    1515The 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.
    1616
    17 The main instance of this concept is the interface `WP_Autolaod_Rule`. A 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:
     17The 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:
    1818
    1919{{{#!php
     
    112112}}}
    113113
    114 The main implementation should be `WP_Autoload_AutoloadSpl` which connects to PHP standard library autoload:
     114The main implementation should be `WP_Autoload_SplAutoload` which connects to PHP standard library autoload:
    115115
    116116{{{#!php