Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36620 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89114 invoked from network); 27 Mar 2008 18:29:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Mar 2008 18:29:37 -0000 Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:28912] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/A8-02016-097EBE74 for ; Thu, 27 Mar 2008 13:29:37 -0500 Received: from us-ex1.zend.com ([192.168.16.5]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 27 Mar 2008 20:30:04 +0200 Received: from [192.168.16.84] ([192.168.16.84]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 27 Mar 2008 11:30:01 -0700 Message-ID: <47EBE78A.1060505@zend.com> Date: Thu, 27 Mar 2008 11:29:30 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: robin@soal.org CC: Marcus Boerger , internals , Alexey Zakhlestin , RQuadling@googlemail.com, Felipe Pena , Lars Strojny References: <5a8807d10802050343r43742844we89366ec47b57f4b@mail.gmail.com> <46ccd1ab0803241816k413c7605p2c3fb9139afd8536@mail.gmail.com> <5a8807d10803250404o6fd33662wbbf3ff14d296cb2a@mail.gmail.com> <1206444907.11368.4.camel@localhost> <1206445347.5400.1.camel@felipe> <10845a340803260945u7a49d991uac5d39be13cca988@mail.gmail.com> <10845a340803260956g6166feaboc04e55c88a9a1a8c@mail.gmail.com> <56335354.20080326181859@marcus-boerger.de> <5a8807d10803270359x5e7cb315m64e5f22e248129cd@mail.gmail.com> In-Reply-To: <5a8807d10803270359x5e7cb315m64e5f22e248129cd@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 27 Mar 2008 18:30:01.0752 (UTC) FILETIME=[91BA1980:01C89038] Subject: Re: [PHP-DEV] Inconsistencies when accessing protected members From: stas@zend.com (Stanislav Malyshev) Hi! > - B1 and B2 both extend A. B2 is neither an ancestor nor a > descendant of B1, but I suppose they could be considered to be part of > the same class hierarchy because they are siblings. > - f() is declared as protected in A and B1, but not declared at all in B2. Which means there exists A::f(), B1::f() and B2::f() (being the same as A::f()), all of which are protected. > - The docs state: "Protected limits access to inherited and parent > classes (and to the class that defines the item)" - > http://php.net/manual/en/language.oop5.visibility.php . > > Currently, B1::f() is visible from B2. A::f() is visible from B2, and B1 can not have access to f() more restricted than A since it's violate the Liskov principle - objects of B1 couldn't be used the same way as objects of A in all contexts. Look at this also this way: suppose we had no B1::f. Then if we call f() from B2, we always get A::f() which is protected, so it works. Now we copy A::f definition to B1 verbatim - with same access, same everything. Should now code that calls f() on B1 start failing? -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com