From:             EdwardDrapkin at gmail dot com
Operating system: Irrelevant
PHP version:      5.3.1
PHP Bug Type:     Class/Object related
Bug description:  Protected members of non-congruent children classes are 
visible

Description:
------------
When you have two classes that extend the same base class, if the
protected members are declared in the base class, they are visible to each
other.  Because the class variables are protected, they should not be
available to other classes, even if they share the same parent (but are of
different types themselves)!

Reproduce code:
---------------
<?php
class foo {
        public $public = "a";   
        private $private = "b";
        protected $protected = "protected";
}

class bar extends foo {
        
}

class kid extends foo {
        public function test() {
                $b = new bar();
                var_dump(get_object_vars($b));
                var_dump($b->protected);
        }
}

$k = new kid();
$k->test();

Expected result:
----------------
array(1) {
  ["public"]=>
  string(1) "a"
}

Visibility error.

Actual result:
--------------
array(2) {
  ["public"]=>
  string(1) "a"
  ["protected"]=>
  string(9) "protected"
}
string(9) "protected"

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

Reply via email to