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
Copy file name to clipboardexpand all lines: docs/en/reference/limitations-and-known-issues.rst
+6-7
Original file line number
Diff line number
Diff line change
@@ -136,18 +136,17 @@ ORM:
136
136
Using Traits in Entity Classes
137
137
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138
138
139
-
There is no real "official" statement whether or to which extent traits
140
-
are supported in entity or mapped superclasses.
139
+
The use of traits in entity or mapped superclasses, at least when they
140
+
include mapping configuration or mapped fields, is currently not
141
+
endorsed by the Doctrine project. The reasons for this are as follows.
141
142
142
143
Traits were added in PHP 5.4 more than 10 years ago, but at the same time
143
144
more than two years after the initial Doctrine 2 release and the time where
144
145
core components were designed.
145
146
146
147
In fact, this documentation mentions traits only in the context of
147
-
:doc:`overriding field association mappings in subclasses <tutorials/override-field-association-mappings-in-subclasses>`. Also, the
148
-
tests in the ORM codebase (as of writing) cover traits only in two (!) places,
149
-
namely the aforementioned override and in an edge-case for a tool that will be
150
-
removed in Doctrine 3.0.
148
+
:doc:`overriding field association mappings in subclasses <tutorials/override-field-association-mappings-in-subclasses>`. Coverage
149
+
of traits in test cases is practically nonexistent.
151
150
152
151
Thus, you should at least be aware that when using traits in your entity and
153
152
mapped superclasses, you will be in uncharted terrain.
@@ -168,7 +167,7 @@ have produced, this is probably fine.
168
167
169
168
However, to mention known limitations, it is currently not possible to use "class" level
170
169
`annotations <https://github.com/doctrine/orm/pull/1517>` or `attributes <https://github.com/doctrine/orm/issues/8868>` on traits, and attempts to improve parser support
171
-
for traits as `here <https://github.com/doctrine/annotations/pull/102>` or `there <https://github.com/doctrine/annotations/pull/63>` have been abandoned.
170
+
for traits as `here <https://github.com/doctrine/annotations/pull/102>` or `there <https://github.com/doctrine/annotations/pull/63>` have been abandoned due to complexity.
172
171
173
172
XML mapping configuration probably needs to completely re-configure or otherwise
174
173
copy-and-paste configuration for fields used from traits.
0 commit comments