Skip to content

Elements extending SimpleXMLElement is seen as having all private properties #2910

@AJenbo

Description

@AJenbo

Bug report

When trying to get properties on an object that extends SimpleXMLElement you get an error stating that it's properties are private. This is a bit odd as the properties on SimpleXMLElement aren't private.

| 17 | Access to private property $message of parent class SimpleXMLElement. |

Code snippet that reproduces the problem

https://phpstan.org/r/9152ee63-93e2-47ae-91f3-c624331838fe

<?php declare(strict_types = 1);

class HelloWorld extends SimpleXMLElement
{
	public function getSelf(): self
	{
		return new self('');
	}
	
	public function getSimpleXMLElement(): SimpleXMLElement
	{
		return new self('');
	}
	
	public function fail(): void
	{
		echo $this->getSelf()->message;
	}
	
	public function success(): void
	{
		echo $this->getSimpleXMLElement()->message;
	}
}

Expected output

[OK] No errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions