Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29903 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70421 invoked by uid 1010); 29 May 2007 22:39:22 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 70406 invoked from network); 29 May 2007 22:39:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 May 2007 22:39:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 63.205.162.114 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 63.205.162.114 unknown Windows 2000 SP4, XP SP1 Received: from [63.205.162.114] ([63.205.162.114:4425] helo=us-ex1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 85/2A-10662-89BAC564 for ; Tue, 29 May 2007 18:39:22 -0400 Received: from [127.0.0.1] ([192.168.16.180]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 29 May 2007 15:39:18 -0700 Message-ID: <465CAB92.6080800@zend.com> Date: Tue, 29 May 2007 15:39:14 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 To: Emil Ivanov CC: internals@lists.php.net References: <57.79.10662.276AC564@pb1.pair.com> In-Reply-To: <57.79.10662.276AC564@pb1.pair.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 29 May 2007 22:39:18.0245 (UTC) FILETIME=[31539150:01C7A242] Subject: Re: [PHP-DEV] function overriding and class inheritance From: stas@zend.com (Stanislav Malyshev) > I'll try get straight to the point: > class C1 {} > class C2 extends C1 {} > > abstract class Work1 { > public function f1(C1 $c); > } > > class Work2 extends Work1 { > public function f1(C2 $c); > } This code violates the LSP (*) - if you have object $X of type C1, you can call $work1->f1($X) but not $work2->f1($X) - so $work2 can't be substituted for $work1. Meaning if you had this code: function foo(Work1 $object) { $X = new C1(); $object->f1($X); } it would break with passing Work2 object into it, which violates the principles of inheritance. (*) http://en.wikipedia.org/wiki/Liskov_substitution_principle -- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/