php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80537 Wrong parameter type in DOMElement::removeAttributeNode stub
Submitted: 2020-12-21 08:48 UTC Modified: 2020-12-21 09:16 UTC
From: ondrej at mirtes dot cz Assigned: nikic (profile)
Status: Closed Package: Reflection related
PHP Version: 8.0.0 OS: N/A
Private report: No CVE-ID: None
 [2020-12-21 08:48 UTC] ondrej at mirtes dot cz
Description:
------------
The stub for this method looks like this (https://github.com/php/php-src/blob/4c5e47d113429773a885e78599e20cfe0490905b/ext/dom/php_dom.stub.php#L207-L208):

    /** @return DOMAttr|false */
    public function removeAttributeNode(string $qualifiedName) {}

But the method accepts DOMAttr: https://3v4l.org/dbST3

PHP documentation agrees: https://www.php.net/manual/en/domelement.removeattributenode.php

Originally reported as PHPStan bug: https://github.com/phpstan/phpstan/issues/4268

Test script:
---------------
<?php declare(strict_types = 1);

$document = new DOMDocument();
$document->loadXML('<x a="foo"/>');
/** @var DOMElement $element */
$element = $document->documentElement;
$attribute = $element->getAttributeNode('a');
$element->removeAttributeNode($attribute);
var_dump($document->saveHTML());


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-21 09:16 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2020-12-21 09:23 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 [2020-12-21 09:23 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=27e250880b46031755a6985c340a6fb2186b9271
Log: Fix bug #80537
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 03:01:27 2024 UTC