Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44630 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91810 invoked from network); 2 Jul 2009 09:26:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jul 2009 09:26:52 -0000 Authentication-Results: pb1.pair.com header.from=ionut.g.stan@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ionut.g.stan@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: ionut.g.stan@gmail.com X-Host-Fingerprint: 209.85.218.206 mail-bw0-f206.google.com Received: from [209.85.218.206] ([209.85.218.206:45360] helo=mail-bw0-f206.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BE/55-65216-A5D7C4A4 for ; Thu, 02 Jul 2009 05:26:51 -0400 Received: by bwz2 with SMTP id 2so924161bwz.23 for ; Thu, 02 Jul 2009 02:26:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=QoL7c7Vg8GxzNrMX1hnybZrqG3DzuViNEaH5Bne0tes=; b=p9j7Oow5xim4od+diRD+dDTt/js+ar0w+qtyG/6HLvM6vupyWjvzscJmDGQE+rUt3M 6m9c6w4fE3lzCtt3H119T7LiOH59PLmyL2RUAlf5fMBHoZfgXZ32n6NJmjr0SUTR7Abc 3Nz5bvr8S6ciVcNrcAYXDaYO/mNUyiDF44veM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; b=QaVl2/Yv36m4pj9IJJauvReUr6n/FNG79TNvRKwEXdBNEbfxpuesZ9ukJpdAEpjvf7 KcdDRpF0/9a53hhZwVwHze56O+WNYqS+DlJ8WNOYyVtw2I84h69v6g1XLc/JkR/WPRUc k8pzztx4nJdx3XUZcmc1LvpPQSG5JdwEqnVhk= Received: by 10.103.197.14 with SMTP id z14mr6187453mup.92.1246526806864; Thu, 02 Jul 2009 02:26:46 -0700 (PDT) Received: from ?10.0.0.187? (mail.cmbtravel.ro [84.234.105.22]) by mx.google.com with ESMTPS id s10sm10441113muh.57.2009.07.02.02.26.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 02 Jul 2009 02:26:46 -0700 (PDT) Message-ID: <4A4C7CE6.6070107@gmail.com> Date: Thu, 02 Jul 2009 12:24:54 +0300 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b3pre) Gecko/20090223 Thunderbird/3.0b2 MIME-Version: 1.0 CC: PHP internals References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3 From: ionut.g.stan@gmail.com ("Ionut G. Stan") Hi, I'm a userland developer with limited C skills, and while I don't yet have an opinion on the whole type enforcing issue, aside from a fear of libraries abusing it, I'd like to propose a little change in the patch. Is it possible that instead of an E_RECOVERABLE_ERROR, an Exception to be thrown? I don't know whether InvalidArgumentException satisfies the semantics, but it's a step in that direction. On 7/1/2009 19:59, 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 nature (most people expect that "1" == 1, > while int type hint would definitely reject string "1"). Personally, > 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 code much easier to > read and understand and the security benefit of type hinting 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 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. -- Ionut G. Stan I'm under construction | http://igstan.blogspot.com/