Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25672 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49459 invoked by uid 1010); 13 Sep 2006 19:00:45 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 49443 invoked from network); 13 Sep 2006 19:00:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Sep 2006 19:00:45 -0000 Authentication-Results: pb1.pair.com header.from=tslettebo@broadpark.no; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=tslettebo@broadpark.no; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain broadpark.no from 80.202.4.58 cause and error) X-PHP-List-Original-Sender: tslettebo@broadpark.no X-Host-Fingerprint: 80.202.4.58 osl1smout1.broadpark.no Solaris 9 Received: from [80.202.4.58] ([80.202.4.58:61654] helo=osl1smout1.broadpark.no) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/80-45066-A3558054 for ; Wed, 13 Sep 2006 15:00:45 -0400 Received: from osl1sminn1.broadpark.no ([80.202.4.59]) by osl1smout1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with ESMTP id <0J5J0003YORY5E30@osl1smout1.broadpark.no> for internals@lists.php.net; Wed, 13 Sep 2006 20:59:58 +0200 (CEST) Received: from pc ([80.203.129.59]) by osl1sminn1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with SMTP id <0J5J000V8ORXHCD2@osl1sminn1.broadpark.no> for internals@lists.php.net; Wed, 13 Sep 2006 20:59:58 +0200 (CEST) Date: Wed, 13 Sep 2006 21:00:12 +0200 To: RQuadling@GoogleMail.com Cc: Marcus Boerger , internals@lists.php.net Message-ID: <004101c6d766$d7c55e30$9a02a8c0@pc> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 X-Mailer: Microsoft Outlook Express 6.00.2800.1807 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 8BIT X-Priority: 3 X-MSMail-priority: Normal References: <0a1301c6d64f$8af01c70$a900000a@adstate.local> <74293252.20060912230042@marcus-boerger.de> <00b501c6d6b4$632b7e90$9a02a8c0@pc> <10845a340609130053n395632f4ka5bbed3e49ce6ad2@mail.gmail.com> <0d4001c6d71a$fa124260$a900000a@adstate.local> <10845a340609130401q20127db0yf8e30f781622c63@mail.gmail.com> Subject: Re: [PHP-DEV] Return type hints From: tslettebo@broadpark.no (=?UTF-8?Q?Terje_Sletteb=C3=B8?=) >From: "Richard Quadling" > On 13/09/06, Terje Slettebø wrote: > > >From: "Richard Quadling" > > > > > On 12/09/06, Terje Slettebø wrote: > > > > function f(Something $value) /** @return SomethingElse */ > > > > { > > > > // ... > > > > } > > > > > > But one of the first things we are told about using PHP ITRW is to > > > always validate user input and to make sure you only accept what you > > > know to be valid data. > > > > True, and at least with regard to function calls, with type hinting (as you > > mention below), that testing is done for you, so you don't have to, leading > > to less code and syntactic noise (and possibly better performance). > > The issue then becomes what would happen to a value of the wrong type? Getting a fatal error, like with today's parameter type hinting? As an aside: I find it a little ironic that something called "type _hint_" gives a _fatal_ error... (Not even a chance for the error handler to catch it...) It's as if it talks with two tongues: "Oh, yes, we are very liberal - we only _hint_ at what we accept. (Then, with much lower voice) However, we do stop with a fatal error, if you try something else..." "PHP: Desperately wants to be loosely typed, yet desperately wants to be strongly typed...? :)" > You either have the option of using PHP's own internal casting > mechanism, so f(int $i_int_expected) would internally cast the > supplied parameter as an int or you have to produce a WARNING with a > "parameter of the wrong type" message. But then what is passed to the > function? This would have to be determined somehow. I'm not sure what you talk about, here? We already _have_ type hints for arguments... Regards, Terje