Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34369 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69923 invoked by uid 1010); 3 Jan 2008 23:07:53 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 69907 invoked from network); 3 Jan 2008 23:07:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2008 23:07:53 -0000 Authentication-Results: pb1.pair.com header.from=pstradomski@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=pstradomski@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 72.14.220.158 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pstradomski@gmail.com X-Host-Fingerprint: 72.14.220.158 fg-out-1718.google.com Received: from [72.14.220.158] ([72.14.220.158:54880] helo=fg-out-1718.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 32/72-20810-7CA6D774 for ; Thu, 03 Jan 2008 18:07:52 -0500 Received: by fg-out-1718.google.com with SMTP id 22so3092710fge.23 for ; Thu, 03 Jan 2008 15:07:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:reply-to:to:subject:date:user-agent:cc:references:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; bh=2qO8pei0pQ1SG3ICrpFLbkLtvoQLHgqFflPMWOI6F/w=; b=wk/VUrYWjXTX9mn6BtVAmbpD7OxW+z8U2Jhe61JyFe7NE7NDMV6PYey6sQP43j0xPdHjlAQ81fll6QIdCmTX43TZcFwtJopyYxClzYiJXXDy5l3gC8AmNS6zR4VePDzQWw9jqDFzcRsPQQzfTFO+A3ZGvhA2+YA90oWGD6nDdCM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:reply-to:to:subject:date:user-agent:cc:references:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; b=echlx9azb/vG/aebSWHUzOOc7NpXRJVz+kPwn5Aol0hur8iMNggEdgplbWpFbfqUEwXPGRIOk+q/YWS0FvIILRSiIFUUc+UK7cdh5SSB6wav8Brtzbdgm9g7GopVp4d+JZtub9EC49Fizp8T8Ag3js6Q0GE1Sb2uDDicYYeWh/4= Received: by 10.82.177.3 with SMTP id z3mr28598912bue.35.1199401668688; Thu, 03 Jan 2008 15:07:48 -0800 (PST) Received: from charon ( [91.196.215.2]) by mx.google.com with ESMTPS id c5sm2603063nfi.2.2008.01.03.15.07.46 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Jan 2008 15:07:47 -0800 (PST) Reply-To: =?utf-8?q?Pawe=C5=82_Stradomski?= To: internals@lists.php.net Date: Fri, 4 Jan 2008 00:08:43 +0100 User-Agent: KMail/1.9.7 Cc: Stanislav Malyshev References: <200801031903.01980.tomi@cumulo.fi> <477D66B4.2000107@zend.com> In-Reply-To: <477D66B4.2000107@zend.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-ID: <200801040008.43944.pstradomski@gmail.com> Subject: Re: [PHP-DEV] RE: Optional scalar type hinting From: pstradomski@gmail.com (=?utf-8?q?Pawe=C5=82_Stradomski?=) W li=C5=9Bcie Stanislav Malyshev z dnia czwartek 03 stycznia 2008: > > type-hinting is asserting. > > checking of types is needed only on interface-border points (where > > With strict checking, that means instead of calling: > foo($bar); > you'd have now to do: > if(is_integer($bar)) { > // stupid foo() call would blow up if passed not integer, so I have > to manually handle it > // oh wait, actually I don't have any way to handle it - I need > foo() to be called to proceed > // so let's just > die("can't call foo() because \$bar is not integer"); > } > foo($bar); > This code is just a good argument *FOR* type hints. When foo is: function foo(int $bar) {...} and you want the code to die if $bar is not integer, then foo($bar) would b= e=20 the way to go, without the need for the mess you posted. And if you know th= at=20 you have either an int or string representing an integer in $bar, then=20 foo((integer)$bar) would work just well. The only problem with the cast is that (integer)'abc' is 0, but it has been= so=20 for a long time and there is no need to change it. is_numeric check solves= =20 the problem. =2D-=20 Pawe=C5=82 Stradomski