Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37118 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94484 invoked from network); 17 Apr 2008 19:43:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2008 19:43:50 -0000 Authentication-Results: pb1.pair.com header.from=paul.biggar@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=paul.biggar@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.184.230 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: paul.biggar@gmail.com X-Host-Fingerprint: 64.233.184.230 wr-out-0506.google.com Received: from [64.233.184.230] ([64.233.184.230:34088] helo=wr-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 84/C7-05127-578A7084 for ; Thu, 17 Apr 2008 15:43:50 -0400 Received: by wr-out-0506.google.com with SMTP id 50so223503wri.2 for ; Thu, 17 Apr 2008 12:43:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=6hz6eDcN0XdswlarbcdthWWnNbSLuHedIRD6e7RrF1M=; b=j3jERabEVPzSI3LsIS4waK58vKXi10HEmEqEh4OE3N9tzIWOZEzUc4fUDiiEWecyhTr9489TVujBySMAbvxB9pFNGwk+Td8Ly1ATRsc59VtbxoiJQBqiIjfAmq84cBUl+6pyF1wsoogASHYalXTGwL++/aNoviTpT4UBo/akL5g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=mY8yNF/lJWhOIT7DB8CQbBY8Ag9ZX2Qn0eeXGmz2SSQlenvJTXUhpvDnkmLhdUcPchqpHdzKrNibc7f76rryyObtw6+hlVcLcqRY3xvsAcbxOJKkrlj1rWd8+xEfdArLUawOTtX0kyuU7m33Nuj2jyLlftAkgG/g/3dFG/km/uE= Received: by 10.114.14.1 with SMTP id 1mr2006252wan.183.1208461426521; Thu, 17 Apr 2008 12:43:46 -0700 (PDT) Received: by 10.114.255.17 with HTTP; Thu, 17 Apr 2008 12:43:46 -0700 (PDT) Message-ID: Date: Thu, 17 Apr 2008 21:43:46 +0200 To: "Stanislav Malyshev" Cc: "Felipe Pena" , internals@lists.php.net In-Reply-To: <480799C9.9030803@zend.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1208404255.5665.34.camel@pena> <480782BE.8050608@zend.com> <4807955B.5010602@zend.com> <480799C9.9030803@zend.com> Subject: Re: [PHP-DEV] [RFC] Type hints (parameter and return value) From: paul.biggar@gmail.com ("Paul Biggar") On Thu, Apr 17, 2008 at 8:41 PM, Stanislav Malyshev wrote: > > is_* are the important functions, since they are the ones which most > > resemble the type hints under discussion. Up until now, anyone > > Circular argument here. Yes, I phrased that badly. I believe it is fair to say that there would be confusion over why is_int may fail after an 'int' type hint. More generally, I think it is difficult to explain why an int type hint does not guarantee an int. > > implementing this in user-land would use is_int(). It makes perfect > > No, you shouldn't do that - there's absolutely no reason to accept 1 and > reject '1', unless you have some very rare and special circumstance. If you > are using is_int for that, your code is wrong. That is very subjective. I doubt there is 'one true style' of PHP, despite suggestions I see about 'the PHP way'. But let us suppose you would use an int cast instead to ensure you have an int (by type, not coerced value). The behaviour I recommend is also consistent with casting. It would be syntactic sugar for function ($x) { $x = (int) ($x); ... } > > sense that type hints should mimic this behaviour. Not doing so would > > be very inconsistent, and so confusing. > > > > Could we stop using word "consistent" to replace "I like it"? I am very deliberately not using "consistent" to replace "I like it", except in the sense that I like consistency. It makes no sense to find that you do not have an int, when you specify you must. I very much mean consistency, and do not have a preference for the approach, except that only one seems perfectly consistent in this case, which is why I have recommended it. Paul -- Paul Biggar paul.biggar@gmail.com