Complex classes like ClassMetadata often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ClassMetadata, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
24 | class ClassMetadata extends ComponentMetadata implements TableOwner |
||
25 | { |
||
26 | /** |
||
27 | * The name of the custom repository class used for the entity class. |
||
28 | * (Optional). |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $customRepositoryClassName; |
||
33 | |||
34 | /** |
||
35 | * READ-ONLY: Whether this class describes the mapping of a mapped superclass. |
||
36 | * |
||
37 | * @var boolean |
||
38 | */ |
||
39 | public $isMappedSuperclass = false; |
||
40 | |||
41 | /** |
||
42 | * READ-ONLY: Whether this class describes the mapping of an embeddable class. |
||
43 | * |
||
44 | * @var boolean |
||
45 | */ |
||
46 | public $isEmbeddedClass = false; |
||
47 | |||
48 | /** |
||
49 | * Whether this class describes the mapping of a read-only class. |
||
50 | * That means it is never considered for change-tracking in the UnitOfWork. |
||
51 | * It is a very helpful performance optimization for entities that are immutable, |
||
52 | * either in your domain or through the relation database (coming from a view, |
||
53 | * or a history table for example). |
||
54 | * |
||
55 | * @var boolean |
||
56 | */ |
||
57 | private $readOnly = false; |
||
58 | |||
59 | /** |
||
60 | * The names of all subclasses (descendants). |
||
61 | * |
||
62 | * @var array |
||
63 | */ |
||
64 | protected $subClasses = []; |
||
65 | |||
66 | /** |
||
67 | * READ-ONLY: The names of all embedded classes based on properties. |
||
68 | * |
||
69 | * @var array |
||
70 | */ |
||
71 | //public $embeddedClasses = []; |
||
|
|||
72 | |||
73 | /** |
||
74 | * The named queries allowed to be called directly from Repository. |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | protected $namedQueries = []; |
||
79 | |||
80 | /** |
||
81 | * READ-ONLY: The named native queries allowed to be called directly from Repository. |
||
82 | * |
||
83 | * A native SQL named query definition has the following structure: |
||
84 | * <pre> |
||
85 | * array( |
||
86 | * 'name' => <query name>, |
||
87 | * 'query' => <sql query>, |
||
88 | * 'resultClass' => <class of the result>, |
||
89 | * 'resultSetMapping' => <name of a SqlResultSetMapping> |
||
90 | * ) |
||
91 | * </pre> |
||
92 | * |
||
93 | * @var array |
||
94 | */ |
||
95 | public $namedNativeQueries = []; |
||
96 | |||
97 | /** |
||
98 | * READ-ONLY: The mappings of the results of native SQL queries. |
||
99 | * |
||
100 | * A native result mapping definition has the following structure: |
||
101 | * <pre> |
||
102 | * array( |
||
103 | * 'name' => <result name>, |
||
104 | * 'entities' => array(<entity result mapping>), |
||
105 | * 'columns' => array(<column result mapping>) |
||
106 | * ) |
||
107 | * </pre> |
||
108 | * |
||
109 | * @var array |
||
110 | */ |
||
111 | public $sqlResultSetMappings = []; |
||
112 | |||
113 | /** |
||
114 | * READ-ONLY: The registered lifecycle callbacks for entities of this class. |
||
115 | * |
||
116 | * @var array<string, array<string>> |
||
117 | */ |
||
118 | public $lifecycleCallbacks = []; |
||
119 | |||
120 | /** |
||
121 | * READ-ONLY: The registered entity listeners. |
||
122 | * |
||
123 | * @var array |
||
124 | */ |
||
125 | public $entityListeners = []; |
||
126 | |||
127 | /** |
||
128 | * READ-ONLY: The field names of all fields that are part of the identifier/primary key |
||
129 | * of the mapped entity class. |
||
130 | * |
||
131 | * @var string[] |
||
132 | */ |
||
133 | public $identifier = []; |
||
134 | |||
135 | /** |
||
136 | * READ-ONLY: The inheritance mapping type used by the class. |
||
137 | * |
||
138 | * @var string |
||
139 | */ |
||
140 | public $inheritanceType = InheritanceType::NONE; |
||
141 | |||
142 | /** |
||
143 | * READ-ONLY: The policy used for change-tracking on entities of this class. |
||
144 | * |
||
145 | * @var string |
||
146 | */ |
||
147 | public $changeTrackingPolicy = ChangeTrackingPolicy::DEFERRED_IMPLICIT; |
||
148 | |||
149 | /** |
||
150 | * READ-ONLY: The discriminator value of this class. |
||
151 | * |
||
152 | * <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies |
||
153 | * where a discriminator column is used.</b> |
||
154 | * |
||
155 | * @var mixed |
||
156 | * |
||
157 | * @see discriminatorColumn |
||
158 | */ |
||
159 | public $discriminatorValue; |
||
160 | |||
161 | /** |
||
162 | * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. |
||
163 | * |
||
164 | * <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies |
||
165 | * where a discriminator column is used.</b> |
||
166 | * |
||
167 | * @var array<string, string> |
||
168 | * |
||
169 | * @see discriminatorColumn |
||
170 | */ |
||
171 | public $discriminatorMap = []; |
||
172 | |||
173 | /** |
||
174 | * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE |
||
175 | * inheritance mappings. |
||
176 | * |
||
177 | * @var DiscriminatorColumnMetadata |
||
178 | */ |
||
179 | public $discriminatorColumn; |
||
180 | |||
181 | /** |
||
182 | * READ-ONLY: The primary table metadata. |
||
183 | * |
||
184 | * @var TableMetadata |
||
185 | */ |
||
186 | public $table; |
||
187 | |||
188 | /** |
||
189 | * READ-ONLY: An array of field names. Used to look up field names from column names. |
||
190 | * Keys are column names and values are field names. |
||
191 | * |
||
192 | * @var array<string, string> |
||
193 | */ |
||
194 | public $fieldNames = []; |
||
195 | |||
196 | /** |
||
197 | * READ-ONLY: The field which is used for versioning in optimistic locking (if any). |
||
198 | * |
||
199 | * @var FieldMetadata|null |
||
200 | */ |
||
201 | public $versionProperty; |
||
202 | |||
203 | /** |
||
204 | * NamingStrategy determining the default column and table names. |
||
205 | * |
||
206 | * @var NamingStrategy |
||
207 | */ |
||
208 | protected $namingStrategy; |
||
209 | |||
210 | /** |
||
211 | * Value generation plan is responsible for generating values for auto-generated fields. |
||
212 | * |
||
213 | * @var ValueGenerationPlan |
||
214 | */ |
||
215 | protected $valueGenerationPlan; |
||
216 | |||
217 | /** |
||
218 | * Initializes a new ClassMetadata instance that will hold the object-relational mapping |
||
219 | * metadata of the class with the given name. |
||
220 | * |
||
221 | * @param string $entityName The name of the entity class. |
||
222 | * @param ClassMetadataBuildingContext $metadataBuildingContext |
||
223 | */ |
||
224 | public function __construct( |
||
233 | |||
234 | /** |
||
235 | * @todo guilhermeblanco Remove once ClassMetadataFactory is finished |
||
236 | * |
||
237 | * @param string $className |
||
238 | */ |
||
239 | public function setClassName(string $className) |
||
243 | |||
244 | /** |
||
245 | * @return \ArrayIterator |
||
246 | */ |
||
247 | public function getColumnsIterator() : \ArrayIterator |
||
257 | |||
258 | /** |
||
259 | * @return \ArrayIterator |
||
260 | */ |
||
261 | public function getAncestorsIterator() : \ArrayIterator |
||
276 | |||
277 | /** |
||
278 | * @return string |
||
279 | */ |
||
280 | public function getRootClassName() : string |
||
287 | |||
288 | /** |
||
289 | * Handles metadata cloning nicely. |
||
290 | */ |
||
291 | public function __clone() |
||
301 | |||
302 | /** |
||
303 | * Creates a string representation of this instance. |
||
304 | * |
||
305 | * @return string The string representation of this instance. |
||
306 | * |
||
307 | * @todo Construct meaningful string representation. |
||
308 | */ |
||
309 | public function __toString() |
||
313 | |||
314 | /** |
||
315 | * Determines which fields get serialized. |
||
316 | * |
||
317 | * It is only serialized what is necessary for best unserialization performance. |
||
318 | * That means any metadata properties that are not set or empty or simply have |
||
319 | * their default value are NOT serialized. |
||
320 | * |
||
321 | * Parts that are also NOT serialized because they can not be properly unserialized: |
||
322 | * - reflectionClass |
||
323 | * |
||
324 | * @return array The names of all the fields that should be serialized. |
||
325 | */ |
||
326 | public function __sleep() |
||
401 | |||
402 | /** |
||
403 | * Restores some state that can not be serialized/unserialized. |
||
404 | * |
||
405 | * @param ReflectionService $reflectionService |
||
406 | * |
||
407 | * @return void |
||
408 | */ |
||
409 | public function wakeupReflection(ReflectionService $reflectionService) : void |
||
425 | |||
426 | /** |
||
427 | * Validates Identifier. |
||
428 | * |
||
429 | * @return void |
||
430 | * |
||
431 | * @throws MappingException |
||
432 | */ |
||
433 | public function validateIdentifier() : void |
||
444 | |||
445 | /** |
||
446 | * Validates field value generators. |
||
447 | */ |
||
448 | public function validateValueGenerators() : void |
||
470 | |||
471 | /** |
||
472 | * Validates association targets actually exist. |
||
473 | * |
||
474 | * @return void |
||
475 | * |
||
476 | * @throws MappingException |
||
477 | */ |
||
478 | public function validateAssociations() : void |
||
495 | |||
496 | /** |
||
497 | * Validates lifecycle callbacks. |
||
498 | * |
||
499 | * @param ReflectionService $reflectionService |
||
500 | * |
||
501 | * @return void |
||
502 | * |
||
503 | * @throws MappingException |
||
504 | */ |
||
505 | public function validateLifecycleCallbacks(ReflectionService $reflectionService) : void |
||
516 | |||
517 | /** |
||
518 | * Sets the change tracking policy used by this class. |
||
519 | * |
||
520 | * @param string $policy |
||
521 | * |
||
522 | * @return void |
||
523 | */ |
||
524 | public function setChangeTrackingPolicy(string $policy) : void |
||
528 | |||
529 | /** |
||
530 | * Checks whether a field is part of the identifier/primary key field(s). |
||
531 | * |
||
532 | * @param string $fieldName The field name. |
||
533 | * |
||
534 | * @return bool TRUE if the field is part of the table identifier/primary key field(s), FALSE otherwise. |
||
535 | */ |
||
536 | public function isIdentifier(string $fieldName) : bool |
||
548 | |||
549 | /** |
||
550 | * @return bool |
||
551 | */ |
||
552 | public function isIdentifierComposite() : bool |
||
556 | |||
557 | /** |
||
558 | * Gets the named query. |
||
559 | * |
||
560 | * @see ClassMetadata::$namedQueries |
||
561 | * |
||
562 | * @param string $queryName The query name. |
||
563 | * |
||
564 | * @return string |
||
565 | * |
||
566 | * @throws MappingException |
||
567 | */ |
||
568 | public function getNamedQuery($queryName) : string |
||
576 | |||
577 | /** |
||
578 | * Gets all named queries of the class. |
||
579 | * |
||
580 | * @return array |
||
581 | */ |
||
582 | public function getNamedQueries() : array |
||
586 | |||
587 | 578 | /** |
|
588 | * Gets the named native query. |
||
589 | 578 | * |
|
590 | 578 | * @see ClassMetadata::$namedNativeQueries |
|
591 | 578 | * |
|
592 | 578 | * @param string $queryName The query name. |
|
593 | 578 | * |
|
594 | * @return array |
||
595 | * |
||
596 | * @throws MappingException |
||
597 | */ |
||
598 | public function getNamedNativeQuery($queryName) : array |
||
606 | |||
607 | /** |
||
608 | * Gets all named native queries of the class. |
||
609 | * |
||
610 | * @return array |
||
611 | */ |
||
612 | 1 | public function getNamedNativeQueries() : array |
|
616 | |||
617 | /** |
||
618 | * Gets the result set mapping. |
||
619 | * |
||
620 | * @see ClassMetadata::$sqlResultSetMappings |
||
621 | * |
||
622 | * @param string $name The result set mapping name. |
||
623 | * |
||
624 | * @return array |
||
625 | * |
||
626 | * @throws MappingException |
||
627 | */ |
||
628 | public function getSqlResultSetMapping($name) |
||
636 | |||
637 | /** |
||
638 | * Gets all sql result set mappings of the class. |
||
639 | * |
||
640 | * @return array |
||
641 | */ |
||
642 | public function getSqlResultSetMappings() |
||
646 | 91 | ||
647 | /** |
||
648 | 91 | * Validates & completes the basic mapping information for field mapping. |
|
649 | 91 | * |
|
650 | * @param FieldMetadata $property |
||
651 | 91 | * |
|
652 | 91 | * @throws MappingException If something is wrong with the mapping. |
|
653 | */ |
||
654 | protected function validateAndCompleteFieldMapping(FieldMetadata $property) |
||
692 | |||
693 | 24 | /** |
|
694 | * Validates & completes the basic mapping information for field mapping. |
||
695 | 24 | * |
|
696 | 24 | * @param VersionFieldMetadata $property |
|
697 | * |
||
698 | * @throws MappingException If something is wrong with the mapping. |
||
699 | */ |
||
700 | protected function validateAndCompleteVersionFieldMapping(VersionFieldMetadata $property) |
||
724 | |||
725 | /** |
||
726 | * Validates & completes the basic mapping information that is common to all |
||
727 | * association mappings (one-to-one, many-ot-one, one-to-many, many-to-many). |
||
728 | * |
||
729 | * @param AssociationMetadata $property |
||
730 | * |
||
731 | * @throws MappingException If something is wrong with the mapping. |
||
732 | * @throws CacheException If entity is not cacheable. |
||
733 | */ |
||
734 | protected function validateAndCompleteAssociationMapping(AssociationMetadata $property) |
||
790 | |||
791 | /** |
||
792 | * Validates & completes a to-one association mapping. |
||
793 | 7 | * |
|
794 | * @param ToOneAssociationMetadata $property The association mapping to validate & complete. |
||
795 | * |
||
796 | * @throws \RuntimeException |
||
797 | 7 | * @throws MappingException |
|
798 | 1 | */ |
|
799 | protected function validateAndCompleteToOneAssociationMetadata(ToOneAssociationMetadata $property) |
||
876 | |||
877 | /** |
||
878 | * Validates & completes a to-many association mapping. |
||
879 | * |
||
880 | * @param ToManyAssociationMetadata $property The association mapping to validate & complete. |
||
881 | 1984 | * |
|
882 | * @throws MappingException |
||
883 | 1984 | */ |
|
884 | protected function validateAndCompleteToManyAssociationMetadata(ToManyAssociationMetadata $property) |
||
888 | |||
889 | 1988 | /** |
|
890 | * Validates & completes a one-to-one association mapping. |
||
891 | * |
||
892 | * @param OneToOneAssociationMetadata $property The association mapping to validate & complete. |
||
893 | */ |
||
894 | protected function validateAndCompleteOneToOneMapping(OneToOneAssociationMetadata $property) |
||
898 | |||
899 | 543 | /** |
|
900 | * Validates & completes a many-to-one association mapping. |
||
901 | 543 | * |
|
902 | * @param ManyToOneAssociationMetadata $property The association mapping to validate & complete. |
||
903 | 543 | * |
|
904 | 539 | * @throws MappingException |
|
905 | */ |
||
906 | protected function validateAndCompleteManyToOneMapping(ManyToOneAssociationMetadata $property) |
||
913 | |||
914 | /** |
||
915 | * Validates & completes a one-to-many association mapping. |
||
916 | * |
||
917 | * @param OneToManyAssociationMetadata $property The association mapping to validate & complete. |
||
918 | * |
||
919 | 385 | * @throws MappingException |
|
920 | */ |
||
921 | 385 | protected function validateAndCompleteOneToManyMapping(OneToManyAssociationMetadata $property) |
|
941 | |||
942 | 382 | /** |
|
943 | * Validates & completes a many-to-many association mapping. |
||
944 | 382 | * |
|
945 | 254 | * @param ManyToManyAssociationMetadata $property The association mapping to validate & complete. |
|
946 | 254 | * |
|
947 | * @throws MappingException |
||
948 | */ |
||
949 | 381 | protected function validateAndCompleteManyToManyMapping(ManyToManyAssociationMetadata $property) |
|
1032 | |||
1033 | /** |
||
1034 | * {@inheritDoc} |
||
1035 | */ |
||
1036 | 123 | public function getIdentifierFieldNames() |
|
1040 | |||
1041 | /** |
||
1042 | * Gets the name of the single id field. Note that this only works on |
||
1043 | * entity classes that have a single-field pk. |
||
1044 | * |
||
1045 | * @return string |
||
1046 | 267 | * |
|
1047 | * @throws MappingException If the class has a composite primary key. |
||
1048 | 267 | */ |
|
1049 | public function getSingleIdentifierFieldName() |
||
1061 | |||
1062 | /** |
||
1063 | * INTERNAL: |
||
1064 | * Sets the mapped identifier/primary key fields of this class. |
||
1065 | * Mainly used by the ClassMetadataFactory to assign inherited identifiers. |
||
1066 | 290 | * |
|
1067 | * @param array $identifier |
||
1068 | 290 | * |
|
1069 | * @return void |
||
1070 | */ |
||
1071 | public function setIdentifier(array $identifier) |
||
1075 | |||
1076 | /** |
||
1077 | * {@inheritDoc} |
||
1078 | */ |
||
1079 | 1032 | public function getIdentifier() |
|
1083 | |||
1084 | /** |
||
1085 | 1031 | * {@inheritDoc} |
|
1086 | 1026 | */ |
|
1087 | public function hasField($fieldName) |
||
1092 | |||
1093 | /** |
||
1094 | * Returns an array with identifier column names and their corresponding ColumnMetadata. |
||
1095 | * |
||
1096 | * @param EntityManagerInterface $em |
||
1097 | * |
||
1098 | * @return array |
||
1099 | */ |
||
1100 | public function getIdentifierColumns(EntityManagerInterface $em) : array |
||
1143 | |||
1144 | /** |
||
1145 | * Gets the name of the primary table. |
||
1146 | * |
||
1147 | * @return string|null |
||
1148 | */ |
||
1149 | 237 | public function getTableName() : ?string |
|
1153 | 237 | ||
1154 | /** |
||
1155 | * Gets primary table's schema name. |
||
1156 | * |
||
1157 | * @return string|null |
||
1158 | */ |
||
1159 | public function getSchemaName() : ?string |
||
1163 | |||
1164 | /** |
||
1165 | * Gets the table name to use for temporary identifier tables of this class. |
||
1166 | * |
||
1167 | 4 | * @return string |
|
1168 | */ |
||
1169 | 4 | public function getTemporaryIdTableName() : string |
|
1179 | |||
1180 | /** |
||
1181 | 5 | * Sets the mapped subclasses of this class. |
|
1182 | * |
||
1183 | 5 | * @todo guilhermeblanco Only used for ClassMetadataTest. Remove if possible! |
|
1184 | * |
||
1185 | * @param array $subclasses The names of all mapped subclasses. |
||
1186 | * |
||
1187 | * @return void |
||
1188 | */ |
||
1189 | public function setSubclasses(array $subclasses) : void |
||
1195 | |||
1196 | /** |
||
1197 | 15 | * @return array |
|
1198 | */ |
||
1199 | 15 | public function getSubClasses() : array |
|
1203 | 15 | ||
1204 | /** |
||
1205 | * Sets the inheritance type used by the class and its subclasses. |
||
1206 | * |
||
1207 | * @param integer $type |
||
1208 | * |
||
1209 | * @return void |
||
1210 | * |
||
1211 | 2 | * @throws MappingException |
|
1212 | */ |
||
1213 | 2 | public function setInheritanceType($type) : void |
|
1221 | |||
1222 | /** |
||
1223 | * Sets the override property mapping for an entity relationship. |
||
1224 | * |
||
1225 | * @param Property $property |
||
1226 | * |
||
1227 | 17 | * @return void |
|
1228 | * |
||
1229 | 17 | * @throws \RuntimeException |
|
1230 | * @throws MappingException |
||
1231 | * @throws CacheException |
||
1232 | */ |
||
1233 | 17 | public function setPropertyOverride(Property $property) : void |
|
1300 | |||
1301 | 47 | /** |
|
1302 | 47 | * Checks if this entity is the root in any entity-inheritance-hierarchy. |
|
1303 | * |
||
1304 | * @return bool |
||
1305 | */ |
||
1306 | 47 | public function isRootEntity() |
|
1310 | 47 | ||
1311 | 3 | /** |
|
1312 | * Checks whether a mapped field is inherited from a superclass. |
||
1313 | * |
||
1314 | * @param string $fieldName |
||
1315 | * |
||
1316 | * @return boolean TRUE if the field is inherited, FALSE otherwise. |
||
1317 | 312 | */ |
|
1318 | public function isInheritedProperty($fieldName) |
||
1324 | |||
1325 | /** |
||
1326 | 312 | * {@inheritdoc} |
|
1327 | 171 | */ |
|
1328 | public function setTable(TableMetadata $table) : void |
||
1336 | 64 | ||
1337 | /** |
||
1338 | * Checks whether the given type identifies an inheritance type. |
||
1339 | * |
||
1340 | 309 | * @param integer $type |
|
1341 | 309 | * |
|
1342 | * @return boolean TRUE if the given type identifies an inheritance type, FALSe otherwise. |
||
1343 | 309 | */ |
|
1344 | 30 | private function isInheritanceType($type) |
|
1351 | 1 | ||
1352 | /** |
||
1353 | * @param string $columnName |
||
1354 | * |
||
1355 | 308 | * @return LocalColumnMetadata|null |
|
1356 | */ |
||
1357 | 308 | public function getColumn(string $columnName): ?LocalColumnMetadata |
|
1367 | |||
1368 | /** |
||
1369 | * Add a property mapping. |
||
1370 | 270 | * |
|
1371 | * @param Property $property |
||
1372 | 270 | * |
|
1373 | * @throws \RuntimeException |
||
1374 | 264 | * @throws MappingException |
|
1375 | 194 | * @throws CacheException |
|
1376 | */ |
||
1377 | public function addProperty(Property $property) |
||
1429 | |||
1430 | /** |
||
1431 | 264 | * INTERNAL: |
|
1432 | * Adds a property mapping without completing/validating it. |
||
1433 | 264 | * This is mainly used to add inherited property mappings to derived classes. |
|
1434 | 17 | * |
|
1435 | 13 | * @param Property $property |
|
1436 | * |
||
1437 | * @return void |
||
1438 | 17 | */ |
|
1439 | public function addInheritedProperty(Property $property) |
||
1474 | 29 | ||
1475 | /** |
||
1476 | * INTERNAL: |
||
1477 | * Adds a named query to this class. |
||
1478 | * |
||
1479 | 119 | * @param string $name |
|
1480 | * @param string $query |
||
1481 | * |
||
1482 | * @return void |
||
1483 | * |
||
1484 | * @throws MappingException |
||
1485 | */ |
||
1486 | public function addNamedQuery(string $name, string $query) |
||
1494 | |||
1495 | 126 | /** |
|
1496 | * INTERNAL: |
||
1497 | 110 | * Adds a named native query to this class. |
|
1498 | 20 | * |
|
1499 | * @param string $name |
||
1500 | * @param string $query |
||
1501 | 110 | * @param array $queryMapping |
|
1502 | 110 | * |
|
1503 | * @return void |
||
1504 | 110 | * |
|
1505 | 17 | * @throws MappingException |
|
1506 | */ |
||
1507 | 17 | public function addNamedNativeQuery(string $name, string $query, array $queryMapping) |
|
1523 | |||
1524 | 110 | /** |
|
1525 | * INTERNAL: |
||
1526 | 110 | * Adds a sql result set mapping to this class. |
|
1527 | 110 | * |
|
1528 | 2 | * @param array $resultMapping |
|
1529 | * |
||
1530 | * @return void |
||
1531 | 110 | * |
|
1532 | 6 | * @throws MappingException |
|
1533 | */ |
||
1534 | public function addSqlResultSetMapping(array $resultMapping) |
||
1579 | |||
1580 | /** |
||
1581 | * Registers a custom repository class for the entity class. |
||
1582 | * |
||
1583 | * @param string|null $repositoryClassName The class name of the custom mapper. |
||
1584 | * |
||
1585 | * @return void |
||
1586 | */ |
||
1587 | public function setCustomRepositoryClassName(?string $repositoryClassName) |
||
1591 | 1 | ||
1592 | /** |
||
1593 | * @return string|null |
||
1594 | 369 | */ |
|
1595 | public function getCustomRepositoryClassName() : ?string |
||
1599 | |||
1600 | /** |
||
1601 | * Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event. |
||
1602 | * |
||
1603 | * @param string $lifecycleEvent |
||
1604 | * |
||
1605 | * @return boolean |
||
1606 | */ |
||
1607 | public function hasLifecycleCallbacks($lifecycleEvent) |
||
1611 | |||
1612 | /** |
||
1613 | * Gets the registered lifecycle callbacks for an event. |
||
1614 | * |
||
1615 | * @param string $event |
||
1616 | * |
||
1617 | * @return array |
||
1618 | */ |
||
1619 | 108 | public function getLifecycleCallbacks($event) |
|
1623 | 108 | ||
1624 | /** |
||
1625 | * Adds a lifecycle callback for entities of this class. |
||
1626 | * |
||
1627 | * @param string $callback |
||
1628 | 51 | * @param string $event |
|
1629 | * |
||
1630 | 51 | * @return void |
|
1631 | */ |
||
1632 | public function addLifecycleCallback($callback, $event) |
||
1640 | |||
1641 | /** |
||
1642 | * Sets the lifecycle callbacks for entities of this class. |
||
1643 | * Any previously registered callbacks are overwritten. |
||
1644 | * |
||
1645 | * @param array $callbacks |
||
1646 | * |
||
1647 | * @return void |
||
1648 | 43 | */ |
|
1649 | public function setLifecycleCallbacks(array $callbacks) : void |
||
1653 | |||
1654 | 1 | /** |
|
1655 | * Adds a entity listener for entities of this class. |
||
1656 | * |
||
1657 | * @param string $eventName The entity lifecycle event. |
||
1658 | * @param string $class The listener class. |
||
1659 | * @param string $method The listener callback method. |
||
1660 | * |
||
1661 | * @return void |
||
1662 | 322 | * |
|
1663 | * @throws \Doctrine\ORM\Mapping\MappingException |
||
1664 | 322 | */ |
|
1665 | public function addEntityListener(string $eventName, string $class, string $method) : void |
||
1686 | |||
1687 | /** |
||
1688 | 322 | * Sets the discriminator column definition. |
|
1689 | * |
||
1690 | * @param DiscriminatorColumnMetadata $discriminatorColumn |
||
1691 | * |
||
1692 | * @return void |
||
1693 | * |
||
1694 | * @throws MappingException |
||
1695 | * |
||
1696 | * @see getDiscriminatorColumn() |
||
1697 | */ |
||
1698 | 397 | public function setDiscriminatorColumn(DiscriminatorColumnMetadata $discriminatorColumn) : void |
|
1714 | |||
1715 | /** |
||
1716 | 1304 | * Sets the discriminator values used by this class. |
|
1717 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. |
||
1718 | 1304 | * |
|
1719 | * @param array $map |
||
1720 | * |
||
1721 | * @return void |
||
1722 | * |
||
1723 | * @throws MappingException |
||
1724 | */ |
||
1725 | public function setDiscriminatorMap(array $map) : void |
||
1731 | |||
1732 | /** |
||
1733 | * Adds one entry of the discriminator map with a new class and corresponding name. |
||
1734 | * |
||
1735 | * @param string|int $name |
||
1736 | * @param string $className |
||
1737 | * |
||
1738 | 1199 | * @return void |
|
1739 | * |
||
1740 | 1199 | * @throws MappingException |
|
1741 | */ |
||
1742 | public function addDiscriminatorMapClass($name, string $className) : void |
||
1760 | |||
1761 | 1063 | /** |
|
1762 | * @return ValueGenerationPlan |
||
1763 | */ |
||
1764 | public function getValueGenerationPlan() : ValueGenerationPlan |
||
1768 | |||
1769 | 308 | /** |
|
1770 | * @param ValueGenerationPlan $valueGenerationPlan |
||
1771 | 308 | */ |
|
1772 | public function setValueGenerationPlan(ValueGenerationPlan $valueGenerationPlan) : void |
||
1776 | |||
1777 | /** |
||
1778 | * Checks whether the class has a named query with the given query name. |
||
1779 | 71 | * |
|
1780 | * @param string $queryName |
||
1781 | 71 | * |
|
1782 | * @return boolean |
||
1783 | */ |
||
1784 | public function hasNamedQuery($queryName) : bool |
||
1788 | |||
1789 | /** |
||
1790 | 72 | * Checks whether the class has a named native query with the given query name. |
|
1791 | * |
||
1792 | 72 | * @param string $queryName |
|
1793 | * |
||
1794 | * @return boolean |
||
1795 | */ |
||
1796 | public function hasNamedNativeQuery($queryName) : bool |
||
1800 | |||
1801 | /** |
||
1802 | * Checks whether the class has a named native query with the given query name. |
||
1803 | * |
||
1804 | * @param string $name |
||
1805 | * |
||
1806 | * @return boolean |
||
1807 | */ |
||
1808 | public function hasSqlResultSetMapping($name) : bool |
||
1812 | 1781 | ||
1813 | /** |
||
1814 | * Marks this class as read only, no change tracking is applied to it. |
||
1815 | * |
||
1816 | * @return void |
||
1817 | */ |
||
1818 | public function asReadOnly() : void |
||
1822 | 1382 | ||
1823 | /** |
||
1824 | * Whether this class is read only or not. |
||
1825 | * |
||
1826 | * @return bool |
||
1827 | */ |
||
1828 | public function isReadOnly() : bool |
||
1832 | 7 | ||
1833 | 6 | /** |
|
1834 | 7 | * @return bool |
|
1835 | */ |
||
1836 | public function isVersioned() : bool |
||
1840 | |||
1841 | /** |
||
1842 | * Map Embedded Class |
||
1843 | * |
||
1844 | * @param array $mapping |
||
1845 | * |
||
1846 | * @throws MappingException |
||
1847 | * @return void |
||
1848 | 2 | */ |
|
1849 | public function mapEmbedded(array $mapping) : void |
||
1863 | |||
1864 | 391 | /** |
|
1865 | * Inline the embeddable class |
||
1866 | 391 | * |
|
1867 | * @param string $property |
||
1868 | 391 | * @param ClassMetadata $embeddable |
|
1869 | 75 | */ |
|
1870 | public function inlineEmbeddable($property, ClassMetadata $embeddable) : void |
||
1894 | } |
||
1895 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.