-
Notifications
You must be signed in to change notification settings - Fork 8k
Open
Description
Description
The following code:
<?php
$wm = new \WeakMap;
$os = new \SplObjectStorage;
$obj1 = new \stdClass;
$obj2 = new \stdClass;
$wm[$obj1] = null;
$wm[$obj2] = true;
$os[$obj1] = null;
$os[$obj2] = true;
var_dump($wm->offsetExists($obj1));
var_dump($wm->offsetExists($obj2));
var_dump($os->offsetExists($obj1));
var_dump($os->offsetExists($obj2));
foreach ($wm as $key => $value) {
if ($key === $obj1) {
echo 'key $obj1 is always here';
}
}Resulted in this output:
bool(false)
bool(true)
bool(true)
bool(true)
key $obj1 is always here
But I expected this output instead:
bool(true)
bool(true)
bool(true)
bool(true)
key $obj1 is always here
PHP Version
PHP 8.1.5