Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44589 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13112 invoked from network); 1 Jul 2009 18:32:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jul 2009 18:32:42 -0000 Authentication-Results: pb1.pair.com header.from=ilia@prohost.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ilia@prohost.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain prohost.org from 209.85.218.206 cause and error) X-PHP-List-Original-Sender: ilia@prohost.org X-Host-Fingerprint: 209.85.218.206 mail-bw0-f206.google.com Received: from [209.85.218.206] ([209.85.218.206:63105] helo=mail-bw0-f206.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/C4-24906-8CBAB4A4 for ; Wed, 01 Jul 2009 14:32:42 -0400 Received: by bwz2 with SMTP id 2so555517bwz.23 for ; Wed, 01 Jul 2009 11:32:37 -0700 (PDT) Received: by 10.204.118.70 with SMTP id u6mr9756150bkq.198.1246473155978; Wed, 01 Jul 2009 11:32:35 -0700 (PDT) Received: from ?10.195.36.143? ([24.114.234.32]) by mx.google.com with ESMTPS id z15sm2484841fkz.34.2009.07.01.11.32.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 01 Jul 2009 11:32:35 -0700 (PDT) References: Message-ID: <0B8CA34F-7D86-4BD1-813B-B64AC01CD0B1@prohost.org> To: Paul Biggar In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (iPhone Mail 7A341) Date: Wed, 1 Jul 2009 13:45:01 -0400 Cc: PHP internals X-Mailer: iPhone Mail (7A341) Subject: Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3 From: ilia@prohost.org (Ilia Alshanetsky) If you use int type hit "1" will be rejected, but if use numeric type hint it will be accepted. Ilia Alshanetsky On 2009-07-01, at 1:23 PM, Paul Biggar wrote: > Hi Ilia, > > This is great. > > On Wed, Jul 1, 2009 at 5:59 PM, Ilia Alshanetsky > wrote: >> I've taken a few hours this morning to port my 5.2 type hinting >> patch to >> 5.3. In recognition of a need for a more 'flexible' numeric type I've >> introduced (numeric) type hint that would allow bool/int/float data >> types as >> well as a string containing a numeric entity as identified by >> is_numeric_string(). For completion i've also added (scalar) data >> type that >> will allow any scalar data element. > > I think this will go a long way to addressing people's concerns when > this came up previously. > > >> The patch is available here: http://ia.gd/patch/type_hint_53.txt > > I presume the idea is that some people (if they so chose) would want > to type hint every parameter in their program. To facilitate this, I > might suggest a "mixed" hint (like in the docs), and a null hint > (though I'm not sure if it would be called "null" or "unset" or both). > > > Finally, I don't want to ruin this, but last time there was > disagreement over whether numbers should be coerced to the specified > types, or left alone. What does your patch do? > > ie function x (int $x) { echo is_int ($x); } x ("5"); > > > > Thanks, > Paul > > >> It should be noted that this is not the first idea for type hints, >> that >> credit goes to Hannes Magnusson who had posted a similar patch on the >> internals list back in 2006. Also, back in 2008 Felipe Pena wrote a >> type >> hinting patch for PHP that is available on wiki.php.net. >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > > -- > Paul Biggar > paul.biggar@gmail.com