Skip to content

Wrong access reported for DOMDocument::documentElement #3477

@schlessera

Description

@schlessera

Bug report

We are extending DOMDocument we a custom wrapper that adds all sorts of convenience functionality.

The latest PHPStan v0.12.28 throws errors though that seem incorrect, and didn't previously get flagged:

Image 2020-06-16 at 8 08 39 AM

The documentElement is public according to the PHP Docs, and the code works as expected.

Any usage of the $documentElement property in our code base triggers this, even across packages. Here's one example of code that produces this error:
Image 2020-06-16 at 8 17 23 AM

Code snippet that reproduces the problem

I tried replicating the issue here, but couldn't get the same error to be thrown: https://phpstan.org/r/02668645-c6b7-43d3-8c34-d41d6937e253

Expected output

Using the DOMDocument::$documentElement public property from an extending child class shouldn't throw 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