From: info at netmosfera dot it Operating system: Irrelevant PHP version: 5.3.0alpha1 PHP Bug Type: Feature/Change Request Bug description: Request magic method __iteration()
Description: ------------ Hello, im asking for a magic method in oop __iteration() that is how i want it work a special __get, but for the iteration (foreach) please just read the code :D thank you Reproduce code: --------------- <?php class Test { private $pointer = -1; private $fields = array(); private $values = array(); public function __set($name, $value) { $this->fields[] = $name; $this->values[] = $value; } public function __get($name) { list($key) = array_keys($this->fields, $name); return $this->values[$key]; } public function __iteration($name, $value) { /* my useful [...] code */ $this->pointer++; return array($this->fields[$this->pointer], $this->values[$this->pointer]); } } $php = new Test(); $php->just = "a"; $php->a = "b"; $php->simple = "c"; $php->test = "d"; foreach($php as $field => $value) { echo $field . "=" . $value . "<br>"; } ?> Expected result: ---------------- just = a a = b simple = c test = d Actual result: -------------- no result -- Edit bug report at http://bugs.php.net/?id=45747&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45747&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45747&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45747&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45747&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45747&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45747&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45747&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45747&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45747&r=support Expected behavior: http://bugs.php.net/fix.php?id=45747&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45747&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45747&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45747&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45747&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45747&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45747&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45747&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45747&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45747&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45747&r=mysqlcfg