php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52655 SimpleXMLElement supports ArrayAccess without implementing Interface
Submitted: 2010-08-20 15:14 UTC Modified: 2021-07-16 04:31 UTC
Votes:6
Avg. Score:2.8 ± 0.7
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:0 (0.0%)
From: ircmaxell at yahoo dot com Assigned:
Status: Re-Opened Package: SimpleXML related
PHP Version: 5.3.3 OS: CentOS 5.5
Private report: No CVE-ID: None
 [2010-08-20 15:14 UTC] 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

Patches

bug52655 (last revision 2015-03-29 07:17 UTC by kalle@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-20 15:58 UTC] salathe@php.net
-Type: Bug +Type: Feature/Change Request
 [2010-08-20 15:58 UTC] salathe@php.net
Moved to Feature Request category. 

Could you open a separate bug regarding the documentation of this array-style 
access? Thanks.
 [2010-08-20 17:34 UTC] kalle@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: kalle
 [2010-08-21 18:22 UTC] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=302614
Log: Fixed bug #52655 (SimpleXMLIterator supports ArrayAccess without implementing the interface)
 [2010-08-21 18:23 UTC] kalle@php.net
-Status: Assigned +Status: To be documented -Assigned To: kalle +Assigned To: salathe
 [2010-08-21 18:23 UTC] kalle@php.net
Peter, I have fixed the bug in the source and it will be available as of 5.3.4, if you want to take this documentation issue :)
 [2010-08-21 21:52 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=302623
Log: simplexmlelement/iterator implements arrayaccess (doc #52655)
 [2010-08-21 21:56 UTC] salathe@php.net
-Status: To be documented +Status: Closed
 [2010-08-21 21:56 UTC] salathe@php.net
Updated SimpleXMLElement/SimpleXMLIterator interfaces list and added a changelog to SimpleXMLElement synopsis page.
 [2010-08-22 13:39 UTC] kalle@php.net
-Status: Closed +Status: Re-Opened
 [2010-08-22 13:39 UTC] kalle@php.net
As written on php-doc-cvs@, its as of 5.3.4, not trunk :)
 [2010-08-22 13:39 UTC] kalle@php.net
As written on php-doc-cvs@, its as of 5.3.4, not trunk :)
 [2010-08-22 13:47 UTC] salathe@php.net
-Status: Re-Opened +Status: Closed
 [2010-08-22 13:47 UTC] salathe@php.net
We can't document a version number which does not exist. For now, the changelog will say "Future".  When a release is made which contains this change, the docs can be updated to reflect that.
 [2010-08-23 19:01 UTC] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=302715
Log: - revert fix for #52655, rev. 302614
 [2010-08-23 19:18 UTC] pajoye@php.net
-Status: Closed +Status: Re-Opened
 [2010-08-23 19:18 UTC] pajoye@php.net
reverted as the fix breaks many tests.
 [2010-08-23 21:54 UTC] kalle@php.net
-Assigned To: salathe +Assigned To: kalle
 [2010-08-23 21:54 UTC] kalle@php.net
I need to re-implement some additional code here before the correct fix will be there
 [2015-03-29 07:17 UTC] kalle@php.net
The following patch has been added/updated:

Patch Name: bug52655
Revision:   1427613447
URL:        https://bugs.php.net/patch-display.php?bug=52655&patch=bug52655&revision=1427613447
 [2015-03-29 07:18 UTC] kalle@php.net
-Status: Re-Opened +Status: Feedback
 [2015-03-29 07:18 UTC] kalle@php.net
I added a patch for this, but I'm sure there is a better way to do this than what the patch does
 [2015-04-12 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2020-06-22 08:09 UTC] nikic@php.net
-Summary: SimpleXMLIterator supports ArrayAccess without implementing Interface +Summary: SimpleXMLElement supports ArrayAccess without implementing Interface -Status: No Feedback +Status: Re-Opened
 [2020-06-22 08:09 UTC] nikic@php.net
This issue still exists.
 [2021-07-16 04:31 UTC] kalle@php.net
-Assigned To: kalle +Assigned To:
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 09 08:01:27 2024 UTC