Req #60053 [Opn->Wfx]: Allow throwing of strings and things
| From: | nikic@php.net | Date: | Thu, 27 Aug 2015 20:26:39 +0000 |
| Subject: | Req #60053 [Opn->Wfx]: Allow throwing of strings and things | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-195570@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60053&edit=1
ID: 60053
Updated by: nikic@php.net
Reported by: anon at anon dot anon
Summary: Allow throwing of strings and things
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Class/Object related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Marking as Won't Fix, as I doubt we wish to further encourage throwing of unspecific exception
types.
Previous Comments:
------------------------------------------------------------------------
[2015-02-12 00:41:02] codedokode at gmail dot com
I don't like the idea. It only makes things more confusing and you can use snippets in a code
editor to save keystrokes anyway.
------------------------------------------------------------------------
[2011-10-13 13:35:54] anon at anon dot anon
I'd like to add that since PHP is so dynamically-typed and prefers to cock programs up at run
time instead of letting them be robustly specified from the get go, I once thought I *could* do this
anyway. It's a valid syntax, but the first time one of my "exceptions" was thrown it
blew up.
------------------------------------------------------------------------
[2011-10-13 13:32:11] anon at anon dot anon
Description:
------------
Here's my suggestion: when throwing something that's not an Exception, use it as the
message of a new Exception (instead of dying). I.e.,
throw $x;
where !($x instanceof Exception)
would be interpreted as:
throw new Exception($x);
Then I could do this:
throw "I can't be arsed to type new Exception() everywhere";
>inb4 one person looks at and rejects this for some bureaucratic reason and it's never
>considered again.
>I mean, er, have a nice day.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60053&edit=1