php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47568 autoload function with namespace aliasing
Submitted: 2009-03-05 05:38 UTC Modified: 2009-03-10 18:12 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: ice dot wynn at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3CVS-2009-03-05 (snap) OS: windows vista
Private report: No CVE-ID: None
 [2009-03-05 05:38 UTC] ice dot wynn at gmail dot com
Description:
------------
The parameter of __autoload() is wrong when using a variable to instantiate a namespaced class with aliasing namespace.

Reproduce code:
---------------
<?php
//file 1
function __autoload($className){
    var_dump($className);
    //require($className.'.php');
    exit;
}
use Foo as Bar;
new Bar\SomeClass;
?>

<?php
//file 2
function __autoload($className){
    var_dump($className);
    //require($className.'.php');
    exit;
}
use Foo as Bar;
$class = 'Bar\SomeClass';
new $class;
?>



Expected result:
----------------
file 1:
string(13) "Foo\SomeClass" 
file 2:
string(13) "Foo\SomeClass" 

Actual result:
--------------
file 1:
string(13) "Foo\SomeClass" 
file 2:
string(13) "Bar\SomeClass" 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-10 18:12 UTC] scottmac@php.net
Importing is performed at compile-time, and so does not affect dynamic class, function or constant names.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Dec 12 06:00:01 2025 UTC