How to properly inherit an entity from another entity? I have an AbstractPerson abstract entity in which there are certain properties, a Person entity (an empty object with no properties) that inherits AbstractPerson . We populate Person and end up with a Person object with the filled AbstractPerson properties in the debugger like this:

AppBundle\Entity\Person(переменная $owner) -> *AbstractPerson*id=null -> *AbstractPerson*type='my_type' 

When the AbstractPerson object was just an entity ( not abstract ), then the object was null (even when the type property is filled)

 AppBundle\Entity\AbstractPerson(переменная $owner) -> null 

What could be the problem?

    1 answer 1

    Based on your question, I can assume that you called the constructor for the Person class and the resulting object was written to the $ owner variable. The $ owner variable now contains an object of class Person and, accordingly, all fields that have been filled in or declared by default.

    The AbstractPerson class is abstract and declared using the abstract keyword. The constructor of this class cannot be called because it will result in an error.

    You cannot create objects of abstract classes, they are designed as templates for inheritance.

    Since the object was not created, the $ owner variable is null. Read more here http://php.net/manual/ru/language.oop5.php