[wp-trac] [WordPress Trac] #36926: Autoloading: Introduce compatibility shim for spl_autoload_register

WordPress Trac noreply at wordpress.org
Tue May 24 06:23:06 UTC 2016


#36926: Autoloading: Introduce compatibility shim for spl_autoload_register
-----------------------------------+------------------
 Reporter:  rmccue                 |       Owner:
     Type:  enhancement            |      Status:  new
 Priority:  normal                 |   Milestone:  4.6
Component:  General                |     Version:
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+------------------

Comment (by tfrommen):

 Hey Ryan,

 since you copied stuff from the Autoloader ticket, I do that as well. ;)

 We actually spoke about it, but it hasn't made it into your code yet.

 '''Improve `__autoload()`'''
 `$spl_autoloaders` is global, so anyone can put into it whatever they
 like. So we should check for `is_callable` for each autoloader function
 '''inside `__autoload()`''', and `continue` if it isn't.

 '''Improve `spl_autoload_functions()`'''
 Since `$spl_autoloaders` is, again, a global, and since we don't want to
 argue with SPL, we should make sure we're returning an array.

 {{{#!php
 <?php

 function spl_autoload_functions() {
         global $spl_autoloaders;

         return is_array( $spl_autoloaders ) ? $spl_autoloaders : array();
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36926#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list