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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 06:01:32 2025 UTC