<?php
class Foo {
public $name;
public $type;
public function __construct($name, $type) {
$this->name = $name;
$this->type = $type;
}
}
$s = new SplObjectStorage();
$first = new Foo('first', 0);
$second = new Foo('second', 0);
$third = new Foo('third', 1);
$fourth = new Foo('fourth', 1);
$s->attach($first);
$s->attach($second);
$s->attach($third);
$s->attach($fourth);
PD9waHAKY2xhc3MgRm9vIHsKCXB1YmxpYyAkbmFtZTsKCXB1YmxpYyAkdHlwZTsKCQoJcHVibGljIGZ1bmN0aW9uIF9fY29uc3RydWN0KCRuYW1lLCAkdHlwZSkgewoJCSR0aGlzLT5uYW1lID0gJG5hbWU7CgkJJHRoaXMtPnR5cGUgPSAkdHlwZTsKCX0KfQoKJHMgPSBuZXcgU3BsT2JqZWN0U3RvcmFnZSgpOwoKJGZpcnN0ID0gbmV3IEZvbygnZmlyc3QnLCAwKTsKJHNlY29uZCA9IG5ldyBGb28oJ3NlY29uZCcsIDApOwokdGhpcmQgPSBuZXcgRm9vKCd0aGlyZCcsIDEpOwokZm91cnRoID0gbmV3IEZvbygnZm91cnRoJywgMSk7Cgokcy0+YXR0YWNoKCRmaXJzdCk7CiRzLT5hdHRhY2goJHNlY29uZCk7CiRzLT5hdHRhY2goJHRoaXJkKTsKJHMtPmF0dGFjaCgkZm91cnRoKTsKCnByaW50X3IoJHMpOw==