ID: 50246
User updated by: krzysztof dot talajko at gmail dot com
Reported By: krzysztof dot talajko at gmail dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Windows 7 RC
PHP Version: 5.2.11
New Comment:
Simpler reproduce code is (results same as in original code):
<?php
function __autoload($class) {
throw new Exception("Class ".$class." not found");
}
try{
new Foo;
}
catch (Exception $e) {
echo "Caught load class failed exception (".$e->getMessage().").";
}
Previous Comments:
------------------------------------------------------------------------
[2009-11-20 15:58:12] krzysztof dot talajko at gmail dot com
Description:
------------
Throw exception in __autoload() implementation is impossible. Instead
fatal error "Class (...) not found" is reported.
Reproduce code:
---------------
<?php
function loader($class) {
@include_once($class.'.php');
if (!class_exists($class, false)) {
throw new Exception("Class ".$class." not found");
}
}
spl_autoload_register('loader');
try{
class FooClass extends Some_Not_Existing_Class {}
}
catch (Exception $e) {
echo "Caught load class failed exception (".$e->getMessage().").";
}
Expected result:
----------------
Caught load class failed exception (Class Some_Not_Existing_Class not
found).
Actual result:
--------------
Fatal error: Class 'Some_Not_Existing_Class' not found in
C:\dev\workspace\foo.php on line 19
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50246&edit=1