From: d at koteroff dot ru
Operating system: *
PHP version: 5CVS-2004-05-21 (dev)
PHP Bug Type: Zend Engine 2 problem
Bug description: catch() does not catch exceptions by interfaces
Description:
------------
Seems PHP does not support exception catching by parent interface (not by
parent classes). Why? This is a very powerful method to classify
exceptions in programs.
Documentation says that while comparing type in catch block 'instanceof'
operator is used, but following test shows that it is wrong.
I found corresponding code in the source, zend_execute.c:2866, and it
searches for parent classes only. Why not use instanceof_function?
Do you have any perspectives about this problem? Can I wrote in my book
that PHP will support "interface catching" in the future?
Reproduce code:
---------------
<?
interface E {}
class A extends Exception implements E {}
try {
throw new A();
} catch (E $e) {
echo $e;
}
?>
Expected result:
----------------
prints exception data
Actual result:
--------------
Fatal error: Uncaught exception
--
Edit bug report at http://bugs.php.net/?id=28464&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28464&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28464&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28464&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28464&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28464&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28464&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28464&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28464&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28464&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28464&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28464&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28464&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28464&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28464&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28464&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28464&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28464&r=float