ID:               45008
 Updated by:       [EMAIL PROTECTED]
 Reported By:      bruno dot caillaud at cndp dot fr
 Status:           Open
 Bug Type:         *General Issues
 Operating System: Windows XP
 PHP Version:      5.2.6
 New Comment:

Just a note about bug #42814: "No feedback" is not same as "Closed" in
which case there would be an entry in the NEWS file about a fixed bug..


Previous Comments:
------------------------------------------------------------------------

[2008-05-15 14:41:48] bruno dot caillaud at cndp dot fr

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 this bug report at http://bugs.php.net/?id=45008&edit=1

Reply via email to