Edit report at http://bugs.php.net/bug.php?id=49889&edit=1

 ID:               49889
 Updated by:       col...@php.net
 Reported by:      carmen at helderhosting dot nl
 Summary:          offsetExists wrong result
-Status:           Assigned
+Status:           Wont fix
 Type:             Bug
 Package:          SPL related
 Operating System: unix
 PHP Version:      5.3.0
 Assigned To:      colder

 New Comment:

Indeed, this feels a bit odd. However, isset() internally calls
offsetExists, so 

if offsetExists returns true(and it should) on NULLs, then isset() will
also 

return true. Three options at hand:



1) Modify offsetExists semantics to return false on NULLs, or

2) add another magic method called by isset().

3) Modify the semantics of isset() on objects to also call offsetGet and
check 

the value, like empty.



For which I have at least one objection each:



1+3) counter-intuitive, and would break BC

2) not worth it, given that isset() is the only special case.



I believe that this is a "won't fix" scenario, sorry.


Previous Comments:
------------------------------------------------------------------------
[2009-10-15 12:31:07] carmen at helderhosting dot nl

Description:
------------
If $o = new ArrayObject(); $o['x'] = null;

the result for isset($o['x']) it should be false, instead true is given

Reproduce code:
---------------
<?php

$a = array();

$a['x'] = null;

var_dump(isset($a['x']));

var_dump(empty($a['x']));

var_dump(array_key_exists('x', $a));



$o = new ArrayObject();

$o['x'] = null;

var_dump($o->offsetExists('x'));

var_dump(isset($o['x']));

var_dump(empty($o['x']));

var_dump(array_key_exists('x', $o));

?>

Expected result:
----------------
bool(false)

bool(true)

bool(true)

bool(true)

bool(false)

bool(true)

bool(true)

Actual result:
--------------
bool(false)

bool(true)

bool(true)

bool(true)

bool(true)

bool(true)

bool(true)


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=49889&edit=1

Reply via email to