Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49452 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19027 invoked from network); 19 Aug 2010 09:26:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2010 09:26:19 -0000 Authentication-Results: pb1.pair.com header.from=nrixham@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=nrixham@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: nrixham@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-wy0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:39606] helo=mail-wy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9F/A1-10260-AB8FC6C4 for ; Thu, 19 Aug 2010 05:26:19 -0400 Received: by wye20 with SMTP id 20so2018237wye.29 for ; Thu, 19 Aug 2010 02:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=+VAg+xGOQKnoZBs+ChXE4BcM3oqOK5Kt0P4s1pkEcJo=; b=eZ+shS5q0dxThoZRGwFFTv1TGWtoPd3jipqBUc9DkUPjksOfW48XAV1KlsX0t9Vy1P 0u3S/sEtqUy2kGIaOIYPUxRuUpnPK9aNCiCksMznDp5FG4MtixYeGMgC8fkUdOks7o1c QYTt5zRnzsNjs2XgPHZz7rSzBdJ4xmFZKOHeQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=d87JMhgNKTPS7oUTmb0V61M5D1+KZsDPQaPbA/6K1v6iW9EMaH/EspYsYrZCelFGMA lVG37sIork16EqzniJOecXgb1LhmOB0vXM11/HIwGKcOPCatxwyFpbELDzRgw7s41l3M oGkTj+PWknSESIkLRFuYMpr0f+BWLunrjAcSI= Received: by 10.227.145.208 with SMTP id e16mr8074911wbv.164.1282209975944; Thu, 19 Aug 2010 02:26:15 -0700 (PDT) Received: from [192.168.1.69] (host86-169-12-34.range86-169.btcentralplus.com [86.169.12.34]) by mx.google.com with ESMTPS id b23sm844977wbb.22.2010.08.19.02.26.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 19 Aug 2010 02:26:14 -0700 (PDT) Message-ID: <4C6CF898.5060706@gmail.com> Date: Thu, 19 Aug 2010 10:25:44 +0100 User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: =?UTF-8?B?Sm9oYW5uZXMgU2NobMO8dGVy?= CC: Stas Malyshev , Dave Ingram , PHP Internals References: <4C6CE273.2070501@sugarcrm.com> <4C6CE604.1010209@dmi.me.uk> <4C6CE793.1020601@sugarcrm.com> <1282206735.2561.11.camel@guybrush> In-Reply-To: <1282206735.2561.11.camel@guybrush> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] inheritance check too strict? From: nrixham@gmail.com (Nathan Rixham) Johannes Schlüter wrote: > On Thu, 2010-08-19 at 01:13 -0700, Stas Malyshev wrote: >> Hi! >> >>> I was under the impression that, in order for inheritance to provide >>> proper polymorphism, overridden methods should share the parent's method >>> signature, although they can have additional optional arguments. >> Your impression is wrong. Overriden method should have _compatible_ >> signature - i.e. accept any argument set that parent object accepted. >> Nothing requires it to have the same signature. > > Let|s take a look at making it one step more complex: > > class A { > public function foo(Foo $a = null) {} > } > > class B extends A { > public function foo() {} > } > > class C extends B { > public function foo(Bar $a = null) {} > } > > Here B::foo() is compatible with A:foo() and as the parameter is > optional C::foo() is compatible with B::foo(). But C::foo() is no more > compatible with A::foo(). > > So I consider the message good and correct. what if Bar implements Foo, or Bar extends Foo - surely that should be compatible given the inheritance chain.