-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WeakMap::offsetExists return false if value is null #8437
Comments
Line 384 in e063243
I wonder if that is deliberate or if |
This is deliberate. Despite the confusing name, the API contract of offsetExists is that it must return false for null values. It is the analogue of |
Will other Spl implementations of ArrayAccess, like SplObjectStorage, will change in the future according to this? |
|
Ah, right.
php-src/ext/spl/spl_observer.c Line 459 in 7ce5e0a
I think we should clarify the respective note in the manual. Are there other classes, where |
Also on ArrayAccess manual, is unclear ( https://www.php.net/manual/en/arrayaccess.offsetexists.php ) even if it's talking about the empty() function |
Just encountered this myself ( The only part of the manual I found that was relevant was the statement on the Is it correct? If it's a deliberate decision, what was the rationale? Or is it just a emergent consequence of |
I can't reproduce this. https://3v4l.org/NKKhE Additionally, "never assigned to" suggests you didn't create Unless, of course, the |
Try using In perhaps related behaviour, |
I had a quick look at that. Unfortunately, there php-src/ext/spl/spl_observer.c Line 457 in 360e6f8
So this seems intentional, although dubious. |
Not sure why I thought this was a problem when I wrote that: it's always been normal behaviour. The test is whether the indexed element exists or not - which assumes the index exists. |
Description
The following code:
Resulted in this output:
But I expected this output instead:
PHP Version
PHP 8.1.5
Operating System
The text was updated successfully, but these errors were encountered: