go to bug id or search bugs for
WeakRef Vesion: 0.2.6
Configure line: --with-pdo-mysql --enable-mbstring --with-openssl
The documentation states that the ::key() method returns an object.
However in my test script it returns an integer.
Also in a foreach loop the key is just an integer, never the object. I also couldn't find any other way to get the objects back out of the WeakMap.
PS: Thanks for the great extension and the support!
$o = new stdClass();
$wm = new WeakMap();
$wm[$o] = 'foo';
// outputs int(1) instead of the expected object
Dump of the object $o
Add a Patch
Add a Pull Request
The general issue is that foreach($wm as $k => $o) originally did not support keys other than int/string in PHP (this is an engine limitation of PHP <5.5).
Now that it does support these, I should release a version of WeakMap that does this in foreach.
I understand, thanks. Is there any other way or work around to get the values out of the WeakMap again?
This has been fixed in the latest version of php-weakref (available only for PHP7)