|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2015-04-24 05:13 UTC] michaelduff2 at yahoo dot com
  [2016-06-20 14:43 UTC] cmb@php.net
 
-Status:      Open
+Status:      Feedback
-Assigned To:
+Assigned To: cmb
  [2016-06-20 14:43 UTC] cmb@php.net
  [2016-07-03 04:22 UTC] php-bugs at lists dot php dot net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 13:00:01 2025 UTC | 
Description: ------------ This case breaks autoloading, because of an apparent assumption in the way spl_autoload processes its registered functions: namespace BaseLibrary { class Loader { protected static $ns=__NAMESPACE__; protected static $dir=__DIR__; function Load($class_name) { // ...fully tested code for autoloading classes // using static::$ns and static:$dir... } } class SomeClass { } } namespace DerivedLibrary { class Loader extends \BaseLibrary\Loader { protected static $ns=__NAMESPACE__; protected static $dir=__DIR__; } class SomeClass extends \BaseLibrary\SomeClass { } } When an attempt is made to load \DerivedLibrary\SomeClass, spl_autoload finds it correctly, include()s the file, but then never calls \BaseLibrary\Loader::Load('\BaseLibrary\SomeClass') -- which is necessary because \DerivedLibrary\SomeClass extends \BaseLibrary\SomeClass and \DerivedLibrary\Loader extends \BaseLibrary\Loader. It simply throws "Class does not exist." My guess is that the spl_autoload queue uses globally scoped data rather than function-scoped (stack) data to manage its traversal of the autoload functions, OR because spl_autoload peeks at the function call stack to ascertain which autoloaders it has already called (probably to avoid loops). If \DerivedLibrary\Loader is made into a verbatim copy of \BaseLibrary\Loader (i.e., copying the file and changing only the namespace declaration -- thereby implicitly removing the 'extends \BaseLibrary\Loader') ... then immediately everything works!