Skip to content

Commit

Permalink
Make createDocument() $namespace nullable
Browse files Browse the repository at this point in the history
According to the DOM specification, this argument should be
nullable. It's also supposed to be a required argument, but
not changing that at this point.
  • Loading branch information
nikic committed Feb 9, 2021
1 parent ab92ffe commit 3549f48
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ext/dom/domimplementation.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ PHP_METHOD(DOMImplementation, createDocument)
char *prefix = NULL, *localname = NULL;
dom_object *doctobj;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ssO!", &uri, &uri_len, &name, &name_len, &node, dom_documenttype_class_entry) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!sO!", &uri, &uri_len, &name, &name_len, &node, dom_documenttype_class_entry) == FAILURE) {
RETURN_THROWS();
}

Expand Down
2 changes: 1 addition & 1 deletion ext/dom/php_dom.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function hasFeature(string $feature, string $version) {}
public function createDocumentType(string $qualifiedName, string $publicId = "", string $systemId = "") {}

/** @return DOMDocument|false */
public function createDocument(string $namespace = "", string $qualifiedName = "", ?DOMDocumentType $doctype = null) {}
public function createDocument(?string $namespace = null, string $qualifiedName = "", ?DOMDocumentType $doctype = null) {}
}

class DOMDocumentFragment implements DOMParentNode
Expand Down
4 changes: 2 additions & 2 deletions ext/dom/php_dom_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 72c2add8db9af8f90e84997a2a5ca6743268fae8 */
* Stub hash: f4f6923a713a51d2944a21a123967343320be15c */

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 1)
ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0)
Expand Down Expand Up @@ -106,7 +106,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMImplementation_createDocumentType, 0, 0,
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMImplementation_createDocument, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, namespace, IS_STRING, 0, "\"\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, namespace, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, qualifiedName, IS_STRING, 0, "\"\"")
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, doctype, DOMDocumentType, 1, "null")
ZEND_END_ARG_INFO()
Expand Down
1 change: 1 addition & 0 deletions ext/dom/tests/DOMImplementation_createDocument_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include('skipif.inc');
?>
--FILE--
<?php
declare(strict_types=1);
$x = new DOMImplementation();
$doc = $x->createDocument(null, 'html');
echo $doc->saveHTML();
Expand Down

0 comments on commit 3549f48

Please sign in to comment.