ID:               44854
 Updated by:       [EMAIL PROTECTED]
 Reported By:      doctorrock83 at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: Windows XP
 PHP Version:      5.2.5
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is expected as access control is *class* based, and not object
based.


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

[2008-04-28 13:40:16] doctorrock83 at gmail dot com

Description:
------------
In some cases, PHP doesn't handle the visibility correctly, allowing a
private or protected member to be directly accessed via $obj->prop

This seems to happen when a class stores instances of itself and tries
to access their properties.

Reproduce code:
---------------
<?php
class bar
{
    private $a;    
    private $children = array();
    
    public function __construct($infiniteDepth)
    {
        $this->a = 'foo';
        if ($infiniteDepth) $this->children[] = new self(false);
    }
    
    public function privateAcces()
    {
        foreach ($this->children as $child) {
            echo $child->a; // here is the bug
        }
    }    
}

$t = new toto(true);
$t->privateAcces();

Expected result:
----------------
fatal error as we access the private 'a' property from a non-$this
context

Actual result:
--------------
the property gets read correctly, as if it was public


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44854&edit=1

Reply via email to