[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pear-dev
Subject:    Re: [PEAR-DEV] HTML_QuickForm2 calling protected methods in other
From:       Alexey Borzov <borz_off () cs ! msu ! su>
Date:       2011-07-05 12:07:40
Message-ID: 4E12FE8C.3030200 () cs ! msu ! su
[Download RAW message or body]

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

-- 
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic