Re: Re: SimpleXML is creating nodes when it shouldn't...
| From: | D. Dante Lorenso | Date: | Fri, 12 May 2006 15:42:23 +0000 |
| Subject: | Re: Re: SimpleXML is creating nodes when it shouldn't... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-236069@lists.php.net to get a copy of this message | ||
Marcus Boerger wrote:
Creating data without using '=' assignment or calling a function is scary and somewhat 'magical' behavior. When I 'read' from a SimpleXML node and cast that read into an array context, I NEVER expect to actually create an array on the object I am reading from. If I do a SET (__set), I'd be ok with the magical behavior: $xmlstr = "<test><item>1</item></test>"; $xml = simplexml_load_string($xmlstr); $xml->nonexist = array(); But if I'm doing a GET, changing the structure of the object is very bad: foreach ($xml->nonexist2 as $nonexist2) { } Adding a flag is fine and all, but I definitely don't want that flag to be inside an INI file. We don't need yet another flag which causes the language to behave differently under different circumstances. Can't you distinguish between __get and __set on the object and handle it differently that way? If not, the flag needs to somehow be set in code and not in an INI file with the default behavior to be NO, do not enable write support. This is a bad break in BC from such a minor version upgrade of 5.1.2 to 5.1.4. DanteI think that's a bug and not a feature. Why was this changed?It is called write support. I think we are going to add a flag so that one can specify whether write support is enabled or not.