Edit report at http://bugs.php.net/bug.php?id=52655&edit=1
ID: 52655 Updated by: [email protected] Reported by: ircmaxell at yahoo dot com Summary: SimpleXMLIterator supports ArrayAccess without implementing Interface Status: Open -Type: Bug +Type: Feature/Change Request Package: SimpleXML related Operating System: CentOS 5.5 PHP Version: 5.3.3 Block user comment: N New Comment: Moved to Feature Request category. Could you open a separate bug regarding the documentation of this array-style access? Thanks. Previous Comments: ------------------------------------------------------------------------ [2010-08-20 15:14:30] ircmaxell at yahoo dot com Description: ------------ This is more of a consistency issue, but I'm submitting it as a bug since it prevents certain type checks in PHP code. SimpleXMLIterator does not implement the ArrayAccess interface (and neither does its parent SimpleXML). And the documentation says nothing about access via array syntax. However the class itself does support that method of access. To resolve the issue, two things can be done. First, documentation should be updated to reflect that method of access. Second, SimpleXMLIterator should implement the ArrayAccess interface for consistency... Test script: --------------- $xml = '<items><item>foo</item></items>'; $simple = simplexml_load_string($xml); var_dump($simple->item instanceof ArrayAccess); print (string) $simple->item[0]; Expected result: ---------------- bool(true) foo Actual result: -------------- bool(false) foo ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52655&edit=1
