Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44638 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20924 invoked from network); 2 Jul 2009 12:26:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jul 2009 12:26:19 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.220.224 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 209.85.220.224 mail-fx0-f224.google.com Received: from [209.85.220.224] ([209.85.220.224:41128] helo=mail-fx0-f224.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 07/E0-16153-967AC4A4 for ; Thu, 02 Jul 2009 08:26:18 -0400 Received: by fxm24 with SMTP id 24so1604900fxm.23 for ; Thu, 02 Jul 2009 05:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=SIzSdpmAtc0BqsbekduJo5nKdcVFbJVgRnfoPhyFNpQ=; b=ZynzOMddTpiBH0XV62rrqlqtws/Ow3whMJXwAT24oWACS9MpAdkyxuRDwKDu9TPHky IK/NVS38+jYZhwDmyqY8C5VLrAQLtgnKTCKjfBJgw7Wa3c0gZCKKbMW2qmQKIEUEn/MK snWgCHjDpggEy13QgFRCHTLXRKi1H0ficbutE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=GzlMQGRArvHTWOoYkaFfRw2JaP52QwHV2oEQgJ0g4Y96TBgiBPd5bj5rGvBjhnyg2d R1fgQlgPpZOCvfbfpysM2ETGn2Xyw6uZ1luwFfKmDXWQoSxIoSBNF3lMRvI9IBE+NcfI KvLAr0sAOahKTU+DO394OWUielkBkfwon4KxY= MIME-Version: 1.0 Received: by 10.223.112.204 with SMTP id x12mr7080204fap.70.1246537574121; Thu, 02 Jul 2009 05:26:14 -0700 (PDT) Reply-To: RQuadling@googlemail.com In-Reply-To: <4A4BA5C8.1020204@zend.com> References: <4A4BA5C8.1020204@zend.com> Date: Thu, 2 Jul 2009 13:25:54 +0100 Message-ID: <10845a340907020525x786a196dv4959d522675ca6eb@mail.gmail.com> To: Stanislav Malyshev Cc: Ilia Alshanetsky , 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: rquadling@googlemail.com (Richard Quadling) 2009/7/1 Stanislav Malyshev : > Hi! > >> The patch is available here: http://ia.gd/patch/type_hint_53.txt > > Technical comment: as this patch changes binary API this shouldn't happen= in > 5.3 branch. So maybe it's better to make it for 6. > > As for the idea itself, it is obvious that many people like it, I would j= ust > note that it would produce a confusion for some people due to the fact th= at > true, 1, 1.0, b'1' and '1' now become incompatible values and (once you > start using typehints, of course) you'd have to explicitly convert them. > That would lead people to stuff their code with explicit type conversions= , > which doesn't add to code cleanness. This also means that internal functi= ons > and user functions would behave differently with regard to type conversio= ns. > -- > Stanislav Malyshev, Zend Software Architect > stas@zend.com =C2=A0 http://www.zend.com/ > (408)253-8829 =C2=A0 MSN: stas@zend.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Doesn't "stuff their code with explicit type conversions" actually mean "perform appropriate validation and conversion on incoming data" ? The majority of data that a program gets is either from a DB (and if ALL your columns are varchars, well, I give up and a xxx_fetch_row SHOULD cast to an appropriate type in my mind, but ...), from a config file (normally all strings), $_xxx (normally all strings). Internal values are inherently cast. How many people write ... $some_boolean =3D "1"; // Set some_boolean flag to true. No, they write ... $some_boolean =3D true; // No need to document anything here as the code is pretty much speaking for itself. We are constantly told about GIGO and not accepting anything a user supplies as safe, so, with that in mind, you validate the incoming data (one way is to cast to the valid type and then check ranges, etc.) and from then on everything is in the appropriate type. PHP's type juggling is useful, without a doubt. But it seems to be limited to 2 areas. 1 - Casting to strings for output. 2 - Casting to boolean for equality testing. So they don't "perform appropriate validation and conversion on incoming data", then you will end up with having to "stuff their code with explicit type conversions". That's something I'm prepared to live with. So. A big +1 from me to incorporate type hinting into PHP. Regards, Richard Quadling. --=20 ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474= 731 "Standing on the shoulders of some very clever giants!" I need a car : http://snipurl.com/l4pih ZOPA : http://uk.zopa.com/member/RQuadling