Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37078 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74323 invoked from network); 17 Apr 2008 16:02:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2008 16:02:25 -0000 Authentication-Results: pb1.pair.com header.from=sam@sambarrow.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sam@sambarrow.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain sambarrow.com from 208.70.128.56 cause and error) X-PHP-List-Original-Sender: sam@sambarrow.com X-Host-Fingerprint: 208.70.128.56 smtp-gw30.mailanyone.net Received: from [208.70.128.56] ([208.70.128.56:50916] helo=smtp-gw30.mailanyone.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DA/BE-05127-F8477084 for ; Thu, 17 Apr 2008 12:02:24 -0400 Received: from mailanyone.net by smtp-gw30.mailanyone.net with esmtpsa (TLSv1:RC4-MD5:128) (MailAnyone extSMTP sam@sambarrow.com) id 1JmWZ2-0005Ul-1R; Thu, 17 Apr 2008 11:02:20 -0500 To: Paul Biggar Cc: Felipe Pena , internals@lists.php.net In-Reply-To: References: <46ccd1ab0804170742g142ed562t4f03339da549a820@mail.gmail.com> <1208445852.5366.31.camel@felipe> Content-Type: text/plain Date: Thu, 17 Apr 2008 11:59:56 -0400 Message-ID: <1208447996.32403.11.camel@sbarrow-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Strict type hints (parameter and return value) From: sam@sambarrow.com (Sam Barrow) On Thu, 2008-04-17 at 17:29 +0200, Paul Biggar wrote: > On Thu, Apr 17, 2008 at 5:24 PM, Felipe Pena wrote: > > > Thanks for making the change. This is much more consistent. It remains > > > that there is no 'scalar' or 'numeric' hint. Are you planning on > > > including them? > > > > No, i'm not planning to do that. > > Ah, I should have been more specific. I meant to ask for those > changes. Can I ask why not? I think scalar is very important. For any function where you are interacting with the database values or echoing output, scalar is very useful. > > > I also wonder about allowing NULL for an 'array' type hint. Is this > > > acceptable? The patch seems to indicate it is. If so, why is this > > > allowed? > > > > I added yesterday an information about that in the doc: > > > > "Functions are now able to force parameters to be objects (by specifying > > the name of the class in the function prototype) or arrays (since PHP > > 5.1). However, if NULL is used as the default parameter value, it will > > be allowed as an argument for any later call." > > That doesnt explain why its allowed. Can you elaborate? > The way i do it is to only allow null if null is the default. This way, people cannot skip parameters using null unless specifically allowed to in the function declaration. > > Thanks, > Paul > > > > > > On Thu, Apr 17, 2008 at 4:42 PM, Felipe Pena wrote: > > > > Hi. > > > > > > > > Well, thinking better about the behavior of type hinting, i decided to > > > > change the proposal for strict type. I.e. don't accept numeric string > > > > as an intenger, etc. > > > > > > > > If anyone wants use type hinting, i believe that it should be strict. > > > > Otherwise, it makes more sense to not use it. > > > > > > > > Examples, patches and tests: http://wiki.php.net/rfc/typehint > > > > > > > > > > > > -- > > > > Regards, > > > > Felipe Pena. > > > > > > > > -- > > > > PHP Internals - PHP Runtime Development Mailing List > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > > > > > > -- > > Regards, > > Felipe Pena. > > > > > > > > -- > Paul Biggar > paul.biggar@gmail.com >