WeakMap and SplObjectStorage have different behavior when iterating in a foreach loop. While the key in SplObjectStorage is the numeric index of the inner array, in the WeakMap the key is the object reference:
<?php
class A {}
$a = new A;
$objectStorage = new SplObjectStorage ();
$weakMap = new WeakMap();
$objectStorage [$a] = 1;
$weakMap[$a] = 1;
foreach($objectStorage as $key => $value) {
var_dump($key); // prints: int(0)
}
foreach($weakMap as $key => $value) {
var_dump($key); // prints: object(A)#1 (0) {}
}