Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57006 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1305 invoked from network); 22 Dec 2011 15:43:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Dec 2011 15:43:32 -0000 Authentication-Results: pb1.pair.com header.from=will.fitch@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=will.fitch@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) X-PHP-List-Original-Sender: will.fitch@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:59209] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5C/A4-12618-32053FE4 for ; Thu, 22 Dec 2011 10:43:31 -0500 Received: by qcsd16 with SMTP id d16so5431451qcs.29 for ; Thu, 22 Dec 2011 07:43:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=9zHUSyJzM2EM8wf3PKTc92ZdFyB/LlX/Ow6K5xNlDNc=; b=Ix492VRMku0SKi3Bqbg7s5B3o9hGwhRuP9ub99xdz800ipFW1k/VgSw55SpMalu4fq 9kaOxseUAaHPdD001V/KDOQtck2B/VE2Ud6ZK++BzgZez8qMFfU9uFuZlqM7WTkvTG1H i/il8Kmz5qgEWEamSofjBYVWbAmhZeNlxB17s= Received: by 10.229.78.155 with SMTP id l27mr4200447qck.38.1324568608686; Thu, 22 Dec 2011 07:43:28 -0800 (PST) Received: from [192.168.1.68] ([68.64.144.221]) by mx.google.com with ESMTPS id df3sm18010846qab.6.2011.12.22.07.43.23 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Dec 2011 07:43:24 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii In-Reply-To: <792BD425-1447-4FF3-8ED1-8C8701662432@inbox.lv> Date: Thu, 22 Dec 2011 10:43:23 -0500 Cc: "Dmitri Snytkine" , "'Nikita Popov'" , "'Alain Williams'" , Content-Transfer-Encoding: quoted-printable Message-ID: 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> <20111222145159.GY25857@alliantinternet.com> <006101ccc0ba$46b81160$d4283420$@alliantinternet.com> <006801ccc0bc$04e876b0$0eb96410$@alliantinternet.com> <792BD425-1447-4FF3-8ED1-8C8701662432@inbox.lv> To: Oleg Oshmyan X-Mailer: Apple Mail (2.1251.1) Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC From: will.fitch@gmail.com (Will Fitch) On Dec 22, 2011, at 10:18 AM, Oleg Oshmyan wrote: >> public function \Customer getCustomer(){ >> return $this->customer; >> } >>=20 >> If the $customer instance variable is not declared with the type = Customer >> then first of all IDE will not be able to spot an error, second = compiler may >> have a slighly harder time of detecting a mismatch. >=20 > The compiler does not even try to detect a mismatch; type hinting is > taken into account at run-time only. So whenever this function = executes, > if it tries to return a value that is not a \Customer, a run-time = error > will be reported. The only exception is implementing an interface that defines a returned = type hint. This is detected at compile time but only to the point that = the implemented method prototype is the same type hint. If it is not, = an E_COMPILE_ERROR is raised. The runtime error raised is an = E_RECOVERABLE_ERROR. >=20 > --=20 > Oleg > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20