ID:               41584
 Updated by:       [EMAIL PROTECTED]
 Reported By:      judas dot iscariote at gmail dot com
-Status:           Feedback
+Status:           Assigned
 Bug Type:         SimpleXML related
 Operating System: any
 PHP Version:      5CVS-2007-06-04 (CVS)
-Assigned To:      
+Assigned To:      helly
 New Comment:

After a discussion with Christian, I do agree that there is something
wrong with the logics SimpleXML uses.
When you use $obj->element[0] it actually uses $obj->element (well, I
can see the reasoning, but it's a bit non-obvious). On the other hand,
when you try to write $obj->element[1], the result is NULL 'cause there
is no element #1.

I guess sxe_prop_dim_read() should automatically create elements when
used with BP_VAR_W/BP_VAR_RW.
Marcus, what do you think about it?


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

[2007-06-04 11:12:37] [EMAIL PROTECTED]

IMO the warning is correct and the code is not.
I don't understand what you're trying to do with $object[0]->property -
is this supposed to created a property named '0' and assign an empty
object to it?

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

[2007-06-04 10:09:37] judas dot iscariote at gmail dot com

Description:
------------
[different problem, but a follow up of bug 41582


The following code emits a wrong notice, rendering this stuff more or
less useless in write context...



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

$xml = new SimpleXMLElement('<?xml version="1.0" standalone="yes"?>
<collection></collection>');

$xml->movie[0]->characters->character[0]->name = 'Miss Coder';
$xml->movie[0]->characters->character[1]->name = 'ouch';

var_dump($xml->asXML());


Expected result:
----------------
string(%d) "<?xml version="1.0" standalone="yes"?>
<collection><movie><characters><character><name>Miss
Coder</name></character><character><name>ouch</name></character></characters></movie></collection>
"

Actual result:
--------------
PHP Notice:  Indirect modification of overloaded element of
SimpleXMLElement has no effect in /home/cristian/simplecrashes.php on
line 6
string(151) "<?xml version="1.0" standalone="yes"?>
<collection><movie><characters><character><name>Miss
Coder</name></character></characters></movie></collection>
"



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


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

Reply via email to