Skip to content

DOMDocument signatures seem to be broken #3478

@schlessera

Description

@schlessera

Bug report

When overriding DOMDocument::saveHTML(), I get rather random signature mismatches that have nothing to do with the documented signature.

Parameter #1 $node (DOMNode|null) of method ExtendedDocument::saveHTML() is not contravariant with parameter #1 $node (mixed) of method DOMDocument::saveHTML().

Even worse - just returning parent::saveHTML() from the extending method, PHPStan claims the return type does not match, even though it deduced it itself from the parent.

Method ExtendedDocument::saveHTML() should return string but returns string|false.

Code snippet that reproduces the problem

This code snippet replicates the problem: https://phpstan.org/r/f2176152-5861-4451-a9b4-da32795c2b8f

Expected output

The above snippet should not throw any errors.

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