diff --git a/ext/dom/node.c b/ext/dom/node.c index 803237d96fb..5d4f0144c67 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -2548,7 +2548,7 @@ PHP_METHOD(Dom_Node, compareDocumentPosition) PHP_METHOD(Dom_Node, __construct) { - ZEND_UNREACHABLE(); + zend_throw_error(NULL, "Cannot directly construct %s, use document methods instead", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name)); } PHP_METHOD(DOMNode, __sleep) diff --git a/ext/dom/tests/gh16190.phpt b/ext/dom/tests/gh16190.phpt new file mode 100644 index 00000000000..d3d83b5eb49 --- /dev/null +++ b/ext/dom/tests/gh16190.phpt @@ -0,0 +1,18 @@ +--TEST-- +GH-16190 (Using reflection to call Dom\Node::__construct causes assertion failure) +--EXTENSIONS-- +dom +--FILE-- +invoke($doc); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Cannot directly construct Dom\XMLDocument, use document methods instead