From:             vituko at gmail dot com
Operating system: Debian GNU/Linux
PHP version:      5.3CVS-2008-04-01 (CVS)
PHP Bug Type:     Class/Object related
Bug description:  strange behavior of visibility

Description:
------------
Context visibility of inherited private attributes when they apply 
to child classes.

When a private attribtue is inherited, it's still accessible from 
the context (base class) where it was declared and it becomes 
accessible from the child context (unidirectional visibility).

But when this attribute is static (class attribute), it becomes 
inaccessible from every context : the base class and the child 
class.

I don't know if it's the normal behavior, anyway I find it strange 
and it could be documented.

Thanks

Reproduce code:
---------------
class a {
        private $v ;
        private static $w ;
        function f($c) {
                $c -> v = 'asdf' ;
                $c :: $w = 'fdsa' ;
        }
}
class b extends a {
        function g($c) {
                $c -> v = 'asdf' ;
                $c :: $w = 'fdsa' ;
        }
}
$a = new a() ;
$b = new b() ;

$a-> f($a) ;
$a-> f($b) ;
$b -> f($b) ;
$b -> g($b) ;

Expected result:
----------------
no errors

Actual result:
--------------
A - protected static $w ;

all is ok

B - private static $w ;

1 : $a-> f($a) ; -> ok
2 : $a-> f($b) ; -> Cannot access property b::$w
3 : $b -> f($b) ; -> Cannot access property b::$w
4 : $b -> g($b) ; -> Cannot access property b::$w

2,3,4 : b:$w is accessible from nowhere.

The errors are not :
- Access to undeclared static property
- Cannot access private property

-- 
Edit bug report at http://bugs.php.net/?id=44590&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44590&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44590&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44590&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44590&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44590&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44590&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44590&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44590&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44590&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44590&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44590&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44590&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44590&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44590&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44590&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44590&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44590&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44590&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44590&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44590&r=mysqlcfg

Reply via email to