Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49451 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8032 invoked from network); 19 Aug 2010 08:32:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2010 08:32:34 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.211.66 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.211.66 unknown Solaris 10 (beta) Received: from [217.114.211.66] ([217.114.211.66:33449] helo=config.schlueters.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/31-04318-61CEC6C4 for ; Thu, 19 Aug 2010 04:32:24 -0400 Received: from [192.168.1.31] (ppp-93-104-119-47.dynamic.mnet-online.de [93.104.119.47]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by config.schlueters.de (Postfix) with ESMTPSA id 6D334443D0; Thu, 19 Aug 2010 10:32:19 +0200 (CEST) To: Stas Malyshev Cc: Dave Ingram , PHP Internals In-Reply-To: <4C6CE793.1020601@sugarcrm.com> References: <4C6CE273.2070501@sugarcrm.com> <4C6CE604.1010209@dmi.me.uk> <4C6CE793.1020601@sugarcrm.com> Content-Type: text/plain; charset="UTF-8" Date: Thu, 19 Aug 2010 10:32:15 +0200 Message-ID: <1282206735.2561.11.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.2 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] inheritance check too strict? From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) 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. johannes