Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49328 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5127 invoked from network); 11 Aug 2010 13:30:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2010 13:30:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=arvids.godjuks@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=arvids.godjuks@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: arvids.godjuks@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:54819] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 39/60-01618-9D5A26C4 for ; Wed, 11 Aug 2010 09:30:03 -0400 Received: by vws18 with SMTP id 18so96158vws.29 for ; Wed, 11 Aug 2010 06:29:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=EF3pmXvbo4Em/SmpoZXsonMZq5O7koBBTX0SjC2v+Ww=; b=N0sQ/Lpr25M0UnxpQx9w7R2w7TMi16/qLRfzy0/M6If5gDp4Bu9dWir38ts67gdY0q x9uIKzyjVO4GBzFi1DdgCH1jZpbzA/yCbQiqp7HiuADmPhZ2PZ3aPVh/+4NnX7WL2QHl ni9nsVjBGkSN86c6KZVbbf+6P3LdX3Y5y0yBs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=JS4RqR58FkVWNLH8vf8XwzqM+Ubn/ekfsyg701L9FndxcuOLJy6Sx56H7UCVEGjLFS rV4EGTOm9LC6oav4gQzOBswoTU1OwBn0sU3lkzKWr6MyVfnrGzDAGmAxAUUrLzSeknSA kgxaJeHUUfr5AOVjcaiONp8P1ysxT51nGy2/c= MIME-Version: 1.0 Received: by 10.220.121.206 with SMTP id i14mr3776053vcr.141.1281533398672; Wed, 11 Aug 2010 06:29:58 -0700 (PDT) Received: by 10.220.98.148 with HTTP; Wed, 11 Aug 2010 06:29:58 -0700 (PDT) In-Reply-To: References: <1281478269.6608.292.camel@guybrush> <4C61D6FB.6030108@sugarcrm.com> <7.0.1.0.2.20100811085214.0f024300@zend.com> Date: Wed, 11 Aug 2010 16:29:58 +0300 Message-ID: To: Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Strict typing (was: Typehints) From: arvids.godjuks@gmail.com (Arvids Godjuks) 2010/8/11 Ilia Alshanetsky : > I think that weak type-hinting defeats the whole purpose of the > feature and I would rather not have it than have a non-obvious > implementation. > > -1 > I would like to point out an argument, posted in the "Typehints (was Re: [PHP-DEV] Annoucing PHP 5.4 Alpha 1)" thread by Jonathan Bond-Caron, quoting: "It's only consistent in the function declarations but *completely* inconsistent with how the rest of the language works." He took the words out of my mouth. The auto-convert feature only touches the idea that 1 => "1", "1" => 1 conversions should take place automatically. In the case of "abcd" => 0 we emit an error message. As it was mentioned in the RFC, the idea is not only to make type hint's this way, but _also_ to change the language conversion rules acordingly to match the type hinting auto-conversion rules. That way the conversion rules are made more strict and type hints get some freedom instead of going into E_FATAL everytime a developer misses string to int (and other similiar) conversion in the code before passing data to objects/functions/API. The conversions don't just go completly silent if inapropriate value is passed to the function/method witch can't be converted transparently to the required type. It gives you the error message and it's your choise to ignore it or fix it. Strict type hintng will just bring tons of code that does: settype('integer', $total); settype('integer', $per_page); settype('integer', $page); pager($page, $total, $per_page); It will have to be written to make sure the variables have the right type. Especially $page, witch usually comes via $_GET. Instead of just checking for is_numeric now we have also to convert the type. I just have an empression that you don't write much PHP code or you work on very big and highly sophisticated projects, where the situation is different. You leaving out the majority of PHP code written for the middle and small scale projects, witch usually done by far more simplier tools, sometimes even just using the plain old PHP without a framework (and yes, sometimes it's just faster that way!).