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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: giorgio dot liscio at email dot it
New email:
PHP Version: OS:

 

 [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-2020 The PHP Group
All rights reserved.
Last updated: Tue Nov 24 10:01:23 2020 UTC