[php-src] Issue #8437: WeakMap::offsetExists return false if value is null
| From: | julien-boudry | Date: | Mon, 25 Apr 2022 13:52:20 +0000 |
| Subject: | [php-src] Issue #8437: WeakMap::offsetExists return false if value is null | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241227@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8437
Author: julien-boudry
### Description
The following code:
```php
<?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));
```
Resulted in this output:
```
bool(false)
bool(true)
bool(true)
bool(true)
```
But I expected this output instead:
```
bool(true)
bool(true)
bool(true)
bool(true)
```
### PHP Version
PHP 8.1.5
### Operating System
*