Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44677 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50609 invoked from network); 3 Jul 2009 10:31:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jul 2009 10:31:12 -0000 Authentication-Results: pb1.pair.com header.from=david.coallier@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=david.coallier@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.206 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: david.coallier@gmail.com X-Host-Fingerprint: 209.85.218.206 mail-bw0-f206.google.com Received: from [209.85.218.206] ([209.85.218.206:38946] helo=mail-bw0-f206.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D8/AB-27980-EEDDD4A4 for ; Fri, 03 Jul 2009 06:31:11 -0400 Received: by bwz2 with SMTP id 2so1681712bwz.23 for ; Fri, 03 Jul 2009 03:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=q6x0MCOTfuYsGVxJ2/WJQ+NMbayboCy0EVY4w646X7Y=; b=T+rgXlL/JZ5R4bxsGIkF/uXLd+23fuRq8v685vtmFd9kQlvDNM4HB/+VGbp0MbX+mY p3g8D+SEJY2xIEAlLbfsXVb/hQdU1eFb239qk+ApVbihqbJfNyhWb9ef5azkyfrQkG6Q GRu/8rj74OU6rf8oHVVK1gWULf2Cb/IlRv3CE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=XgJH+GDmYK/aztx9Cexty/KZuGu+SQ0fdP4uOk7anfXk+LefWTWdlHoSXY8ByJ12WQ MMWPY7LiC1gy2mLPTgrFm7e4AsusJZiwFQz9Y6EX6e8sVA/orOHGNnSjRbZCElJ+IgGz sfuUL0XeOB3bipZ7GjMPlgvALXFFGMnElDtQg= MIME-Version: 1.0 Sender: david.coallier@gmail.com Received: by 10.204.60.72 with SMTP id o8mr1102903bkh.184.1246617066110; Fri, 03 Jul 2009 03:31:06 -0700 (PDT) In-Reply-To: References: Date: Fri, 3 Jul 2009 11:31:05 +0100 X-Google-Sender-Auth: d8b8d68c281d3ec0 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: davidc@php.net (David Coallier) 2009/7/1 Ilia Alshanetsky : > 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. Brilliant stuff Ilia! One thing I noticed in the patch is: "+("string"|"binary"|"unicode") { + return T_STRING_HINT; +} " which makes sense if we keep for PHP6 but doesn't for 5_3 which afaik doesn't have (unicode) casting yet :) I think that's nitpicking I agree and I just want to make sure that this doesn't become a documentation issue for people who'd think you can hint using unicode or even see article saying you can hint with unicode. Makes sense for PHP6 though but since you merged your patch from 5.2 I figured I could ask :) Apart from that this is awesome and am I glad that we are not trying to cast automatically! +1 --=20 Slan, David