Req #77290 [NEW]: asXML - fist argument behavior

From: Date: Wed, 12 Dec 2018 18:18:25 +0000
Subject: Req #77290 [NEW]: asXML - fist argument behavior
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218426@lists.php.net to get a copy of this message
From: lagodichyuriy at gmail dot com Operating system: Archlinux PHP version: 7.2.13 Package: SimpleXML related Bug Type: Feature/Change Request Bug description:asXML - fist argument behavior Description: ------------ Current asXML() behavior of the SimpleXMLElement object is not really neat: this method may accept "filename" as a first argument for data storing on a HDD. However, if a "filename" is empty (let's say "null" or empty string), this method will throw a warning about it. This logic asks from the programmer create very strange structures to avoid such warning messages: "if ($filename) { return $xml->asXML($filename); } else { return $xml->asXML(); }" Test script: --------------- <?php function example($file_path = null) { $xml = new \SimpleXMLElement('<data></data>'); return $xml->asXML($file_path); } example(); # will throw "PHP Warning: SimpleXMLElement::asXML(): Filename cannot be empty in ..." Expected result: ---------------- I suggest to make a "filename" as an optional argument for this method. Actual result: -------------- PHP Warning: SimpleXMLElement::asXML(): Filename cannot be empty in ... -- Edit bug report at https://bugs.php.net/bug.php?id=77290&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77290&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77290&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77290&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77290&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77290&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77290&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77290&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77290&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77290&r=support Expected behavior: https://bugs.php.net/fix.php?id=77290&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77290&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77290&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77290&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77290&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77290&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77290&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77290&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77290&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77290&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77290&r=mysqlcfg

« previous php.bugs (#218426) next »