Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44679 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83273 invoked from network); 3 Jul 2009 13:13:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jul 2009 13:13:47 -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 72.14.220.154 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: 72.14.220.154 fg-out-1718.google.com Received: from [72.14.220.154] ([72.14.220.154:58855] helo=fg-out-1718.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 13/A2-27980-A040E4A4 for ; Fri, 03 Jul 2009 09:13:47 -0400 Received: by fg-out-1718.google.com with SMTP id e12so711474fga.0 for ; Fri, 03 Jul 2009 06:13:44 -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=PF3G8LSeZGYwWKj0xIdNJ7w5K60gegXAYvPZXlOhvh4=; b=XU6JxLoVelDWqsoeJNFHAZXsni4kzx7HnlkefDiASUP9xE7pn4R+fE2GHJAzQJ4Rx6 j3GHg6vVIZRptu8UqYrZYCgXL6ErzuQm8ODlM8SIyEKqaIfGK8Ha38KX71IzLAoG7Gv2 nfkuaPJmHts63fkHulE1kVPZGyGP7h9A4lO2A= 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=jrzZpdDqj5v5dPG5u9e9Q0fiYS8S/PYeZtX4OG3nLTUZLnUclippwiJyHHePQoduZq XBx46qOO+0WWiKqpBh5HSgec8neQW2BfS11Ct2xMbDepsRxC/C6U2Kb8tB/GIYReNnDJ nj/FYAV3SIY3SaSdO93/aqEV+YAFpLnLVt1cE= MIME-Version: 1.0 Received: by 10.86.84.12 with SMTP id h12mr1022669fgb.21.1246626823060; Fri, 03 Jul 2009 06:13:43 -0700 (PDT) In-Reply-To: References: Date: Fri, 3 Jul 2009 14:13:23 +0100 Message-ID: To: Ilia Alshanetsky Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3 From: paul.biggar@gmail.com (Paul Biggar) Hi Ilia, Your patch doesn't support a "null" (or maybe it should be called "unset") type check. Its uses would be rare, but I think it should be present for completeness. Thanks, Paul On Wed, Jul 1, 2009 at 5:59 PM, Ilia Alshanetsky wrote: > There has been quite a bit of discussion on this list, IRC, developer > meetings, etc... about introduction of type hinting to PHP. Most people > appear to think that this would be a good idea, but there is a reason why= it > is not in PHP already. The main source of conflict appears to be that in > some cases typical type hinting is just too strict for PHP's typeless nat= ure > (most people expect that "1" =3D=3D 1, while int type hint would definite= ly > reject string "1"). =C2=A0Personally, I disagree with that opinion, but I= can > understand people who raise that issue. At work we've been using PHP 5.2 > with type hinting for nearly 2 years now with great success, it makes cod= e > much easier to read and understand and the security benefit of type hinti= ng > is not to be under valued. In many cases type hinting can present a last > line of defense against unexpected input for numeric fields, which are > typically abused to do SQL injection. > > 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 th= at > 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 p= art > 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. > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 Paul Biggar paul.biggar@gmail.com