Re: svn: /phpdoc/en/trunk/language/oop5/ visibility.xml
| From: | Daniel Egeberg | Date: | Fri, 11 Jun 2010 09:57:13 +0000 |
| Subject: | Re: svn: /phpdoc/en/trunk/language/oop5/ visibility.xml | ||
| References: | 1 2 3 4 | Groups: | php.doc.cvs |
| Request: | Send a blank email to doc-cvs+get-6810@lists.php.net to get a copy of this message | ||
On Fri, Jun 11, 2010 at 11:45, Richard Quadling <rquadling@gmail.com> wrote:
> On 11 June 2010 10:40, Daniel Egeberg <degeberg@php.net> wrote:
>> On Fri, Jun 11, 2010 at 11:16, Richard Quadling <rquadling@gmail.com> wrote:
>>> On 11 June 2010 09:55, Daniel Egeberg <degeberg@php.net> wrote:
>>>> degeberg Fri, 11 Jun 2010 08:55:34
>>>> +0000
>>>>
>>>> Revision:
>>>> http://svn.php.net/viewvc?view=revision&revision=300372
>>>>
>>>> Log:
>>>> Explained that it is possible accessing private and protected members of other
>>>> instances of the same object type.
>>>>
>>>> Changed paths:
>>>> U phpdoc/en/trunk/language/oop5/visibility.xml
>>>>
>>>> *snip*
>>>>
>>>> --
>>>> PHP Documentation Commits Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>
>>> That "smells" like a bug. Private not being private. Sort of isn't
>>> private anymore. I know that everyone in the company has a bank
>>> account, but I can't get to it just because I know how to read my own.
>>
>> It is not a bug. Marking members as private or protected is to
>> encapsulate things and hide implementation details. When you are
>> inside the Test class, there is nothing to hide about Test's
>> implementation even though it's a different instance.
>>
>> You'll find similar behavior in C# [1], Java [2] and likely other
>> languages as well.
>>
>> [1] http://pastebin.com/mtkUD2fp
>> [2] http://pastebin.com/cTb9PTQq
>>
>> --
>> Daniel Egeberg
>>
>
> Ah. OK. I see what you mean. OOI, is there any technique (in PHP or
> otherwise) that allows for private properties at the instance level?
For calling methods, I suppose you could implement some hack using
debug_backtrace(). It's not really an issue though. When you are
implementing a class, you have complete control over what methods you
are going to call (on that class or otherwise). That's not the case
when you expose the API to other people though, and that's when
visibility modifiers become useful.
--
Daniel Egeberg