Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:459 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43248 invoked from network); 29 Mar 2003 13:23:42 -0000 Received: from unknown (HELO moutng.kundenserver.de) (212.227.126.187) by pb1.pair.com with SMTP; 29 Mar 2003 13:23:42 -0000 Received: from [212.227.126.205] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 18zGIz-0003Dx-00; Sat, 29 Mar 2003 14:23:29 +0100 Received: from [217.80.180.239] (helo=[217.80.180.239]) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 18zGIz-0003at-00; Sat, 29 Mar 2003 14:23:29 +0100 To: zeev@zend.com Cc: engine2@lists.zend.com, internals@lists.php.net In-Reply-To: <5.1.0.14.2.20030329150401.06b3c688@localhost> References: <1048781764.25691.593.camel@localhost> <1048781764.25691.593.camel@localhost> <5.1.0.14.2.20030329150401.06b3c688@localhost> Content-Type: text/plain Organization: Message-ID: <1048944208.25691.691.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 29 Mar 2003 14:23:29 +0100 Content-Transfer-Encoding: 7bit Subject: Re: [Zend Engine 2] Type hints revisited [IllegalArgumentException instead of E_ERROR] From: thekid@thekid.de (Timm Friebe) On Sat, 2003-03-29 at 13:10, Zeev Suraski wrote: [...] > >After reading through a bunch of mails this generated, I get the idea > >that most people here would be happier with an E_WARNING and the > >function not being executed. > > ?! > > How the heck can we even think about such a thing? When you call a > function, you expect it to run. The code that follows it may rely on stuff > that it has done. Not running it is simply not an option, I can't even > begin to imagine the possible consequences of such an approach! Well, at the moment, the function is not run either, isn't it? The program dies. To clarify: function foo(Bar $bar) { // [...] } is - with my patch - equivalent to: function foo($bar) { if (!($bar instanceof Bar)) { trigger_error('Argument 1 must be an instance of Bar', E_WARNING); return; } // [...] } and basically much nicer as a function containing - say - five or six arguments all needing to be checked in the "not-instance-of" manner. At the moment, it is: function foo($bar) { if (!($bar instanceof Bar)) { die('Argument 1 must be an instance of Bar'); } // [...] } That's all I changed. > Type hints are shortcuts for instanceof. If you want to handle a situation > where the function is passed the wrong arguments, don't use type hints, use > instanceof. Or use the errors-for-exceptions mode that we may have. I guess, as we can't find a consensus here, that is what has to be done. - Timm