php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43862 Autoload Functions in Namespaces
Submitted: 2008-01-16 05:02 UTC Modified: 2008-01-22 17:01 UTC
From: rpanning at hotmail dot com Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5.3CVS-2008-01-16 (snap) OS: Windows XP SP2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rpanning at hotmail dot com
New email:
PHP Version: OS:

 

 [2008-01-16 05:02 UTC] rpanning at hotmail dot com
Description:
------------
Currently spl_autoload_register() is unable to load any functions or class static functions in namespaces.

Reproduce code:
---------------
namespace NS;

function load_class($name) {
	// load class file
}

class Test {
	public static function load_class($name) {
		// load class file
	}
}

spl_autoload_register(array('NS', 'load_class'));

spl_autoload_register(array('NS', 'Test', 'load_class'));

var_dump(spl_autoload_functions());

Expected result:
----------------
Should output an array with the registered namespace function and namespace class static function.

Actual result:
--------------
Fatal error: Uncaught exception 'LogicException' with message 'Passed array does not specify an existing static method' in C:\PHP\file.php:14 Stack trace: #0 C:\PHP\file.php(14): spl_autoload_register(Array) #1 {main} thrown in C:\PHP\file.php on line 14

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-22 17:01 UTC] felipe@php.net
spl_autoload_register(__NAMESPACE__ .'::load_class');
spl_autoload_register(array(__NAMESPACE__ .'::Test', 'load_class'));
spl_autoload_register(__NAMESPACE__ .'::Test::load_class');

Works fine!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 18:01:34 2025 UTC