Re: Inconsistencies when accessing protected members

From: Date: Wed, 26 Mar 2008 20:07:14 +0000
Subject: Re: Inconsistencies when accessing protected members
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-36564@lists.php.net to get a copy of this message
It just doesn't seem right to be able to call a private or protected method of another instance. Sort of isn't private any more.
Why not? Private/protected is meant to separate APIs, it's not a security check on objects. Private means this API belongs to this class only, protected means this API belongs to this class and the children - i.e. to whoever develops this class further, but not to the clients. However, I see no reason to restrict class's code access to its own functions because the passed object is not $this. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

« previous php.internals (#36564) next »