-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
Hello
First of all - Thanks for the great open source tool!
We have some issues with the latest phpstan
$cpd = $this->document->createElement(self::CPD_ELEMENT_NAME);
if ($cpd === false) {
$this->generateException("Can not create element: %s", self::CPD_ELEMENT_NAME);
}
$result = $this->document->appendChild($cpd);
Error 1: "phpstan: Strict comparison using === between DOMElement and false will always evaluate to false."
Error 2: "phpstan: Parameter #1 $node of method DOMNode::appendChild() expects DOMNode, DOMElement|false given."
dom_c.php:
/**
* Create new element node
* @link https://php.net/manual/en/domdocument.createelement.php
* @param string $localName <p>
* The tag name of the element.
* </p>
* @param string $value [optional] <p>
* The value of the element. By default, an empty element will be created.
* You can also set the value later with DOMElement->nodeValue.
* </p>
* @return DOMElement|false A new instance of class DOMElement or false
* if an error occurred.
* @throws DOMException If invalid $localName
*/
public function createElement(
#[LanguageLevelTypeAware(['8.0' => 'string'], default: '')] $localName,
#[LanguageLevelTypeAware(['8.0' => 'string'], default: '')] $value = ''
) {}
Code snippet that reproduces the problem
Expected output
no error
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels