Doc #73057 [Csd]: Casting a SimpleXMLElement to an array does NOT exhibit differing behavior
| From: | brian dot mcclure at adition dot com | Date: | Fri, 09 Sep 2016 14:25:00 +0000 |
| Subject: | Doc #73057 [Csd]: Casting a SimpleXMLElement to an array does NOT exhibit differing behavior | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-13891@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73057&edit=1
ID: 73057
User updated by: brian dot mcclure at adition dot com
Reported by: brian dot mcclure at adition dot com
Summary: Casting a SimpleXMLElement to an array does NOT
exhibit differing behavior
Status: Closed
Type: Documentation Problem
Package: SimpleXML related
Operating System: Ubuntu 16.04
PHP Version: Irrelevant
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Thanks for the quick responses.
to clarify, this only occurs when attempting to cast a child node of a SimpleXMLElement that has
multiple children with the same name?
Are there any other scenarios?
Previous Comments:
------------------------------------------------------------------------
[2016-09-09 13:45:40] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
------------------------------------------------------------------------
[2016-09-09 13:45:15] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=340007
Log: Fix #73057: Casting a SimpleXMLElement to an array does NOT exhibit differing behavior
------------------------------------------------------------------------
[2016-09-09 13:24:26] cmb@php.net
The former behavior was sometimes buggy, and the respective change
was merely a bugfix. See <https://3v4l.org/5dQ0S> for a
case where
the behavior was different before and after PHP 5.4.
I think the documentation should be improved to emphasize the
word "always".
------------------------------------------------------------------------
[2016-09-09 12:50:47] brian dot mcclure at adition dot com
fixed typo in summary
------------------------------------------------------------------------
[2016-09-09 12:38:29] brian dot mcclure at adition dot com
Description:
------------
According to 5.4 changenotes, http://php.net/manual/en/migration54.other.php
there is some sort of behavior change to be expected when casting a SimnpleXMLElement to an array.
But unless I'm misunderstanding what the docs mean, the bahavior is consistent all the way from
5.1 to 7.1
https://3v4l.org/F4DfI
If this is not a bug, would someone mind providing an example of the before and after behavior?
Test script:
---------------
<?php
$xml =
"<xml><first-node>foo</first-node><second-node><nested-node>bar</nested-node></second-node><third-node>baz</third-node></xml>";
$a = new SimpleXMLElement($xml);
var_export((array)$a);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73057&edit=1