You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
but be aware that it is deprecated since PHP 8.1. We do not recommend its usage.
90
-
- PHP 7.4 introduces :doc:`the new magic method <https://php.net/manual/en/language.oop5.magic.php#object.unserialize>`
91
-
``__unserialize``, which changes the execution priority between
92
-
``__wakeup`` and itself when used. This can cause unexpected behaviour in
93
-
an Entity.
77
+
- An entity class must not be final nor read-only but
78
+
it may contain final methods or read-only properties.
94
79
- Any two entity classes in a class hierarchy that inherit
95
80
directly or indirectly from one another must not have a mapped
96
81
property with the same name. That is, if B inherits from A then B
97
82
must not have a mapped field with the same name as an already
98
83
mapped field that is inherited from A.
99
-
- An entity cannot make use of func_get_args() to implement variable parameters.
100
-
Generated proxies do not support this for performance reasons and your code might
101
-
actually fail to work when violating this restriction.
102
-
- Entity cannot access private/protected properties/methods of another entity of the same class or :doc:`do so safely <../cookbook/accessing-private-properties-of-the-same-class-from-different-instance>`.
103
84
104
85
Entities support inheritance, polymorphic associations, and
105
86
polymorphic queries. Both abstract and concrete classes can be
@@ -159,17 +140,13 @@ Serializing entities
159
140
160
141
Serializing entities can be problematic and is not really
161
142
recommended, at least not as long as an entity instance still holds
162
-
references to proxy objects or is still managed by an
163
-
EntityManager. If you intend to serialize (and unserialize) entity
164
-
instances that still hold references to proxy objects you may run
165
-
into problems with private properties because of technical
166
-
limitations. Proxy objects implement ``__sleep`` and it is not
167
-
possible for ``__sleep`` to return names of private properties in
168
-
parent classes. On the other hand it is not a solution for proxy
169
-
objects to implement ``Serializable`` because Serializable does not
170
-
work well with any potential cyclic object references (at least we
171
-
did not find a way yet, if you did, please contact us). The
172
-
``Serializable`` interface is also deprecated beginning with PHP 8.1.
143
+
references to proxy objects or is still managed by an EntityManager.
144
+
By default, serializing proxy objects does not initialize them. On
145
+
unserialization, resulting objects are detached from the entity
146
+
manager and cannot be initialiazed anymore. You can implement the
147
+
``__serialize()`` method if you want to change that behavior, but
148
+
then you need to ensure that you won't generate large serialized
149
+
object graphs and take care of circular associations.
0 commit comments