Bug #80599 [NEW]: Wrong type signature for DOMElement methods
| From: | jules dot bernable at gmail dot com | Date: | Wed, 06 Jan 2021 19:11:57 +0000 |
| Subject: | Bug #80599 [NEW]: Wrong type signature for DOMElement methods | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-231417@lists.php.net to get a copy of this message | ||
From: jules dot bernable at gmail dot com
Operating system: debian
PHP version: 8.0.0
Package: DOM XML related
Bug Type: Bug
Bug description:Wrong type signature for DOMElement methods
Description:
------------
In addition to https://bugs.php.net/bug.php?id=80537
The signature for the following methods :
* hasAttributeNS
* getAttributeNS
* setAttributeNS
* removeAttributeNS
* getAttributeNodeNS
Report their first argument as a nullable string. This is not what is
documented and passing null as the first argument to these method do
throw a TypeError.
Test script:
---------------
<?php declare(strict_types=1);
$el = new class('foo') extends DOMElement {
public function hasAttributeNS(string $namespace , string $localName):
bool {
return true;
}
};
$el = new class('foo') extends DOMElement {
public function getAttributeNS(string $namespace , string $localName):
string {
return 'bar';
}
};
$el = new class('foo') extends DOMElement {
public function setAttributeNS(string $namespace, string
$qualifiedName, string $value): void {}
};
// etc...
Actual result:
--------------
PHP Fatal error: Declaration of
DOMElement@anonymous::hasAttributeNS(string $namespaceURI, string
$localName): bool must be compatible with
DOMElement::hasAttributeNS(?string $namespace, string $localName) in
...
PHP Fatal error: Declaration of
DOMElement@anonymous::getAttributeNS(string $namespaceURI, string
$localName): string must be compatible with
DOMElement::getAttributeNS(?string $namespace, string $localName) in
...
PHP Fatal error: Declaration of
DOMElement@anonymous::setAttributeNS(string $namespace, string
$qualifiedName, string $value): void must be compatible with
DOMElement::setAttributeNS(?string $namespace, string $qualifiedName,
string $value) in ...
// etc...
--
Edit bug report at https://bugs.php.net/bug.php?id=80599&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80599&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80599&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80599&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80599&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80599&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80599&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80599&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80599&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80599&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80599&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80599&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80599&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80599&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80599&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80599&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80599&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80599&r=mysqlcfg