Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added failing test for derived class #83

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

exeba
Copy link

@exeba exeba commented May 6, 2020

When a derived class redeclares a private member of the base class, the
"Exporter" class fails to recognize that.

When a derived class redeclares a private member of the base class, the
"Exporter" class fails to recognize that.
@exeba
Copy link
Author

exeba commented May 6, 2020

sebastianbergmann/exporter#35 will make tests pass

@sebastianbergmann
Copy link
Owner

Even with sebastianbergmann/exporter#35, I do not understand what it is you are trying to report.

@exeba
Copy link
Author

exeba commented May 6, 2020

class Base 
{
    private $privateField;
    
    public function __construct($value)
    {
        $this->privateField = $value;
    }

}

class Derived extends Base 
{
    private $privateField;

    public function __construct($value, $parentValue)
    {
        parent::__consturct($parentValue);
        $this->privateField = $value;
    }
}

$object1 = new Derived(10, 200);
$object2 = new Derived(100, 200);

The two objects should be considered different, but since Derived declares a private field that already exists in Base, the field by field comparison considers only the $privateField in the Base class, ingoring the one in Derived.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants