From:             bruno dot caillaud at cndp dot fr
Operating system: Windows XP
PHP version:      5.2.6
PHP Bug Type:     *General Issues
Bug description:  get_object_vars bug ?

Description:
------------
I read the Bug #42814 which is supposed to be closed, however, I have
reproduced this bug in the last version 5.2.6

this is a sample code :
<?php
        class Base {
                private $basePrivateProperty;
                protected $baseprotectedProperty;
                
                function getProperties () {
                return get_object_vars ( $this );
          }
        }
        
        class Child extends Base {
                private $childPrivateProperty;
                protected $childprotectedProperty;
                
        }
        
        echo "Base :<br/>\n";
        $father = new Base();
        var_dump($father->getProperties());
        
        echo "<br/>Child :<br/>\n";
        $children = new Child();
        var_dump($children->getProperties());
?>


Running this sample code 
Result on different versions of php 5:

PHP version 5.2.0 to 5.2.3 :
Base :
array(2) { ["basePrivateProperty"]=> NULL ["baseprotectedProperty"]=> NULL
}
Child :
array(3) { ["childPrivateProperty"]=> NULL ["childprotectedProperty"]=>
NULL ["baseprotectedProperty"]=> NULL }

PHP version 5.2.4 to 5.2.6:
Base :
array(2) { ["basePrivateProperty"]=> NULL ["baseprotectedProperty"]=> NULL
}
Child :
array(3) { ["childprotectedProperty"]=> NULL ["basePrivateProperty"]=>
NULL ["baseprotectedProperty"]=> NULL }

I think the good behaviour is the one returned by versions 5.2.0 to
5.2.3.
in 5.2.4 version and up, the child can access to his parent's private
property but not to his own private property

Reproduce code:
---------------
<?php
        class Base {
                private $basePrivateProperty;
                protected $baseprotectedProperty;
                
                function getProperties () {
                return get_object_vars ( $this );
          }
        }
        
        class Child extends Base {
                private $childPrivateProperty;
                protected $childprotectedProperty;
                
        }
        
        echo "Base :<br/>\n";
        $father = new Base();
        var_dump($father->getProperties());
        
        echo "<br/>Child :<br/>\n";
        $children = new Child();
        var_dump($children->getProperties());
?>

Expected result:
----------------
Base :
array(2) { ["basePrivateProperty"]=> NULL ["baseprotectedProperty"]=> NULL
}
Child :
array(3) { ["childPrivateProperty"]=> NULL ["childprotectedProperty"]=>
NULL ["baseprotectedProperty"]=> NULL }

Actual result:
--------------
Base :
array(2) { ["basePrivateProperty"]=> NULL ["baseprotectedProperty"]=> NULL
}
Child :
array(3) { ["childprotectedProperty"]=> NULL ["basePrivateProperty"]=>
NULL ["baseprotectedProperty"]=> NULL }

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

Reply via email to