From: doctorrock83 at gmail dot com Operating system: Win32 PHP version: 5.2.9 PHP Bug Type: SimpleXML related Bug description: SimpleXmlElement __toString() not called on (string) cast
Description: ------------ If I extend SimpleXmlElement and add a __toString() method to it, that method is not called when I cast my object using (string)$obj. It is used however on implicit casts (e.g echo $sxmlObj) Reproduce code: --------------- class MyXml extends SimpleXMLElement { public function __toString() { return $this->asXML(); } public function export() { return (string)$this; } } $xml = new MyXml("<xml><some>xml</some></xml>"); echo $xml; // 1 $a = (string)$xml; echo $a; // 2 echo $xml->export(); // 3 Expected result: ---------------- 1 : xml returned 2 : xml returned 3: xml returned Actual result: -------------- 1 : OK 2: nothing is returned 3: nothing is returned -- Edit bug report at http://bugs.php.net/?id=48059&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48059&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48059&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48059&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48059&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48059&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48059&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48059&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48059&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48059&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48059&r=support Expected behavior: http://bugs.php.net/fix.php?id=48059&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48059&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48059&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48059&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48059&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48059&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48059&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48059&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48059&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48059&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48059&r=mysqlcfg