Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49457 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76882 invoked from network); 19 Aug 2010 15:15:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2010 15:15:04 -0000 Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.185 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 212.25.124.185 il-mr1.zend.com Received: from [212.25.124.185] ([212.25.124.185:57351] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/58-28424-77A4D6C4 for ; Thu, 19 Aug 2010 11:15:04 -0400 Received: from il-gw1.zend.com (unknown [10.1.1.21]) by il-mr1.zend.com (Postfix) with ESMTP id B829A5048D; Thu, 19 Aug 2010 18:14:21 +0300 (IDT) Received: from LAP-ZEEV.zend.com ([10.1.2.20]) by il-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 19 Aug 2010 18:15:00 +0300 Message-ID: <7.0.1.0.2.20100819181013.18df1df8@zend.com> X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Date: Thu, 19 Aug 2010 18:14:35 +0300 To: "Ionut G. Stan" Cc: In-Reply-To: <4C6D39EA.4000705@gmail.com> References: <4C6CE273.2070501@sugarcrm.com> <4C6CE604.1010209@dmi.me.uk> <4C6CE793.1020601@sugarcrm.com> <1282206735.2561.11.camel@guybrush> <4C6CF898.5060706@gmail.com> <4C6D2EB8.30700@gmail.com> <4C6D39EA.4000705@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-OriginalArrivalTime: 19 Aug 2010 15:15:00.0030 (UTC) FILETIME=[4A6845E0:01CB3FB1] Subject: Re: [PHP-DEV] inheritance check too strict? From: zeev@zend.com (Zeev Suraski) At 17:04 19/08/2010, Ionut G. Stan wrote: class Parent >{ > public function foo(Foo $foo) > {} >} > >class Child >{ > public function foo(Bar $bar) > {} >} > >class Foo >{} > >class Bar extends Foo >{} > > > >All fine until here, but what if... > > > >class Taz extends Foo. >{} > > >I can't call Child::foo() with an instance of Taz, but I can call >Parent::foo() with such an instance. So, I can't use instances of >Child wherever instances of Parent would be accepted. Child should clearly not be allowed to inherit Parent in the code above, since the signature of Child::foo() is more restrictive than the signature of Parent::foo(). The other way around could work (although I don't recall if we allow it): class Foo {} class Bar extends Foo {} class Parent { public function foo(Bar $bar){} } class Child extends Parent { public function foo(Foo $foo){} } No issues here - since any Bar object is also a Foo object and would pass the is_a validation of Foo. Again, I don't recall if we allow such signature overrides or not. Zeev