Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81949 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38058 invoked from network); 5 Feb 2015 17:34:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2015 17:34:30 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.177 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.192.177 mail-pd0-f177.google.com Received: from [209.85.192.177] ([209.85.192.177:41883] helo=mail-pd0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/E5-27691-5A9A3D45 for ; Thu, 05 Feb 2015 12:34:29 -0500 Received: by pdiy13 with SMTP id y13so9022385pdi.8 for ; Thu, 05 Feb 2015 09:34:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=YpI1IbfFbURO4HckhalF4twFo2YjpKPe4RhwtND3z8s=; b=ZFPUPbWEYnCn34TYE3JNfrFjLJjib8Gd9R1nPCT+Rsdw8/ny0W7wUgzNtyeYTzXwS1 Z7J2YUjxuD0DQJezoOl/tCgqLBOjHq0e3oXorgGptZOARw/Eu1pogoWazVnLwyxotd+3 7c7ivlwE7KTESfMUNj/Ht5KqfpZOlB9FM0tHnT9ljVCyTUWI0vB+Ua+ZPmfkcegTrJSQ GORfUMw2zoXLpduF5AjcvSTfAtRnBzZJiuzoHXZHfpgi9zqPBBs6GLmnxMPCMv1JAqQt ShD9gBC8jQWp+4Q8ZSTGGPjwZhf4n1zQJ9UnsIWFR7xVPhJIY86xFgb3bCKn/cY61cbS 160A== X-Received: by 10.66.154.196 with SMTP id vq4mr7351701pab.146.1423157665713; Thu, 05 Feb 2015 09:34:25 -0800 (PST) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id oe5sm5651408pbc.33.2015.02.05.09.34.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Feb 2015 09:34:25 -0800 (PST) Message-ID: <54D3A994.9050005@gmail.com> Date: Thu, 05 Feb 2015 09:34:12 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Julien Pauli , Andrea Faulds CC: Hannes Magnusson , Nikita Popov , PHP internals References: <4A36329B-F17B-4665-A84E-D8CF01F5B29A@ajf.me> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Allow dropping typehints during inheritance From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > If we allow larger type, why doesn't such code work ? > > interface A { } > interface B extends A { } > > class C { > public function foo(A $a) { } > } > > class D extends C { > public function foo(B $a) { } // E_STRICT > } > > This is wrong IMO. This shouldn't work - it means that if you have D object, you should be able to call foo on it with any A parameter. However, your definition says not every A parameter would work, but only one that is actually B (i.e. class that implements A but not B is not going to work anymore). That means D violates C's contract by rejecting some calls that C accepted. -- Stas Malyshev smalyshev@gmail.com