From: aarone at klamathsystems dot com
Operating system: Windows
PHP version: 5.1.2
PHP Bug Type: Feature/Change Request
Bug description: have abstract class instatiation throw exception
Description:
------------
would like to have abstract class instatiation throw exception instead of
raise a fatal error.
One use case would be dynamic library loading when the application has to
discover which library it needs.
What are the obstacles to having exceptions caught for runtime errors such
as attempting to instantiate an abstract class? I could probably think of
other instances (especially of older functions that could be upgraded to
php5) that could benefit for the robustness this would allow.
If the tradeoff is for speed or efficiency, that's understandable, but it
would be nice to have an exception that could be caught and recovered from
instead of a fatal error.
Example below:
Reproduce code:
---------------
abstract class Foo
{
}
class Bar extends Foo
{}
try
{
$foo = new Foo();
}
catch (Exception e)
{
//Foo is an abstract class, use concrete class Bar instead
$foo = new Bar();
}
--
Edit bug report at http://bugs.php.net/?id=36491&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=36491&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=36491&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=36491&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36491&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=36491&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36491&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36491&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36491&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36491&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36491&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=36491&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=36491&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36491&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36491&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36491&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36491&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36491&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36491&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36491&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36491&r=mysqlcfg