Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44622 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64587 invoked from network); 2 Jul 2009 07:31:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jul 2009 07:31:45 -0000 X-Host-Fingerprint: 92.254.21.251 unknown Received: from [92.254.21.251] ([92.254.21.251:22118] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/02-54262-0626C4A4 for ; Thu, 02 Jul 2009 03:31:44 -0400 Message-ID: To: internals@lists.php.net References: In-Reply-To: Date: Thu, 2 Jul 2009 09:31:37 +0200 Lines: 49 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6001.18000 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049 X-Posted-By: 92.254.21.251 Subject: Re: Type hinting revisited for PHP 5.3 From: peter@lvp-media.com ("Peter Beverloo") Hello, For what it's worth, a large +1 from me. One concern I do have, however, is that the addition of scalar type hints will put more attention to the lack of method overloading. Right now methods can accept multiple values due to the type-lessness, and while it will remain a possibility, code with type-hints usually is a lot clearner. To demonstrate: class Example { public function setValue (int $value) {} public function setValue (string $value) {} } While there are two obvious solutions for this (not using type-hinted parameters and using setIntValue/setStringValue) I think inclusion of a patch like this would be a good moment to overthink overloading like this. Peter "Ilia Alshanetsky" wrote in message news:FC14FAFE-6785-4067-9B49-9FC14F159C52@prohost.org... > 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. > > The patch is available here: http://ia.gd/patch/type_hint_53.txt > > It should be noted that this patch is fully compatible with opcode caches > and and requires no changes on the part of an opcode cache such as APC to > work. > > My hope is that the latest changes will allow this to become a standard > part of PHP. > > Ilia Alshanetsky > > P.S. > > 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.