Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49453 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22507 invoked from network); 19 Aug 2010 09:42:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2010 09:42:30 -0000 Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:37891] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4E/42-10260-48CFC6C4 for ; Thu, 19 Aug 2010 05:42:29 -0400 Received: by vws18 with SMTP id 18so98660vws.29 for ; Thu, 19 Aug 2010 02:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=NDpVs/tzJooDQU7N2e42MWuy2wpsMea9S2+VoXMw8aQ=; b=i8rr3s652jOeWKpnrGKpXr2SuOwBxxjcp4VRjE1v39bC0gmBb+IdVfXHgldG8fVbOf CmEpW0UnyuN8gehtKQmahe81N4GtJiKT7ukumGkfvRKv9uEhtxumbkGGqT2tV9HY3jXr tnoKiOHO42pAeDO6538o377vrDxmXywmDNoBU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=h0AT0B0/YWu8yGq8qDBqi5bHWAb4+h60CNX5jzWdHi6GYzh72RALCXGX9/gIH0T5fz bEAk1XJQ2MLa5ZhEPtZ7PTZoaeLrzDWnolspqPibcrBgNdaRt13/qvoC9MRaVF75xae6 xWnBOt9fPJLxhWBhzHtfmSk7RJHK1l/Lm9Ke4= MIME-Version: 1.0 Received: by 10.220.62.136 with SMTP id x8mr5809228vch.177.1282210946508; Thu, 19 Aug 2010 02:42:26 -0700 (PDT) Sender: tjerk.meesters@gmail.com Received: by 10.220.50.165 with HTTP; Thu, 19 Aug 2010 02:42:26 -0700 (PDT) In-Reply-To: <1282206735.2561.11.camel@guybrush> References: <4C6CE273.2070501@sugarcrm.com> <4C6CE604.1010209@dmi.me.uk> <4C6CE793.1020601@sugarcrm.com> <1282206735.2561.11.camel@guybrush> Date: Thu, 19 Aug 2010 17:42:26 +0800 X-Google-Sender-Auth: Yre5oK1InNDRah9EAQvq1qe8TAU Message-ID: To: =?ISO-8859-1?Q?Johannes_Schl=FCter?= Cc: Stas Malyshev , Dave Ingram , PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] inheritance check too strict? From: datibbaw@php.net (Tjerk Anne Meesters) 2010/8/19 Johannes 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 meth= od >> > 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 { > =A0 =A0public function foo(Foo $a =3D null) {} > } > > class B extends A { > =A0 =A0public function foo() {} > } > > class C extends B { > =A0 =A0public function foo(Bar $a =3D 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. I suppose, when it comes to optional parameters, one can't rely on the transitive nature of class extension validity. You would need to iterate the definition chain of this method until it hits the signature that actually defines the "type" of the parameter(s) before throwing any messages. In my opinion as a regular developer, B::foo() would make a valid signature. > > johannes > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 -- Tjerk