Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37004 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60592 invoked from network); 14 Apr 2008 16:56:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2008 16:56:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:22406] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 33/B9-11147-8AC83084 for ; Mon, 14 Apr 2008 12:56:12 -0400 Received: from us-ex1.zend.com ([192.168.16.5]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 14 Apr 2008 19:56:48 +0300 Received: from [192.168.16.217] ([192.168.16.217]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 14 Apr 2008 09:56:45 -0700 Message-ID: <48038C9F.7010806@zend.com> Date: Mon, 14 Apr 2008 09:55:59 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: Christian Schneider CC: Chris Stockton , internals@lists.php.net References: <1207539695.5736.42.camel@pena> <8d7b8c130804062157j60871630r6c3b27c4d3245cb9@mail.gmail.com> <1207576676.5331.49.camel@felipe> <47FA507D.2070108@cschneid.com> <5CB53203-F3E5-46F2-89A8-F331B2CB9017@pooteeweet.org> <47FA60F8.7060702@zend.com> <37C655F0-D212-420C-9320-7953A69C5EDB@pooteeweet.org> <48036A0C.7070203@cschneid.com> In-Reply-To: <48036A0C.7070203@cschneid.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 14 Apr 2008 16:56:45.0103 (UTC) FILETIME=[854CBBF0:01C89E50] Subject: Re: [PHP-DEV] Return type hints From: stas@zend.com (Stanislav Malyshev) Hi! > Let me turn your question around: Why on earth would someone restrict a > function to int when string works just as well? > > function int foo_flexible(scalar $x) { return $x + 42; } > $foo = foo_flexible($value); Now let's think - what happens if $x is *not* scalar? So the real code would be like this: function foo_flexible(scalar $x) { return $x + 42; } if(!is_scalar($value)) { $foo = foo_flexible($value); } else { // ok, what do I do now? } And so for each instance. Ugly. > That said, I'll be using > function foo($x) { return $x + 42; } > anyway and let PHP warnings take care of the rest ;-) Amen to that. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com