DDC-940: Entities can / can not have private properties #5470

doctrinebot opened this Issue Dec 15, 2010 · 2 comments

3 participants


Jira issue originally created by user tech13:

In the note in
It appears to state that private variables are not serialized for child objects

If this is the only reason entities can't have private properties, then this restriction is no longer valid, or possibly be reconsidered.


class A {
    private $a = null;

    public function setValue($value) {
        $this->a = $value;

class B extends A {}

$b = new B();

$c = unserialize(serialize($b));

The output suggests private variables are serialized, and are restored fine


This totally correct behavior of PHP language. private variable are not visible for class that extend parent, if you want to see them you need to mark them as protected.

Doctrine member

Indeed: https://3v4l.org/Ha3qj

Also, this was already fixed (we deal with merging private state, AFAIK).

Closing, unless somebody comes up with a failing test case.

@Ocramius Ocramius closed this Dec 9, 2015
@Ocramius Ocramius self-assigned this Dec 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment