Edit report at https://bugs.php.net/bug.php?id=41727&edit=1
ID: 41727 Updated by: col...@php.net Reported by: dan at yes dot lt Summary: ArrayAccess::offsetExists works wrong with isset() -Status: Bogus +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 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. Previous Comments: ------------------------------------------------------------------------ [2011-09-28 17:48:48] s...@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] johan...@php.net . ------------------------------------------------------------------------ [2007-06-22 07:46:23] dan at yes dot lt ok, now think... if you have method to work with array or any object with ArrayAccess implemented... function some($list) { if (isset($list[0])) { // do something with $list[0] return true; } else { // no $list[0] defined, skipping return false; } } user, who implements this function must not know the real type of the $list variable - but only that this variable can be accessed as array... now - if $list = array(0 => null), then this function works correctly, but if $list = new ArrayObject(array(0 => null)), then it fails... now, you say, i must to use offsetGet method... then, i must check whether $list is instance of ArrayAccess, then add complex checkings using offsetExists and offsetGet... was the ArrayAccess realy planned to be such a silly structure to use it in such complex way?.. I don't think so. I still think, isset() must automaticaly call offsetGet after offsetExists returns true... ------------------------------------------------------------------------ [2007-06-22 07:34:01] johan...@php.net Yes, I still think so. ------------------------------------------------------------------------ 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