WeakMap::offsetExists return false if value is null
Aperta
@Girgias ci sta già lavorando.
Dal 8/3/2024.
Bug
Category: Engine
Status: Needs Triage
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.1k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
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
Operating System
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.