From:             [EMAIL PROTECTED]
Operating system: Windpws XP
PHP version:      5.2CVS-2008-02-19 (CVS)
PHP Bug Type:     Arrays related
Bug description:  Unusual output when using each() on private/protected 
properties of an object

Description:
------------
When using the each() function on an object that contains private or
protected properties I'm getting some unusual output shown below. 
I was wondering whether each() should be behaving the same as foreach()
does (as shown in the documentation here:
http://www.php.net/manual/en/language.oop5.iterations.php) and not be able
to access private/protected properties, or whether like the next, prev and
current functions, each() should not work with objects at all (bug raised
here: http://bugs.php.net/bug.php?id=43480).

Reproduce code:
---------------
class myClass {
        private $val1 = 'hello';
        protected $foo = 'world';
        var $bar = 'baz';
}
$input = new myClass;

var_dump($input);

var_dump( each($input) );
var_dump( each($input) );
var_dump( each($input) );

Expected result:
----------------
array(4) {
  [1]=>
  string(3) "baz"
  ["value"]=>
  string(3) "baz"
  [0]=>
  string(3) "bar"
  ["key"]=>
  string(3) "bar"
}

Actual result:
--------------
array(4) {
  [1]=>
  string(5) "hello"
  ["value"]=>
  string(5) "hello"
  [0]=>
  string(13) " myClass val1"
  ["key"]=>
  string(13) " myClass val1"
}
array(4) {
  [1]=>
  string(5) "world"
  ["value"]=>
  string(5) "world"
  [0]=>
  string(6) " * foo"
  ["key"]=>
  string(6) " * foo"
}
array(4) {
  [1]=>
  string(3) "baz"
  ["value"]=>
  string(3) "baz"
  [0]=>
  string(3) "bar"
  ["key"]=>
  string(3) "bar"
}

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

Reply via email to