|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
|
Thank you for your help!
If the status of the bug report you submitted changes, you will be notified.
You may return here and check the status or update your report at any time. The URL for your bug report is: https://bugs.php.net/bug.php?id=49143.
[2009-08-03 16:19 UTC] david at grudl dot com
Description:
------------
is_callable() and method_exists() may invoke autoloader with unnecessary namespace backslash.
\My\MyClass::func() is the same as My\MyClass::func().
Reproduce code:
---------------
function __autoload($name)
{
echo $name;
}
is_callable('\My\MyClass::func'); // ERROR
is_callable('My\MyClass::func'); // OK
method_exists('\My\MyClass', 'func'); // ERROR
method_exists('My\MyClass', 'func'); // OK
// defined works well:
defined('\My\MyClass::CONST'); // OK
defined('My\MyClass::CONST'); // OK
Expected result:
----------------
My\MyClass
My\MyClass
My\MyClass
My\MyClass
My\MyClass
My\MyClass
Actual result:
--------------
\My\MyClass
My\MyClass
\My\MyClass
My\MyClass
My\MyClass
My\MyClass
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sun Feb 22 01:00:01 2026 UTC |
This bug is still present in 5.3.2 and also affects instantiating a new class from a string variable: function __autoload($class) { echo "$class\n"; } $obj = new MyProject\Thing(); // correct: MyProject\Thing $obj = new \MyProject\Thing(); // correct: MyProject\Thing $class = '\\MyProject\\Thing'; $obj = new $class(); // wrong: \MyProject\Thing