|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2006-02-23 00:28 UTC] helly@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 14:00:01 2025 UTC | 
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(); }