Req #60053 [Com]: Allow throwing of strings and things

From: Date: Thu, 13 Oct 2011 13:35:54 +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-164295@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: anon at anon dot anon 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'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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#164295) next »