Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57008 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26433 invoked from network); 22 Dec 2011 18:39:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Dec 2011 18:39:11 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.163 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.163 smtp163.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.163] ([67.192.241.163:45572] helo=smtp163.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/19-12618-E4973FE4 for ; Thu, 22 Dec 2011 13:39:10 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp16.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id E746740888; Thu, 22 Dec 2011 13:39:07 -0500 (EST) X-Virus-Scanned: OK Received: by smtp16.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id E0F9D408D9; Thu, 22 Dec 2011 13:39:06 -0500 (EST) Message-ID: <4EF3794A.8010405@sugarcrm.com> Date: Thu, 22 Dec 2011 10:39:06 -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: Dmitri Snytkine , 'Pierre Joye' , 'Nikita Popov' , '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> <005701ccc0b3$58c8dee0$0a5a9ca0$@alliantinternet.com> <68E7B0B2-6D57-4496-BD0E-7C6876460351@gmail.com> In-Reply-To: <68E7B0B2-6D57-4496-BD0E-7C6876460351@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > That said, PHP is not Java, and type hinting in PHP is very > different. It is, in fact, type *hinting*. This is a runtime > feature. Only interface validation is verified at compile time, so > we have to consider performance vs. feature in these cases. Naming it "hinting" was probably the worst mistake in PHP documentation since "safe mode". The word hinting implies it's just something non-mandatory, that can be used if needed, but ignored if not. While using typing is indeed not mandatory, once used, it *is* mandatory check that can not be ignored and produces fatal error in case of mismatch. The only difference is that in Java this error is detected in compile time, while in PHP it is a runtime failure, usually taking down the application in the middle of processing, without possibility of proper recovery. I'm not sure we're having the better deal here. Performance is irrelevant here, more or less, since typing checks won't take much time unless you have insanely deep class hierarchies (you have to compare object's class and probably his parents' to the prescribed type). Stability and maintainability of such code is an issue. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227