Skip to content

Using reflection to call Dom\Node::__construct causes assertion failure #16190

Closed
@YuanchengJiang

Description

@YuanchengJiang

Description

The following code:

<?php
$dom = Dom\HTMLDocument::createFromString(<<<HTML
<svg width="1" xmlns:xlink='http://www.w3.org/1999/xlink'>
HTML);
foreach (['svg', 'use', 'mo'] as $tag) {
$el = $dom->getElementsByTagName($tag)[0];
foreach ($el->attributes as $attribute) {
}
}
$rm = new ReflectionMethod($attribute, "__construct");
try {
var_dump($rm->invoke($attribute, 0, 1, 2));
} catch (ReflectionException $exception) {
}

Resulted in this output:

/php-src/ext/dom/node.c:2554: void zim_Dom_Node___construct(zend_execute_data *, zval *): Assertion `0' failed.
Aborted (core dumped)

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions