From:             kopelke at gmail dot com
Operating system: Windows Vista
PHP version:      5.2.6
PHP Bug Type:     Class/Object related
Bug description:  each on objects shows private and protected properties

Description:
------------
If each is used on an object it will reveal the protected and private
member data. It is not possible to change this data, but it should not be
visible at all.
Besides the each function should not be allowed on objects, or, if
implementing ArrayAccess, it should not reveal the private and protected
properties.

Reproduce code:
---------------
class A {
        private $x = 'private';
        protected $y = 'protected';
        public $z = 'public';
}

$o = new A();
$o -> a = 'outer:public';

while(list($k, $v) = each($o)) {
        $pos = 0;
        if($k{0} == "\0") 
                $k = substr($k, $pos = strpos($k, "\0", 1) + 1);
        switch($pos) {
                case 6:
                        $k = 'Private::' . $k; break;
                case 3:
                        $k = 'Protected::' . $k; break;
                default:
                        $k = 'Public::' . $k; break;
        }
        echo '<pre>'; print_r(array($k, $v)); echo '</pre>';
}

Expected result:
----------------
Array
(
    [0] => Public::z
    [1] => public
)

Array
(
    [0] => Public::a
    [1] => outer:public
)

Actual result:
--------------
Array
(
    [0] => Protected::x
    [1] => private
)

Array
(
    [0] => Protected::y
    [1] => protected
)

Array
(
    [0] => Public::z
    [1] => public
)

Array
(
    [0] => Public::a
    [1] => public von aussen
)


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

Reply via email to