Skip to content

Commit 807a74a

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-16190: Using reflection to call Dom\Node::__construct causes assertion failure
2 parents 2609127 + 3be6ff6 commit 807a74a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ext/dom/node.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2548,7 +2548,7 @@ PHP_METHOD(Dom_Node, compareDocumentPosition)
25482548

25492549
PHP_METHOD(Dom_Node, __construct)
25502550
{
2551-
ZEND_UNREACHABLE();
2551+
zend_throw_error(NULL, "Cannot directly construct %s, use document methods instead", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name));
25522552
}
25532553

25542554
PHP_METHOD(DOMNode, __sleep)

ext/dom/tests/gh16190.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
GH-16190 (Using reflection to call Dom\Node::__construct causes assertion failure)
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
$doc = Dom\XMLDocument::createEmpty();
9+
$rm = new ReflectionMethod($doc, '__construct');
10+
try {
11+
$rm->invoke($doc);
12+
} catch (Error $e) {
13+
echo $e->getMessage(), "\n";
14+
}
15+
16+
?>
17+
--EXPECT--
18+
Cannot directly construct Dom\XMLDocument, use document methods instead

0 commit comments

Comments
 (0)