Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49468 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61059 invoked from network); 19 Aug 2010 19:33:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2010 19:33:57 -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.42 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.42 mail-ww0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:55643] helo=mail-ww0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 48/49-00261-4278D6C4 for ; Thu, 19 Aug 2010 15:33:57 -0400 Received: by wwf26 with SMTP id 26so58594wwf.5 for ; Thu, 19 Aug 2010 12:33:53 -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=P132ty6Ogwn6U0rVO3LpM9M4QnE1aTl1Hslcc/A6RMM=; b=jOoqopiFRtBPdZbyQ1zXh15oxmrjtQaXaNd0mnJOGofGzsvGiRSAqDWne3EetQMHNZ UVkYPxbkW0jPERwrvOHZfBPcEbJ3xx8JdPQkKM7lsQWsyxb9yrRvhikS7ItUTnay+2G5 0L+EV+9NYoscfh4E6LJN4uGHHhy0FdC9GNVWQ= 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=IXC1UvJxMU8DNIcONFsNLbUCvBXNy4ccBUTtv7FLhG+8UVX93KzG84B/SwJvpBrRF0 woLhfOL8xK8g3C23xHjCh7dPDbDXZMHsdugMPDbOPGYcn0ToHHcrnIqEK2huH5YyL7fE NvoJdhH03HfNAFjyaA5vbxjYRAO/6gDXIvwNU= Received: by 10.227.132.199 with SMTP id c7mr249155wbt.89.1282246433588; Thu, 19 Aug 2010 12:33:53 -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 m25sm1675517wbc.19.2010.08.19.12.33.51 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 19 Aug 2010 12:33:52 -0700 (PDT) Message-ID: <4C6D86FF.7050503@gmail.com> Date: Thu, 19 Aug 2010 20:33:19 +0100 User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Zeev Suraski CC: "Ionut G. Stan" , internals@lists.php.net, smalyshev@sugarcrm.com, Dave Ingram 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> <7.0.1.0.2.20100819181013.18df1df8@zend.com> In-Reply-To: <7.0.1.0.2.20100819181013.18df1df8@zend.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] inheritance check too strict? From: nrixham@gmail.com (Nathan Rixham) Zeev Suraski wrote: > At 17:04 19/08/2010, Ionut G. Stan wrote: >> >> 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 Guys, this is going a bit nuts, let's swap all the Foo and Bar's for a real example - Zeev I've copied the way you specified above. class Point2D { // Foo public $x; public $y; } class Point3D extends Point2D { // Bar extends Foo public $z; } class Point2DManager { // Parent public function distanceBetween( Point3D $p1 , Point3D $p2 ) {}; } class Point3DManager extends Point2DManager { // Child extends Parent public function distanceBetween( Point2D $p1 , Point2D $p2 ) {}; } You're saying that makes sense and is no problem? honestly? Best, Nathan ps: no offence / nothing personal just want to get this cleared up