ID:               34934
 Updated by:       [EMAIL PROTECTED]
 Reported By:      adove at booyahnetworks dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         SPL related
 Operating System: WinXP, Linux
 PHP Version:      5.0.5
 New Comment:

Provide a short but complete reproduce script then.
The code you've pasted in the report is not complete - there is no
declaration of MyArray class.


Previous Comments:
------------------------------------------------------------------------

[2005-10-20 19:28:17] adove at booyahnetworks dot com

Same behavior in both the latest 5.0.5 and 5.1...

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

[2005-10-20 18:57:25] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



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

[2005-10-20 18:52:00] adove at booyahnetworks dot com

Description:
------------
I've searched the bug list and found only one bug that hints arond the
same issue (http://bugs.php.net/bug.php?id=34849) BUT it appears the
closing statement in the bug "ArrayAccess objects don't work in
array_*() functions. You may want to
turn this report into a feature request?" seems incorrect per the code
below. 

I have an class (MyArray) I derived from ArrayObject and have
overridden the ArrayAccess::offset* methods to allow me to make the
array addressable via an XPath-styled key path, e.g., /key1/key2,
etc.). All of the offset* methods get called just fine and work like a
champ EXCEPT offsetExists... 

Based on the bug ref'd above, offsetExists is just an adjunct function
on the ArrayAccess interface and not "hooked up" to any language
constructs. HOWEVER, based on emperical information, this appears
incorrect/inconsistent. 

The code submited illustrates the point. If I take a raw ArrayObject,
set it to a multi-dim'd array and test for the root key via
array_key_exists, I get true, which is correct. Additionally, if I test
for any other key I get false, which is also correct. Based on the above
bug I would expect to get a warning about only arrays being passed to
the method blah blah. So, somehow it would *appear* that the
ArrayObject class is somehow having its offsetExists method.

When I do the same tests with my derived array object (MyArray), I get
the same results. HOWEVER, my overidden offsetExists method is never
called. This is evident via debuging (I never step into it) and in the
last test assigned to $bShouldWorkButDoesNot. This path actually does
exist and would have  been confirmed to via my offsetExists.

So, I am prepared to be given the same answer as the other bug. ;-)
BUT, I think this is inconsistent behavior so it seems a bug to me...
And, if it is not a bug, then I will 100% submit a feature request. 

Reproduce code:
---------------
$a = array(
    "test" => array(
        "one" => "dunno",
        "two" => array(
            "peekabo" => "do you see me?",
            "anyone" => array("there")
            )
        )
    );
$oArray = new ArrayObject($a);
$oMyArray = new MyArray($a);

$bWorks1 = array_key_exists("test", $oArray);
$bWorks2 = array_key_exists("test", $oMyArray);

$bShouldWorkButDoesNot = array_key_exists("test/two/peekabo",
$oBooyahArray);


Expected result:
----------------
true === $bWorks1
true === $bWorks2
true === $bShouldWorkButDoesNot

Actual result:
--------------
true === $bWorks1
true === $bWorks2
false === $bShouldWorkButDoesNot


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


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

Reply via email to