Re: HTML_QuickForm2 calling protected methods in other objects?

From: Date: Tue, 05 Jul 2011 12:07:40 +0000
Subject: Re: HTML_QuickForm2 calling protected methods in other objects?
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-54364@lists.php.net to get a copy of this message
Hi Christian, On 05.07.2011 13:27, Christian Weiske wrote:
Please help me understand why QF2 containers may call protected methods of other objects! The problem: The QF2 container iterates over all children and calls their validate() method: http://svn.php.net/viewvc/pear/packages/HTML_QuickForm2/trunk/HTML/QuickForm2/Node.php?revision=311435&view=markup#l625 The childrens are all QF2 nodes at least: http://svn.php.net/viewvc/pear/packages/HTML_QuickForm2/trunk/HTML/QuickForm2/Container.php?revision=310418&view=markup#l414 the node::validate method is protected. How is it possible that the container may call it? It's outside the class scope!
validate() is declared in HTML_QuickForm2_Node which is extended by Element and Container. PHP's documentation is (as usual) not extremely clear when it states [1] that:
Members declared protected can be accessed only within the class itself and by inherited and parent classes.
Child classes of Element and Container actually qualify as inherited, as can be confirmed by handling of the relevant bugs [2] and [3] [1] http://www.php.net/manual/en/language.oop5.visibility.php [2] https://bugs.php.net/bug.php?id=37212 [3] https://bugs.php.net/bug.php?id=37632

« previous php.pear.dev (#54364) next »