Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44615 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83315 invoked from network); 1 Jul 2009 22:08:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jul 2009 22:08:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=paul.biggar@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=paul.biggar@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.227 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: 209.85.219.227 mail-ew0-f227.google.com Received: from [209.85.219.227] ([209.85.219.227:63673] helo=mail-ew0-f227.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 20/68-43450-04EDB4A4 for ; Wed, 01 Jul 2009 18:08:01 -0400 Received: by ewy27 with SMTP id 27so1405013ewy.23 for ; Wed, 01 Jul 2009 15:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=6HgdAXYmK63dstBbhPb2IbpHVCj7FhiVt+apjFcETIE=; b=eAzW4LdZP23qC5pwVNqdGmfbixfGtwgsxYka6CSF0Bnfs3lpI1pfqzVRUOdVwCBQgy 4wLETCBmjJAiB0nseTQiloAGL09L21unwyUtskhDIn1V79m9RyS24lOi48rDdJkIrr/R OzJ7ocuKLmQ80xzqj047RqmIatDCF36P5EhIk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=ddQi9kAF47JGaiGByC9NPzBv0sfST1gygrxuDV5RZuoNesSWy1GEZ4IF2qpzdu8wms oOzr/MB6PinZUctG9XMsjXHzq+hmNkNmSzKSo1/OUSd+2UeL1UqHk5XWUmtU3iQw5C5M OSFqtYnZjjfUgNgacHKvaS9mGQf2ai7kjQoV8= MIME-Version: 1.0 Received: by 10.210.133.2 with SMTP id g2mr1599ebd.23.1246486077082; Wed, 01 Jul 2009 15:07:57 -0700 (PDT) In-Reply-To: <7f3ed2c30907011453y79eedad9w7c1c0c0832616285@mail.gmail.com> References: <39D0B97E-3A70-44E3-B1BC-D68A0E58CA76@prohost.org> <4A4BC731.1020909@zend.com> <7f3ed2c30907011342y24ccd2c7te5f7c273f001fa7a@mail.gmail.com> <4A4BCC0D.6000704@zend.com> <7f3ed2c30907011402taa51848h56dfff924c59a6cb@mail.gmail.com> <7f3ed2c30907011423p28e693c1nc4da1e2b20ca8a45@mail.gmail.com> <7f3ed2c30907011453y79eedad9w7c1c0c0832616285@mail.gmail.com> Date: Wed, 1 Jul 2009 23:07:37 +0100 Message-ID: To: Hannes Magnusson Cc: Stanislav Malyshev , Ilia Alshanetsky , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3 From: paul.biggar@gmail.com (Paul Biggar) On Wed, Jul 1, 2009 at 10:53 PM, Hannes Magnusson wrote: > On Wed, Jul 1, 2009 at 23:36, Paul Biggar wrote: >> On Wed, Jul 1, 2009 at 10:23 PM, Hannes >> Magnusson wrote: >>> On Wed, Jul 1, 2009 at 23:07, Paul Biggar wrote: >>>> So, what you're saying is, the patch already handles coercion? If >>>> that's the case, then problem solved. >>> >>> The patch offers scalar type _hinting_. Not type _casting_. >>> >>> Type hinting in PHP works very simply: If the value doesn't type-match >>> the argument information (arginfo internally) then it will be rejected >>> and E_RECOVERABLE_ERROR thrown. >>> >>> In most circumstances that error is fatal. However. If the user >>> chooses then he can ignore that error (by creating his own error >>> handler) and continue the execution. >>> >>> Type _hinting_ is in no way related to type _casting_. >> >> >> It should be. > > function foo(string $str, array $arr) {} > > foo(false, "foobar"); > > You are saying that the first argument should be casted, but not the second? > Or are you planning on breaking pretty much every single application using PHP5? I'm sorry, I don't see what you're saying? >> Yes. Therefore only the scalar and numeric types are useful. Nobody >> wants to use an 'int' hint that fails on numeric strings. > > I do. I don't only deal with $_REQUEST stuff. > I don't have the resources to go the Y! route. I write bunch of stuff > in PHP. Real type hinting would help _alot_. My point is that type hints should be like what we've been using for years in the docs. There is obviously a tension here. People want two different features. I'm not sure I see a way to reconcile that (unless you'd like 'strict int' or 'is int'?) >> Also, I don't know what happens for string hints when you pass an >> object with a __toString handler, but it should be allowed. > > Apply the patch and try? > It would be neat if people would do a quick readthrough the patch > before arguing against it :) I did of course read the patch. I ask questions the way I do to avoid confrontation, which is all too prevalent on this list. I wanted to know what the code was intended to do, not what it does. The patch wasnt clear without context, and it had no comments or tests. (FYI, I did a fairly detailed review of the type hinting patch last year, which was ignored, so I'm reluctant to put the same effort in here). Thanks, Paul -- Paul Biggar paul.biggar@gmail.com