Req #60053 [Com]: Allow throwing of strings and things
| From: | codedokode at gmail dot com | Date: | Thu, 12 Feb 2015 00:41:02 +0000 |
| Subject: | Req #60053 [Com]: Allow throwing of strings and things | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-190598@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
Comment by: codedokode at gmail dot com
Reported by: anon at anon dot anon
Summary: Allow throwing of strings and things
Status: Open
Type: Feature/Change Request
Package: Class/Object related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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