#50246 [Opn->Bgs]: Throw exception fails in __autoload() implementation
| From: | jani@php.net | Date: | Fri, 20 Nov 2009 17:56:20 +0000 |
| Subject: | #50246 [Opn->Bgs]: Throw exception fails in __autoload() implementation | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-144875@lists.php.net to get a copy of this message | ||
ID: 50246
Updated by: jani@php.net
Reported By: krzysztof dot talajko at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Windows 7 RC
PHP Version: 5.2.11
New Comment:
Thank you for not reading the manual or searching existing bug reports.
RTFM: http://php.net/autoload
Previous Comments:
------------------------------------------------------------------------
[2009-11-20 16:05:47] krzysztof dot talajko at gmail dot com
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().").";
}
------------------------------------------------------------------------
[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