3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Entity { protected $_properties = []; public function &__get($property) { $value = null; return $value; } public function __set($property, $value) { $property = [$property => $value]; foreach ($property as $p => $value) { $this->_properties[$p] = $value; } } } class CustomIterator extends IteratorIterator { public $callback; public function __construct($items) { $this->callback = function ($a) { $a->foo .= ' world'; return $a; }; parent::__construct($items); } public function current() { $c = $this->callback; return $c(parent::current()); } } $entity = new Entity(); $it = new CustomIterator(new ArrayIterator([$entity])); $it->rewind(); var_dump($it->current());
based on S3fTZ

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for branch master
object(Entity)#1 (1) { ["_properties":protected]=> array(1) { ["foo"]=> string(6) " world" } }

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page