Edit report at http://bugs.php.net/bug.php?id=52339&edit=1

 ID:               52339
 Comment by:       dangerous dot ben at gmail dot com
 Reported by:      dangerous dot ben at gmail dot com
 Summary:          SPL autoloader breaks class_exists()
 Status:           Open
 Type:             Bug
 Package:          SPL related
 Operating System: any (debian)
 PHP Version:      5.3.3RC2

 New Comment:

On further investigation, it appears that the error is meant to happen
only if spl_autoload is called directly, and not via spl_autoload_call. 
Unfortunately when spl_autoload is the only autoloader in the stack it
gets called directly and spl_autoload_call doesn't get a look in.


Previous Comments:
------------------------------------------------------------------------
[2010-07-14 21:31:46] dangerous dot ben at gmail dot com

Description:
------------
Using PHP 5.3 from svn.



When SPL's default autoloader is the only loader in the stack it
triggers an error or throws an exception when it can't find a class. 
This means that you get an exception when calling class_exists() for a
class that doesn't exist.  This behaviour seems pointless anyway since
PHP will trigger its own fatal error if the class still doesn't exist
after attempting to autoload, so the attached patch simply removes it.





Test script:
---------------
spl_autoload_register();

class_exists('foo\bar');



Expected result:
----------------
No error



Actual result:
--------------
b...@arctor:~/src/php-5.3$ sapi/cli/php ~/code/cram/test.php 

PHP Fatal error:  Uncaught exception 'LogicException' with message
'Class foo\bar could not be loaded' in /home/ben/code/cram/test.php:4

Stack trace:

#0 [internal function]: spl_autoload('foo\bar')

#1 /home/ben/code/cram/test.php(4): class_exists('foo\bar')

#2 {main}

  thrown in /home/ben/code/cram/test.php on line 4




------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52339&edit=1

Reply via email to