php.net |  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
28 - 4 = ?
Subscribe to this entry?

 
 [2010-07-20 09:46 UTC] giorgio dot liscio at email dot it
Description:
------------
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()
$doc->appendChild($doc->createElement("root"));
echo $doc->saveXML();

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

thank you!


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-20 09:59 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2010-07-20 09:59 UTC] aharvey@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 08:01:27 2024 UTC