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

Open
opened 2026-01-22 13:04:32 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 15, 2010).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user tech13:

In the note in
http://www.doctrine-project.org/docs/orm/2.0/en/reference/working-with-objects.html#merging-entities
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.

<?php

class A {
    private $a = null;

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

class B extends A {}

$b = new B();
$b->setValue("B");
var_dump($b);

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

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

Originally created by @doctrinebot on GitHub (Dec 15, 2010). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user tech13: In the note in http://www.doctrine-project.org/docs/orm/2.0/en/reference/working-with-objects.html#merging-entities 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. ``` <?php class A { private $a = null; public function setValue($value) { $this->a = $value; } } class B extends A {} $b = new B(); $b->setValue("B"); var_dump($b); $c = unserialize(serialize($b)); var_dump($c); ``` The output suggests private variables are serialized, and are restored fine
admin added the BugInvalid labels 2026-01-22 13:04:32 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1169