|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52382 NULL in method arguments is casted to string?
Submitted: 2010-07-20 09:46 UTC Modified: 2010-07-20 09:59 UTC
From: giorgio dot liscio at email dot it Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.3.2 OS: all ? xp x64
Private report: No CVE-ID: None
 [2010-07-20 09:46 UTC] giorgio dot liscio at email dot it
hi, test this:

header("Content-Type: text/plain");

$doc = new \DOMDocument()
$doc->appendChild($doc->createElement("root", NULL));
echo $doc->saveXML();

echo "\n\nshould be equivalent to:\n\n";

$doc = new \DOMDocument()
echo $doc->saveXML();

i hope other DOM methods will work good... otherwise fix is needed

thank you!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-20 09:59 UTC]
-Status: Open +Status: Bogus
 [2010-07-20 09:59 UTC]
They're not equivalent: you're providing a value for the "value"
parameter to DOMDocument::createElement(), so yes, it will get coerced
into an empty string using PHP's usual type juggling mechanism.
 [2010-07-20 16:13 UTC] giorgio dot liscio at email dot it
i don't think that is like you think

if i extend appendChild

override appendChild($name, $content = NULL, $myNewArg = NULL)

if i want to skip the second argument i can not

or another issue:

as php doc says

DOMImplementation->createDocument  ([  string $namespaceURI = NULL  [,  string $qualifiedName = NULL  [,  DOMDocumentType $doctype = NULL  ]]] )

third parameter is optional (=NULL)

but if i do

$x->createDocument(null, null, null); to create an empty document 

exception is thrown:

Argument 3 passed to DOMImplementation::createDocument() must be an instance of DOMDocumentType, null given

if i do createDocument(); obviously works, but the concept of "skipping not required parameters with null" is not respected
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jul 31 00:01:23 2021 UTC