Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57044 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96834 invoked from network); 23 Dec 2011 00:14:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Dec 2011 00:14:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.133 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.133 smtp133.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.133] ([67.192.241.133:57505] helo=smtp133.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/60-28504-BF7C3FE4 for ; Thu, 22 Dec 2011 19:14:51 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp23.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 124F52F8330; Thu, 22 Dec 2011 19:14:48 -0500 (EST) X-Virus-Scanned: OK Received: by smtp23.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 9CAD02F818F; Thu, 22 Dec 2011 19:14:47 -0500 (EST) Message-ID: <4EF3C7F7.9010404@sugarcrm.com> Date: Thu, 22 Dec 2011 16:14:47 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Will Fitch CC: =?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?= , PHP Developers Mailing List References: <2095305E-D4E3-4D7E-8218-32EE99688E0C@GMAIL.COM> <2C90FB94-38C4-4270-8C6A-B89304BA8ED8@gmail.com> <159A7CA2-8561-40DA-9434-CAAE12304DDB@gmail.com> <4EF3B56A.4040809@gmail.com> <-2451498990672032588@unknownmsgid> <4EF3BD21.2040301@sugarcrm.com> <-6952580475866195972@unknownmsgid> In-Reply-To: <-6952580475866195972@unknownmsgid> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > Are you suggesting not allowing null to be returned, or provide an > indicator within the syntax that it may return null? PHP would be the > first language I'm aware of that would do so in either case. No I am not suggesting that. I'm just pointing out the problems with the concept of strict typing in PHP and this particular instance of it. One of them is that many functions do not actually return one type but multiple types depending on the result. It is a very common pattern. BTW, which languages you are talking about? PHP peers - Python, Ruby, Perl, Javascript (to some measure), etc. don't have typing as far as I know. Comparing PHP to statically compiled strictly typed languages does not seem very useful to me. So could you clarify what do you mean? > The point isn't to restrict a type hint to always be returned. The > goal is to guarantee that if a value is returned, it will be of type > X. In the event it is inappropriate to return the value back, would All functions in PHP return values, so it is not possible that no value would be returned (yes, if you don't return anything it actually will return null). So ensuring something is an object of type X prevents you from returning anything else, false/null included. If you make exceptions for null, then why not for false? If for false, then why not for true? Etc. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227