Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44612 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79006 invoked from network); 1 Jul 2009 21:53:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jul 2009 21:53:53 -0000 Authentication-Results: pb1.pair.com header.from=hannes.magnusson@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=hannes.magnusson@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 72.14.220.157 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: hannes.magnusson@gmail.com X-Host-Fingerprint: 72.14.220.157 fg-out-1718.google.com Received: from [72.14.220.157] ([72.14.220.157:46875] helo=fg-out-1718.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/77-43450-0FADB4A4 for ; Wed, 01 Jul 2009 17:53:53 -0400 Received: by fg-out-1718.google.com with SMTP id 13so1006672fge.0 for ; Wed, 01 Jul 2009 14:53:48 -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 :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=7wRsTHUrIhQT41DQtlUTcmkNDf3AP2FB2+PAhrbnidk=; b=vDdUdN1/kT7yVlVw1ZrxNAre+SMLOl50UyQerpiL/k+3VjqCb01wBIbYgJ38n4dB2P PPzqLq8otRa7Sq9nLW19hlQbflF+2NjppQLJrTlbcymOuMNNJHz9jK8AqQwF+Xpy0B0C U5Qm1azCqvVnu0muF4SYbGyKuGW065mOXnaaw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=e/MHh8NMEquL28/kypVlI+CGOYuoREOONaMCaNMdY/TXTejumb+DYT/3ezXTkP9NUm kZH1BnxZm5VojTt+bsyJC48lo/8Ch5kn7Y3VQvia2w3SUHRIh+4YTHOIf+UBcVypaPjT CUK3s/GDiaeqGvUJ18uwGfXIGXOI+UKpD00OU= MIME-Version: 1.0 Received: by 10.86.68.14 with SMTP id q14mr2752952fga.48.1246485228471; Wed, 01 Jul 2009 14:53:48 -0700 (PDT) In-Reply-To: References: <4A4BAE7B.3020601@zend.com> <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> Date: Wed, 1 Jul 2009 23:53:48 +0200 Message-ID: <7f3ed2c30907011453y79eedad9w7c1c0c0832616285@mail.gmail.com> To: Paul Biggar Cc: Stanislav Malyshev , Ilia Alshanetsky , PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3 From: hannes.magnusson@gmail.com (Hannes Magnusson) 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? >> Furthermore, the patch introduces couple of new types, "scalar" and >> "numeric". These are "magic types" and do value-to-real-type >> comparison. No type casting. >> The scalar type hint accepts strings, booleans, ints and floats. >> The numeric type hint accepts strings (that pass is_numeric()), >> booleans, ints and floats. > > > 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_. > 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 :) -Hannes