Skip to content

simplexml_import_dom() return type is SimpleXMLElement|false not SimpleXMLElement|null #4536

@larsnystrom

Description

@larsnystrom

Bug report

The signature in functionMap.php is

'simplexml_import_dom' => ['SimpleXMLElement|false', 'node'=>'DOMNode', 'class_name='=>'string'],

And still, it looks like phpstan thinks the return type can be null (and not false), as can be seen in the linked playground. The error is only there for PHP 8, and not for 7.1-7.4.

Code snippet that reproduces the problem

https://phpstan.org/r/74fe87de-ea5a-4642-9577-0ecb1978da9c

Expected output

According to the documentation at php.net, the signature of simplexml_import_dom has not changed in PHP 8.0, so the code in the attached playground should not display an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions