ID:               44168
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: Windpws XP
 PHP Version:      5.2CVS-2008-02-19 (CVS)
 New Comment:

Hi Josie. I already have reported that.

http://bugs.php.net/bug.php?id=43713

Derick' article about this:
http://derickrethans.nl/private_properties_exposed.php


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

[2008-02-19 14:09:12] [EMAIL PROTECTED]

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

Reply via email to