Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37083 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4452 invoked from network); 17 Apr 2008 16:50:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2008 16:50:55 -0000 Authentication-Results: pb1.pair.com header.from=chrisstocktonaz@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=chrisstocktonaz@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.46.30 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: chrisstocktonaz@gmail.com X-Host-Fingerprint: 74.125.46.30 yw-out-2324.google.com Received: from [74.125.46.30] ([74.125.46.30:29100] helo=yw-out-2324.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B7/35-05127-CEF77084 for ; Thu, 17 Apr 2008 12:50:55 -0400 Received: by yw-out-2324.google.com with SMTP id 5so91339ywb.83 for ; Thu, 17 Apr 2008 09:50: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:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=65ANyYmklcikxSE25xpyeLWXNOq+/T0yXJyyJDHGluI=; b=d1fYrMSNO8HY81kAYH5z2cJp7ijFrsVkfzeTPjvme+qtAJ25DUIByLKiWcILd/Cfl6IXEpSjuxQq2aSPtIGR4FL4+eAerApj8TDW+OhSH4AVsp4+u37emFz8NGnqY1nFaR1FzM0/wbC4pQY3AW+GQ5ftSHokNDEzlu+YFKhmVSo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=b8nrxcUz+oXo5xgpy2y2/sxDrP6Y/PJ5kJMWrlKOHW7VHQZlC4Iyq85U1tj3X1ib9NZKxtPpUQOBfKi1/rMOPbJnTuK46Fa14G+S9mz1FekYVGZj0XG9InVUhoDZ521tp9YFBIOMnKKMM//M2tB2CWyhmpVkmdRQcCYREvYjIqI= Received: by 10.142.53.14 with SMTP id b14mr490860wfa.332.1208451048198; Thu, 17 Apr 2008 09:50:48 -0700 (PDT) Received: by 10.142.178.15 with HTTP; Thu, 17 Apr 2008 09:50:48 -0700 (PDT) Message-ID: Date: Thu, 17 Apr 2008 09:50:48 -0700 To: "Stanislav Malyshev" Cc: "Felipe Pena" , internals@lists.php.net In-Reply-To: <48077BD2.2000107@zend.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_842_22016530.1208451048177" References: <46ccd1ab0804170742g142ed562t4f03339da549a820@mail.gmail.com> <48077BD2.2000107@zend.com> Subject: Re: [PHP-DEV] [RFC] Strict type hints (parameter and return value) From: chrisstocktonaz@gmail.com ("Chris Stockton") ------=_Part_842_22016530.1208451048177 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Thu, Apr 17, 2008 at 9:33 AM, Stanislav Malyshev wrote: > Just for the record, I see absolutely no sense in strict type hints. While > there might be some use cases when you want to save typing by having > function convert the arguments instead of you doing it manually - there's > absolutely no sense to check types strictly in PHP, especially taking into > attention that no API ever worked that way, and that it would force users to > surround each call to such function with checks for argument types, since > PHP can not have static type control. Using such feature would be a > nightmare. You have a good point, but I think it might have slightly more benefit then we may think. Less code bloat for the checks many of us already enforce is one. Doing some greps in the Zend Framework is a good example. grep -riE -A2 "is_(binary|bool|double|float|int|long|null|numeric|object|real|resource|scalar|string|unicode)" * I get tons of parameter checks which throw exceptions, so users already have to check there code prior to sending it up the chain. And by "Check" a good framework, like Zend, will do the boundary checking for you, so as long as it is the right type you are ok. So: function foo($var) { if(!is_int($var)) { throw new exception('not int'); }} Turns to: function foo(int $bar) { } which is called like this in both cases, maybe with a try catch etc etc: foo((int) $baz['bar']); -Chris ------=_Part_842_22016530.1208451048177--