Edit report at https://bugs.php.net/bug.php?id=41727&edit=1
ID: 41727
Comment by: php at example dot com
Reported by: dan at yes dot lt
Summary: ArrayAccess::offsetExists works wrong with isset()
Status: Wont fix
Type: Bug
Package: SPL related
Operating System: WinXP
PHP Version: 5.2.3
Block user comment: N
Private report: N
New Comment:
This is embarrassing... Bug #61347 was fixed (in PHP 5.3.11 / 5.4.1) but only for the ArrayObject
implementation, not the ArrayAccess interface :/
Previous Comments:
------------------------------------------------------------------------
[2017-12-06 13:09:40] a dot ryazanov at superjob dot ru
The behavior is still here with 7.1.12, and I still suppose it's a bug. Since the docs
(https://secure.php.net/manual/en/function.isset.php) clearly tells "isset â Determine if
a variable is set and is not NULL", it should work as documented, but it doesn't: it
doesn't check if the value of ArrayAccess element is not null.
Also, as mentioned above, it breaks ArrayAccess compatibility with natural arrays, thus making this
interface virtually useless: if you can't mimic an array with the object and have to check what
is the type of array-like variable before interacting with it, then implementing
ArrayAccess/ArrayObject etc makes no sense,
------------------------------------------------------------------------
[2011-09-28 23:51:49] colder@php.net
This is a known "problem", on one hand offsetExists is similar to
array_key_exists, on the other hand, it is the only thing called by isset.
Even though this is a bit of a problem, I don't believe it is worth modifying
the isset() behavior now to call get, as that would be some BC break that would
not be easy to track down.
I guess the only thin gto do now is accept that offsetExists mimics isset(),
that nothing mimics array_key_exists, and work with that, making this a Won't
fix.
------------------------------------------------------------------------
[2011-09-28 17:48:48] stas@php.net
What prevents you from implementing offsetExists with any checks you like,
including null check?
------------------------------------------------------------------------
[2007-06-22 10:35:20] dan at yes dot lt
I see... you make php for yourself, but not for others... you don't listen for arguments, just
skipping the bugs... without any reason explanations...
thank you for good support and correct php!
------------------------------------------------------------------------
[2007-06-22 10:29:15] johannes@php.net
.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=41727
--
Edit this bug report at https://bugs.php.net/bug.php?id=41727&edit=1