3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test {} function addToStorage(\SplObjectStorage $storage, Test $test) { if (!$storage->contains($test)) { $storage->attach($test); } } class OneSpecimenPerClassStorage extends \SplObjectStorage { public function getHash($o) { return get_class($o); } } $storage = new \OneSpecimenPerClassStorage(); $test1 = new Test(); $test2 = new Test(); addToStorage($storage, $test1); addToStorage($storage, $test2); echo $storage->count();
based on NOjXd
Output for 5.4.0 - 7.2.0
1
Output for 5.3.18 - 5.3.29
2