How hard should PHP try to finish a script?
| From: | Karoly Negyesi | Date: | Sun, 17 Jun 2012 19:06:03 +0000 |
| Subject: | How hard should PHP try to finish a script? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-60869@lists.php.net to get a copy of this message | ||
Hi,
PHP often throws fatal errors when it could throw an exception.
Take PHP Fatal error: Non-abstract method foo::bar() must contain
body this error for example. It would be possible to mark this class
as 'invalid' instead and when doing a new foo , throw an exception. Or
if you try really hard then only the method call should throw an
exception.
Or, I was extending ReflectionClass and got Fatal error:
ReflectionClass::getFileName(): Internal error: Failed to retrieve the
reflection object (same happens if you try serialzie / unserialzie on
ReflectionClass as a comment in the manual points out). I could argue
this is an exception and not a fatal.
Let me quote documentation:
Fatal run-time errors. These indicate errors that can not be recovered
from, such as a memory allocation problem. Execution of the script is
halted.
I do not see the above or , indeed , most of fatals I see this sort of
error. Sure, if a malloc call fails, the world has ended and it's time
to die. Otherwise, could we just get an exception so that it can be
handled ?
Thanks
Karoly "chx" Negyesi