#50731 [NEW]: Inconsistent namespaces sent to functions registered with spl_autoload_register
| From: | court at epixa dot com | Date: | Tue, 12 Jan 2010 18:09:45 +0000 |
| Subject: | #50731 [NEW]: Inconsistent namespaces sent to functions registered with spl_autoload_register | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-146581@lists.php.net to get a copy of this message | ||
From: court at epixa dot com
Operating system: MAC OS X 10.6.2
PHP version: 5.3.1
PHP Bug Type: SPL related
Bug description: Inconsistent namespaces sent to functions registered with spl_autoload_register
Description:
------------
When you instantiate a namespaced class, the expected behavior is for the
fully qualified namespace with leading slash absent to be passed to your
registered function. However, if you instantiate a namespaced class with a
class name stored in a variable, the fully qualified namespace is not
evaluated and the leading slash (if specified) is included.
You'll have to run the reproduce code twice to see what I mean.
Reproduce code:
---------------
function loadClass($class) {
die($class . PHP_EOL);
}
spl_autoload_register('loadClass');
$myClass = '\Fully\Qualified\ClassName';
// run this first:
new \Fully\Qualified\ClassName();
// run this second:
//new $myClass();
Expected result:
----------------
First run:
Fully\Qualified\ClassName
Second run:
Fully\Qualified\ClassName
Actual result:
--------------
First run:
Fully\Qualified\ClassName
Second run:
\Fully\Qualified\ClassName
--
Edit bug report at http://bugs.php.net/?id=50731&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50731&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50731&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50731&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50731&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50731&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50731&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50731&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50731&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50731&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50731&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50731&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50731&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50731&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50731&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50731&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50731&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50731&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50731&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50731&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50731&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50731&r=mysqlcfg