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 |
||
54 | class ClassMetadata implements BaseClassMetadata |
||
55 | { |
||
56 | /* The Id generator types. */ |
||
57 | /** |
||
58 | * AUTO means Doctrine will automatically create a new \MongoDB\BSON\ObjectId instance for us. |
||
59 | */ |
||
60 | public const GENERATOR_TYPE_AUTO = 1; |
||
61 | |||
62 | /** |
||
63 | * INCREMENT means a separate collection is used for maintaining and incrementing id generation. |
||
64 | * Offers full portability. |
||
65 | */ |
||
66 | public const GENERATOR_TYPE_INCREMENT = 2; |
||
67 | |||
68 | /** |
||
69 | * UUID means Doctrine will generate a uuid for us. |
||
70 | */ |
||
71 | public const GENERATOR_TYPE_UUID = 3; |
||
72 | |||
73 | /** |
||
74 | * ALNUM means Doctrine will generate Alpha-numeric string identifiers, using the INCREMENT |
||
75 | * generator to ensure identifier uniqueness |
||
76 | */ |
||
77 | public const GENERATOR_TYPE_ALNUM = 4; |
||
78 | |||
79 | /** |
||
80 | * CUSTOM means Doctrine expect a class parameter. It will then try to initiate that class |
||
81 | * and pass other options to the generator. It will throw an Exception if the class |
||
82 | * does not exist or if an option was passed for that there is not setter in the new |
||
83 | * generator class. |
||
84 | * |
||
85 | * The class will have to be a subtype of AbstractIdGenerator. |
||
86 | */ |
||
87 | public const GENERATOR_TYPE_CUSTOM = 5; |
||
88 | |||
89 | /** |
||
90 | * NONE means Doctrine will not generate any id for us and you are responsible for manually |
||
91 | * assigning an id. |
||
92 | */ |
||
93 | public const GENERATOR_TYPE_NONE = 6; |
||
94 | |||
95 | /** |
||
96 | * Default discriminator field name. |
||
97 | * |
||
98 | * This is used for associations value for associations where a that do not define a "targetDocument" or |
||
99 | * "discriminatorField" option in their mapping. |
||
100 | */ |
||
101 | public const DEFAULT_DISCRIMINATOR_FIELD = '_doctrine_class_name'; |
||
102 | |||
103 | public const REFERENCE_ONE = 1; |
||
104 | public const REFERENCE_MANY = 2; |
||
105 | public const EMBED_ONE = 3; |
||
106 | public const EMBED_MANY = 4; |
||
107 | public const MANY = 'many'; |
||
108 | public const ONE = 'one'; |
||
109 | |||
110 | /** |
||
111 | * The types of storeAs references |
||
112 | */ |
||
113 | public const REFERENCE_STORE_AS_ID = 'id'; |
||
114 | public const REFERENCE_STORE_AS_DB_REF = 'dbRef'; |
||
115 | public const REFERENCE_STORE_AS_DB_REF_WITH_DB = 'dbRefWithDb'; |
||
116 | public const REFERENCE_STORE_AS_REF = 'ref'; |
||
117 | |||
118 | /* The inheritance mapping types */ |
||
119 | /** |
||
120 | * NONE means the class does not participate in an inheritance hierarchy |
||
121 | * and therefore does not need an inheritance mapping type. |
||
122 | */ |
||
123 | public const INHERITANCE_TYPE_NONE = 1; |
||
124 | |||
125 | /** |
||
126 | * SINGLE_COLLECTION means the class will be persisted according to the rules of |
||
127 | * <tt>Single Collection Inheritance</tt>. |
||
128 | */ |
||
129 | public const INHERITANCE_TYPE_SINGLE_COLLECTION = 2; |
||
130 | |||
131 | /** |
||
132 | * COLLECTION_PER_CLASS means the class will be persisted according to the rules |
||
133 | * of <tt>Concrete Collection Inheritance</tt>. |
||
134 | */ |
||
135 | public const INHERITANCE_TYPE_COLLECTION_PER_CLASS = 3; |
||
136 | |||
137 | /** |
||
138 | * DEFERRED_IMPLICIT means that changes of entities are calculated at commit-time |
||
139 | * by doing a property-by-property comparison with the original data. This will |
||
140 | * be done for all entities that are in MANAGED state at commit-time. |
||
141 | * |
||
142 | * This is the default change tracking policy. |
||
143 | */ |
||
144 | public const CHANGETRACKING_DEFERRED_IMPLICIT = 1; |
||
145 | |||
146 | /** |
||
147 | * DEFERRED_EXPLICIT means that changes of entities are calculated at commit-time |
||
148 | * by doing a property-by-property comparison with the original data. This will |
||
149 | * be done only for entities that were explicitly saved (through persist() or a cascade). |
||
150 | */ |
||
151 | public const CHANGETRACKING_DEFERRED_EXPLICIT = 2; |
||
152 | |||
153 | /** |
||
154 | * NOTIFY means that Doctrine relies on the entities sending out notifications |
||
155 | * when their properties change. Such entity classes must implement |
||
156 | * the <tt>NotifyPropertyChanged</tt> interface. |
||
157 | */ |
||
158 | public const CHANGETRACKING_NOTIFY = 3; |
||
159 | |||
160 | /** |
||
161 | * SET means that fields will be written to the database using a $set operator |
||
162 | */ |
||
163 | public const STORAGE_STRATEGY_SET = 'set'; |
||
164 | |||
165 | /** |
||
166 | * INCREMENT means that fields will be written to the database by calculating |
||
167 | * the difference and using the $inc operator |
||
168 | */ |
||
169 | public const STORAGE_STRATEGY_INCREMENT = 'increment'; |
||
170 | |||
171 | public const STORAGE_STRATEGY_PUSH_ALL = 'pushAll'; |
||
172 | public const STORAGE_STRATEGY_ADD_TO_SET = 'addToSet'; |
||
173 | public const STORAGE_STRATEGY_ATOMIC_SET = 'atomicSet'; |
||
174 | public const STORAGE_STRATEGY_ATOMIC_SET_ARRAY = 'atomicSetArray'; |
||
175 | public const STORAGE_STRATEGY_SET_ARRAY = 'setArray'; |
||
176 | |||
177 | /** |
||
178 | * READ-ONLY: The name of the mongo database the document is mapped to. |
||
179 | */ |
||
180 | public $db; |
||
181 | |||
182 | /** |
||
183 | * READ-ONLY: The name of the mongo collection the document is mapped to. |
||
184 | */ |
||
185 | public $collection; |
||
186 | |||
187 | /** |
||
188 | * READ-ONLY: If the collection should be a fixed size. |
||
189 | */ |
||
190 | public $collectionCapped; |
||
191 | |||
192 | /** |
||
193 | * READ-ONLY: If the collection is fixed size, its size in bytes. |
||
194 | */ |
||
195 | public $collectionSize; |
||
196 | |||
197 | /** |
||
198 | * READ-ONLY: If the collection is fixed size, the maximum number of elements to store in the collection. |
||
199 | */ |
||
200 | public $collectionMax; |
||
201 | |||
202 | /** |
||
203 | * READ-ONLY Describes how MongoDB clients route read operations to the members of a replica set. |
||
204 | */ |
||
205 | public $readPreference; |
||
206 | |||
207 | /** |
||
208 | * READ-ONLY Associated with readPreference Allows to specify criteria so that your application can target read |
||
209 | * operations to specific members, based on custom parameters. |
||
210 | */ |
||
211 | public $readPreferenceTags; |
||
212 | |||
213 | /** |
||
214 | * READ-ONLY: Describes the level of acknowledgement requested from MongoDB for write operations. |
||
215 | */ |
||
216 | public $writeConcern; |
||
217 | |||
218 | /** |
||
219 | * READ-ONLY: The field name of the document identifier. |
||
220 | */ |
||
221 | public $identifier; |
||
222 | |||
223 | /** |
||
224 | * READ-ONLY: The array of indexes for the document collection. |
||
225 | */ |
||
226 | public $indexes = []; |
||
227 | |||
228 | /** |
||
229 | * READ-ONLY: Keys and options describing shard key. Only for sharded collections. |
||
230 | */ |
||
231 | public $shardKey; |
||
232 | |||
233 | /** |
||
234 | * READ-ONLY: The name of the document class. |
||
235 | */ |
||
236 | public $name; |
||
237 | |||
238 | /** |
||
239 | * READ-ONLY: The namespace the document class is contained in. |
||
240 | * |
||
241 | * @var string |
||
242 | * @todo Not really needed. Usage could be localized. |
||
243 | */ |
||
244 | public $namespace; |
||
245 | |||
246 | /** |
||
247 | * READ-ONLY: The name of the document class that is at the root of the mapped document inheritance |
||
248 | * hierarchy. If the document is not part of a mapped inheritance hierarchy this is the same |
||
249 | * as {@link $documentName}. |
||
250 | * |
||
251 | * @var string |
||
252 | */ |
||
253 | public $rootDocumentName; |
||
254 | |||
255 | /** |
||
256 | * The name of the custom repository class used for the document class. |
||
257 | * (Optional). |
||
258 | * |
||
259 | * @var string |
||
260 | */ |
||
261 | public $customRepositoryClassName; |
||
262 | |||
263 | /** |
||
264 | * READ-ONLY: The names of the parent classes (ancestors). |
||
265 | * |
||
266 | * @var array |
||
267 | */ |
||
268 | public $parentClasses = []; |
||
269 | |||
270 | /** |
||
271 | * READ-ONLY: The names of all subclasses (descendants). |
||
272 | * |
||
273 | * @var array |
||
274 | */ |
||
275 | public $subClasses = []; |
||
276 | |||
277 | /** |
||
278 | * The ReflectionProperty instances of the mapped class. |
||
279 | * |
||
280 | * @var \ReflectionProperty[] |
||
281 | */ |
||
282 | public $reflFields = []; |
||
283 | |||
284 | /** |
||
285 | * READ-ONLY: The inheritance mapping type used by the class. |
||
286 | * |
||
287 | * @var int |
||
288 | */ |
||
289 | public $inheritanceType = self::INHERITANCE_TYPE_NONE; |
||
290 | |||
291 | /** |
||
292 | * READ-ONLY: The Id generator type used by the class. |
||
293 | * |
||
294 | * @var string |
||
295 | */ |
||
296 | public $generatorType = self::GENERATOR_TYPE_AUTO; |
||
297 | |||
298 | /** |
||
299 | * READ-ONLY: The Id generator options. |
||
300 | * |
||
301 | * @var array |
||
302 | */ |
||
303 | public $generatorOptions = []; |
||
304 | |||
305 | /** |
||
306 | * READ-ONLY: The ID generator used for generating IDs for this class. |
||
307 | * |
||
308 | * @var AbstractIdGenerator |
||
309 | */ |
||
310 | public $idGenerator; |
||
311 | |||
312 | /** |
||
313 | * READ-ONLY: The field mappings of the class. |
||
314 | * Keys are field names and values are mapping definitions. |
||
315 | * |
||
316 | * The mapping definition array has the following values: |
||
317 | * |
||
318 | * - <b>fieldName</b> (string) |
||
319 | * The name of the field in the Document. |
||
320 | * |
||
321 | * - <b>id</b> (boolean, optional) |
||
322 | * Marks the field as the primary key of the document. Multiple fields of an |
||
323 | * document can have the id attribute, forming a composite key. |
||
324 | * |
||
325 | * @var array |
||
326 | */ |
||
327 | public $fieldMappings = []; |
||
328 | |||
329 | /** |
||
330 | * READ-ONLY: The association mappings of the class. |
||
331 | * Keys are field names and values are mapping definitions. |
||
332 | * |
||
333 | * @var array |
||
334 | */ |
||
335 | public $associationMappings = []; |
||
336 | |||
337 | /** |
||
338 | * READ-ONLY: Array of fields to also load with a given method. |
||
339 | * |
||
340 | * @var array |
||
341 | */ |
||
342 | public $alsoLoadMethods = []; |
||
343 | |||
344 | /** |
||
345 | * READ-ONLY: The registered lifecycle callbacks for documents of this class. |
||
346 | * |
||
347 | * @var array |
||
348 | */ |
||
349 | public $lifecycleCallbacks = []; |
||
350 | |||
351 | /** |
||
352 | * READ-ONLY: The discriminator value of this class. |
||
353 | * |
||
354 | * <b>This does only apply to the JOINED and SINGLE_COLLECTION inheritance mapping strategies |
||
355 | * where a discriminator field is used.</b> |
||
356 | * |
||
357 | * @var mixed |
||
358 | * @see discriminatorField |
||
359 | */ |
||
360 | public $discriminatorValue; |
||
361 | |||
362 | /** |
||
363 | * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. |
||
364 | * |
||
365 | * <b>This does only apply to the SINGLE_COLLECTION inheritance mapping strategy |
||
366 | * where a discriminator field is used.</b> |
||
367 | * |
||
368 | * @var mixed |
||
369 | * @see discriminatorField |
||
370 | */ |
||
371 | public $discriminatorMap = []; |
||
372 | |||
373 | /** |
||
374 | * READ-ONLY: The definition of the discriminator field used in SINGLE_COLLECTION |
||
375 | * inheritance mapping. |
||
376 | * |
||
377 | * @var string |
||
378 | */ |
||
379 | public $discriminatorField; |
||
380 | |||
381 | /** |
||
382 | * READ-ONLY: The default value for discriminatorField in case it's not set in the document |
||
383 | * |
||
384 | * @var string |
||
385 | * @see discriminatorField |
||
386 | */ |
||
387 | public $defaultDiscriminatorValue; |
||
388 | |||
389 | /** |
||
390 | * READ-ONLY: Whether this class describes the mapping of a mapped superclass. |
||
391 | * |
||
392 | * @var bool |
||
393 | */ |
||
394 | public $isMappedSuperclass = false; |
||
395 | |||
396 | /** |
||
397 | * READ-ONLY: Whether this class describes the mapping of a embedded document. |
||
398 | * |
||
399 | * @var bool |
||
400 | */ |
||
401 | public $isEmbeddedDocument = false; |
||
402 | |||
403 | /** |
||
404 | * READ-ONLY: Whether this class describes the mapping of an aggregation result document. |
||
405 | * |
||
406 | * @var bool |
||
407 | */ |
||
408 | public $isQueryResultDocument = false; |
||
409 | |||
410 | /** |
||
411 | * READ-ONLY: The policy used for change-tracking on entities of this class. |
||
412 | * |
||
413 | * @var int |
||
414 | */ |
||
415 | public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; |
||
416 | |||
417 | /** |
||
418 | * READ-ONLY: A flag for whether or not instances of this class are to be versioned |
||
419 | * with optimistic locking. |
||
420 | * |
||
421 | * @var bool $isVersioned |
||
422 | */ |
||
423 | public $isVersioned; |
||
424 | |||
425 | /** |
||
426 | * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). |
||
427 | * |
||
428 | * @var mixed $versionField |
||
429 | */ |
||
430 | public $versionField; |
||
431 | |||
432 | /** |
||
433 | * READ-ONLY: A flag for whether or not instances of this class are to allow pessimistic |
||
434 | * locking. |
||
435 | * |
||
436 | * @var bool $isLockable |
||
437 | */ |
||
438 | public $isLockable; |
||
439 | |||
440 | /** |
||
441 | * READ-ONLY: The name of the field which is used for locking a document. |
||
442 | * |
||
443 | * @var mixed $lockField |
||
444 | */ |
||
445 | public $lockField; |
||
446 | |||
447 | /** |
||
448 | * The ReflectionClass instance of the mapped class. |
||
449 | * |
||
450 | * @var \ReflectionClass |
||
451 | */ |
||
452 | public $reflClass; |
||
453 | |||
454 | /** |
||
455 | * READ_ONLY: A flag for whether or not this document is read-only. |
||
456 | * |
||
457 | * @var bool |
||
458 | */ |
||
459 | public $isReadOnly; |
||
460 | |||
461 | /** |
||
462 | * @var InstantiatorInterface|null |
||
463 | */ |
||
464 | private $instantiator; |
||
465 | |||
466 | /** |
||
467 | * Initializes a new ClassMetadata instance that will hold the object-document mapping |
||
468 | * metadata of the class with the given name. |
||
469 | * |
||
470 | * @param string $documentName The name of the document class the new instance is used for. |
||
471 | */ |
||
472 | 1474 | public function __construct($documentName) |
|
481 | |||
482 | /** |
||
483 | * Helper method to get reference id of ref* type references |
||
484 | * @param mixed $reference |
||
485 | * @param string $storeAs |
||
486 | * @return mixed |
||
487 | * @internal |
||
488 | */ |
||
489 | 120 | public static function getReferenceId($reference, $storeAs) |
|
493 | |||
494 | /** |
||
495 | * Returns the reference prefix used for a reference |
||
496 | * @param string $storeAs |
||
497 | * @return string |
||
498 | */ |
||
499 | 185 | private static function getReferencePrefix($storeAs) |
|
507 | |||
508 | /** |
||
509 | * Returns a fully qualified field name for a given reference |
||
510 | * @param string $storeAs |
||
511 | * @param string $pathPrefix The field path prefix |
||
512 | * @return string |
||
513 | * @internal |
||
514 | */ |
||
515 | 134 | public static function getReferenceFieldName($storeAs, $pathPrefix = '') |
|
523 | |||
524 | /** |
||
525 | * {@inheritDoc} |
||
526 | */ |
||
527 | 1365 | public function getReflectionClass() |
|
535 | |||
536 | /** |
||
537 | * {@inheritDoc} |
||
538 | */ |
||
539 | 321 | public function isIdentifier($fieldName) |
|
543 | |||
544 | /** |
||
545 | * INTERNAL: |
||
546 | * Sets the mapped identifier field of this class. |
||
547 | * |
||
548 | * @param string $identifier |
||
549 | */ |
||
550 | 886 | public function setIdentifier($identifier) |
|
554 | |||
555 | /** |
||
556 | * {@inheritDoc} |
||
557 | * |
||
558 | * Since MongoDB only allows exactly one identifier field |
||
559 | * this will always return an array with only one value |
||
560 | */ |
||
561 | 38 | public function getIdentifier() |
|
565 | |||
566 | /** |
||
567 | * {@inheritDoc} |
||
568 | * |
||
569 | * Since MongoDB only allows exactly one identifier field |
||
570 | * this will always return an array with only one value |
||
571 | */ |
||
572 | 97 | public function getIdentifierFieldNames() |
|
576 | |||
577 | /** |
||
578 | * {@inheritDoc} |
||
579 | */ |
||
580 | 888 | public function hasField($fieldName) |
|
584 | |||
585 | /** |
||
586 | * Sets the inheritance type used by the class and it's subclasses. |
||
587 | * |
||
588 | * @param int $type |
||
589 | */ |
||
590 | 902 | public function setInheritanceType($type) |
|
594 | |||
595 | /** |
||
596 | * Checks whether a mapped field is inherited from an entity superclass. |
||
597 | * |
||
598 | * @param string $fieldName |
||
599 | * |
||
600 | * @return bool TRUE if the field is inherited, FALSE otherwise. |
||
601 | */ |
||
602 | 1361 | public function isInheritedField($fieldName) |
|
606 | |||
607 | /** |
||
608 | * Registers a custom repository class for the document class. |
||
609 | * |
||
610 | * @param string $repositoryClassName The class name of the custom repository. |
||
611 | */ |
||
612 | 834 | public function setCustomRepositoryClass($repositoryClassName) |
|
624 | |||
625 | /** |
||
626 | * Dispatches the lifecycle event of the given document by invoking all |
||
627 | * registered callbacks. |
||
628 | * |
||
629 | * @param string $event Lifecycle event |
||
630 | * @param object $document Document on which the event occurred |
||
631 | * @param array $arguments Arguments to pass to all callbacks |
||
632 | * @throws \InvalidArgumentException if document class is not this class or |
||
633 | * a Proxy of this class |
||
634 | */ |
||
635 | 598 | public function invokeLifecycleCallbacks($event, $document, ?array $arguments = null) |
|
653 | |||
654 | /** |
||
655 | * Checks whether the class has callbacks registered for a lifecycle event. |
||
656 | * |
||
657 | * @param string $event Lifecycle event |
||
658 | * |
||
659 | * @return bool |
||
660 | */ |
||
661 | public function hasLifecycleCallbacks($event) |
||
665 | |||
666 | /** |
||
667 | * Gets the registered lifecycle callbacks for an event. |
||
668 | * |
||
669 | * @param string $event |
||
670 | * @return array |
||
671 | */ |
||
672 | public function getLifecycleCallbacks($event) |
||
676 | |||
677 | /** |
||
678 | * Adds a lifecycle callback for documents of this class. |
||
679 | * |
||
680 | * If the callback is already registered, this is a NOOP. |
||
681 | * |
||
682 | * @param string $callback |
||
683 | * @param string $event |
||
684 | */ |
||
685 | 802 | public function addLifecycleCallback($callback, $event) |
|
693 | |||
694 | /** |
||
695 | * Sets the lifecycle callbacks for documents of this class. |
||
696 | * |
||
697 | * Any previously registered callbacks are overwritten. |
||
698 | * |
||
699 | * @param array $callbacks |
||
700 | */ |
||
701 | 885 | public function setLifecycleCallbacks(array $callbacks) |
|
705 | |||
706 | /** |
||
707 | * Registers a method for loading document data before field hydration. |
||
708 | * |
||
709 | * Note: A method may be registered multiple times for different fields. |
||
710 | * it will be invoked only once for the first field found. |
||
711 | * |
||
712 | * @param string $method Method name |
||
713 | * @param array|string $fields Database field name(s) |
||
714 | */ |
||
715 | 14 | public function registerAlsoLoadMethod($method, $fields) |
|
719 | |||
720 | /** |
||
721 | * Sets the AlsoLoad methods for documents of this class. |
||
722 | * |
||
723 | * Any previously registered methods are overwritten. |
||
724 | * |
||
725 | * @param array $methods |
||
726 | */ |
||
727 | 885 | public function setAlsoLoadMethods(array $methods) |
|
731 | |||
732 | /** |
||
733 | * Sets the discriminator field. |
||
734 | * |
||
735 | * The field name is the the unmapped database field. Discriminator values |
||
736 | * are only used to discern the hydration class and are not mapped to class |
||
737 | * properties. |
||
738 | * |
||
739 | * @param string $discriminatorField |
||
740 | * |
||
741 | * @throws MappingException If the discriminator field conflicts with the |
||
742 | * "name" attribute of a mapped field. |
||
743 | */ |
||
744 | 911 | public function setDiscriminatorField($discriminatorField) |
|
769 | |||
770 | /** |
||
771 | * Sets the discriminator values used by this class. |
||
772 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. |
||
773 | * |
||
774 | * @param array $map |
||
775 | * |
||
776 | * @throws MappingException |
||
777 | */ |
||
778 | 904 | public function setDiscriminatorMap(array $map) |
|
797 | |||
798 | /** |
||
799 | * Sets the default discriminator value to be used for this class |
||
800 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies if the document has no discriminator value |
||
801 | * |
||
802 | * @param string $defaultDiscriminatorValue |
||
803 | * |
||
804 | * @throws MappingException |
||
805 | */ |
||
806 | 888 | public function setDefaultDiscriminatorValue($defaultDiscriminatorValue) |
|
820 | |||
821 | /** |
||
822 | * Sets the discriminator value for this class. |
||
823 | * Used for JOINED/SINGLE_TABLE inheritance and multiple document types in a single |
||
824 | * collection. |
||
825 | * |
||
826 | * @param string $value |
||
827 | */ |
||
828 | 3 | public function setDiscriminatorValue($value) |
|
833 | |||
834 | /** |
||
835 | * Add a index for this Document. |
||
836 | * |
||
837 | * @param array $keys Array of keys for the index. |
||
838 | * @param array $options Array of options for the index. |
||
839 | */ |
||
840 | 183 | public function addIndex($keys, array $options = []) |
|
860 | |||
861 | /** |
||
862 | * Returns the array of indexes for this Document. |
||
863 | * |
||
864 | * @return array $indexes The array of indexes. |
||
865 | */ |
||
866 | 23 | public function getIndexes() |
|
870 | |||
871 | /** |
||
872 | * Checks whether this document has indexes or not. |
||
873 | * |
||
874 | * @return bool |
||
875 | */ |
||
876 | public function hasIndexes() |
||
880 | |||
881 | /** |
||
882 | * Set shard key for this Document. |
||
883 | * |
||
884 | * @param array $keys Array of document keys. |
||
885 | * @param array $options Array of sharding options. |
||
886 | * |
||
887 | * @throws MappingException |
||
888 | */ |
||
889 | 71 | public function setShardKey(array $keys, array $options = []) |
|
890 | { |
||
891 | 71 | if ($this->inheritanceType === self::INHERITANCE_TYPE_SINGLE_COLLECTION && ! is_null($this->shardKey)) { |
|
892 | 2 | throw MappingException::shardKeyInSingleCollInheritanceSubclass($this->getName()); |
|
893 | } |
||
894 | |||
895 | 71 | if ($this->isEmbeddedDocument) { |
|
896 | 2 | throw MappingException::embeddedDocumentCantHaveShardKey($this->getName()); |
|
897 | } |
||
898 | |||
899 | 69 | foreach (array_keys($keys) as $field) { |
|
900 | 69 | if (! isset($this->fieldMappings[$field])) { |
|
901 | 62 | continue; |
|
902 | } |
||
903 | |||
904 | 50 | if (in_array($this->fieldMappings[$field]['type'], ['many', 'collection'])) { |
|
905 | 3 | throw MappingException::noMultiKeyShardKeys($this->getName(), $field); |
|
906 | } |
||
907 | |||
908 | 47 | if ($this->fieldMappings[$field]['strategy'] !== static::STORAGE_STRATEGY_SET) { |
|
909 | 47 | throw MappingException::onlySetStrategyAllowedInShardKey($this->getName(), $field); |
|
910 | } |
||
911 | } |
||
912 | |||
913 | 65 | $this->shardKey = [ |
|
914 | 65 | 'keys' => array_map(function ($value) { |
|
915 | 65 | if ($value === 1 || $value === -1) { |
|
916 | 5 | return (int) $value; |
|
917 | } |
||
918 | 65 | if (is_string($value)) { |
|
919 | 65 | $lower = strtolower($value); |
|
920 | 65 | if ($lower === 'asc') { |
|
921 | 63 | return 1; |
|
922 | 47 | } elseif ($lower === 'desc') { |
|
923 | 43 | return -1; |
|
924 | } |
||
925 | } |
||
926 | 47 | return $value; |
|
927 | 65 | }, $keys), |
|
928 | 65 | 'options' => $options, |
|
929 | ]; |
||
930 | 65 | } |
|
931 | |||
932 | /** |
||
933 | * @return array |
||
934 | */ |
||
935 | 17 | public function getShardKey() |
|
939 | |||
940 | /** |
||
941 | * Checks whether this document has shard key or not. |
||
942 | * |
||
943 | * @return bool |
||
944 | */ |
||
945 | 1095 | public function isSharded() |
|
949 | |||
950 | /** |
||
951 | * Sets the read preference used by this class. |
||
952 | * |
||
953 | * @param string $readPreference |
||
954 | * @param array|null $tags |
||
955 | */ |
||
956 | 885 | public function setReadPreference($readPreference, $tags) |
|
961 | |||
962 | /** |
||
963 | * Sets the write concern used by this class. |
||
964 | * |
||
965 | * @param string $writeConcern |
||
966 | */ |
||
967 | 895 | public function setWriteConcern($writeConcern) |
|
971 | |||
972 | /** |
||
973 | * @return string |
||
974 | */ |
||
975 | 11 | public function getWriteConcern() |
|
979 | |||
980 | /** |
||
981 | * Whether there is a write concern configured for this class. |
||
982 | * |
||
983 | * @return bool |
||
984 | */ |
||
985 | 547 | public function hasWriteConcern() |
|
989 | |||
990 | /** |
||
991 | * Sets the change tracking policy used by this class. |
||
992 | * |
||
993 | * @param int $policy |
||
994 | */ |
||
995 | 887 | public function setChangeTrackingPolicy($policy) |
|
999 | |||
1000 | /** |
||
1001 | * Whether the change tracking policy of this class is "deferred explicit". |
||
1002 | * |
||
1003 | * @return bool |
||
1004 | */ |
||
1005 | 61 | public function isChangeTrackingDeferredExplicit() |
|
1009 | |||
1010 | /** |
||
1011 | * Whether the change tracking policy of this class is "deferred implicit". |
||
1012 | * |
||
1013 | * @return bool |
||
1014 | */ |
||
1015 | 567 | public function isChangeTrackingDeferredImplicit() |
|
1019 | |||
1020 | /** |
||
1021 | * Whether the change tracking policy of this class is "notify". |
||
1022 | * |
||
1023 | * @return bool |
||
1024 | */ |
||
1025 | 308 | public function isChangeTrackingNotify() |
|
1029 | |||
1030 | /** |
||
1031 | * Gets the ReflectionProperties of the mapped class. |
||
1032 | * |
||
1033 | * @return array An array of ReflectionProperty instances. |
||
1034 | */ |
||
1035 | 97 | public function getReflectionProperties() |
|
1039 | |||
1040 | /** |
||
1041 | * Gets a ReflectionProperty for a specific field of the mapped class. |
||
1042 | * |
||
1043 | * @param string $name |
||
1044 | * |
||
1045 | * @return \ReflectionProperty |
||
1046 | */ |
||
1047 | public function getReflectionProperty($name) |
||
1051 | |||
1052 | /** |
||
1053 | * {@inheritDoc} |
||
1054 | */ |
||
1055 | 1370 | public function getName() |
|
1059 | |||
1060 | /** |
||
1061 | * The namespace this Document class belongs to. |
||
1062 | * |
||
1063 | * @return string $namespace The namespace name. |
||
1064 | */ |
||
1065 | public function getNamespace() |
||
1069 | |||
1070 | /** |
||
1071 | * Returns the database this Document is mapped to. |
||
1072 | * |
||
1073 | * @return string $db The database name. |
||
1074 | */ |
||
1075 | 1294 | public function getDatabase() |
|
1079 | |||
1080 | /** |
||
1081 | * Set the database this Document is mapped to. |
||
1082 | * |
||
1083 | * @param string $db The database name |
||
1084 | */ |
||
1085 | 92 | public function setDatabase($db) |
|
1089 | |||
1090 | /** |
||
1091 | * Get the collection this Document is mapped to. |
||
1092 | * |
||
1093 | * @return string $collection The collection name. |
||
1094 | */ |
||
1095 | 1295 | public function getCollection() |
|
1099 | |||
1100 | /** |
||
1101 | * Sets the collection this Document is mapped to. |
||
1102 | * |
||
1103 | * @param array|string $name |
||
1104 | * |
||
1105 | * @throws \InvalidArgumentException |
||
1106 | */ |
||
1107 | 1474 | public function setCollection($name) |
|
1108 | { |
||
1109 | 1474 | if (is_array($name)) { |
|
1110 | 1 | if (! isset($name['name'])) { |
|
1111 | throw new \InvalidArgumentException('A name key is required when passing an array to setCollection()'); |
||
1112 | } |
||
1113 | 1 | $this->collectionCapped = $name['capped'] ?? false; |
|
1114 | 1 | $this->collectionSize = $name['size'] ?? 0; |
|
1115 | 1 | $this->collectionMax = $name['max'] ?? 0; |
|
1116 | 1 | $this->collection = $name['name']; |
|
1117 | } else { |
||
1118 | 1474 | $this->collection = $name; |
|
1119 | } |
||
1120 | 1474 | } |
|
1121 | |||
1122 | /** |
||
1123 | * Get whether or not the documents collection is capped. |
||
1124 | * |
||
1125 | * @return bool |
||
1126 | */ |
||
1127 | 5 | public function getCollectionCapped() |
|
1131 | |||
1132 | /** |
||
1133 | * Set whether or not the documents collection is capped. |
||
1134 | * |
||
1135 | * @param bool $bool |
||
1136 | */ |
||
1137 | 1 | public function setCollectionCapped($bool) |
|
1141 | |||
1142 | /** |
||
1143 | * Get the collection size |
||
1144 | * |
||
1145 | * @return int |
||
1146 | */ |
||
1147 | 5 | public function getCollectionSize() |
|
1151 | |||
1152 | /** |
||
1153 | * Set the collection size. |
||
1154 | * |
||
1155 | * @param int $size |
||
1156 | */ |
||
1157 | 1 | public function setCollectionSize($size) |
|
1161 | |||
1162 | /** |
||
1163 | * Get the collection max. |
||
1164 | * |
||
1165 | * @return int |
||
1166 | */ |
||
1167 | 5 | public function getCollectionMax() |
|
1171 | |||
1172 | /** |
||
1173 | * Set the collection max. |
||
1174 | * |
||
1175 | * @param int $max |
||
1176 | */ |
||
1177 | 1 | public function setCollectionMax($max) |
|
1181 | |||
1182 | /** |
||
1183 | * Returns TRUE if this Document is mapped to a collection FALSE otherwise. |
||
1184 | * |
||
1185 | * @return bool |
||
1186 | */ |
||
1187 | public function isMappedToCollection() |
||
1191 | |||
1192 | /** |
||
1193 | * Validates the storage strategy of a mapping for consistency |
||
1194 | * @param array $mapping |
||
1195 | * @throws MappingException |
||
1196 | */ |
||
1197 | 1387 | private function applyStorageStrategy(array &$mapping) |
|
1240 | |||
1241 | /** |
||
1242 | * Map a single embedded document. |
||
1243 | * |
||
1244 | * @param array $mapping The mapping information. |
||
1245 | */ |
||
1246 | 6 | public function mapOneEmbedded(array $mapping) |
|
1252 | |||
1253 | /** |
||
1254 | * Map a collection of embedded documents. |
||
1255 | * |
||
1256 | * @param array $mapping The mapping information. |
||
1257 | */ |
||
1258 | 5 | public function mapManyEmbedded(array $mapping) |
|
1264 | |||
1265 | /** |
||
1266 | * Map a single document reference. |
||
1267 | * |
||
1268 | * @param array $mapping The mapping information. |
||
1269 | */ |
||
1270 | 2 | public function mapOneReference(array $mapping) |
|
1276 | |||
1277 | /** |
||
1278 | * Map a collection of document references. |
||
1279 | * |
||
1280 | * @param array $mapping The mapping information. |
||
1281 | */ |
||
1282 | 1 | public function mapManyReference(array $mapping) |
|
1288 | |||
1289 | /** |
||
1290 | * INTERNAL: |
||
1291 | * Adds a field mapping without completing/validating it. |
||
1292 | * This is mainly used to add inherited field mappings to derived classes. |
||
1293 | * |
||
1294 | * @param array $fieldMapping |
||
1295 | */ |
||
1296 | 116 | public function addInheritedFieldMapping(array $fieldMapping) |
|
1304 | |||
1305 | /** |
||
1306 | * INTERNAL: |
||
1307 | * Adds an association mapping without completing/validating it. |
||
1308 | * This is mainly used to add inherited association mappings to derived classes. |
||
1309 | * |
||
1310 | * @param array $mapping |
||
1311 | * |
||
1312 | * |
||
1313 | * @throws MappingException |
||
1314 | */ |
||
1315 | 68 | public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) |
|
1319 | |||
1320 | /** |
||
1321 | * Checks whether the class has a mapped association with the given field name. |
||
1322 | * |
||
1323 | * @param string $fieldName |
||
1324 | * @return bool |
||
1325 | */ |
||
1326 | 32 | public function hasReference($fieldName) |
|
1330 | |||
1331 | /** |
||
1332 | * Checks whether the class has a mapped embed with the given field name. |
||
1333 | * |
||
1334 | * @param string $fieldName |
||
1335 | * @return bool |
||
1336 | */ |
||
1337 | 5 | public function hasEmbed($fieldName) |
|
1341 | |||
1342 | /** |
||
1343 | * {@inheritDoc} |
||
1344 | * |
||
1345 | * Checks whether the class has a mapped association (embed or reference) with the given field name. |
||
1346 | */ |
||
1347 | 7 | public function hasAssociation($fieldName) |
|
1351 | |||
1352 | /** |
||
1353 | * {@inheritDoc} |
||
1354 | * |
||
1355 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
1356 | * is a single valued association. |
||
1357 | */ |
||
1358 | public function isSingleValuedAssociation($fieldName) |
||
1362 | |||
1363 | /** |
||
1364 | * {@inheritDoc} |
||
1365 | * |
||
1366 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
1367 | * is a collection valued association. |
||
1368 | */ |
||
1369 | public function isCollectionValuedAssociation($fieldName) |
||
1373 | |||
1374 | /** |
||
1375 | * Checks whether the class has a mapped association for the specified field |
||
1376 | * and if yes, checks whether it is a single-valued association (to-one). |
||
1377 | * |
||
1378 | * @param string $fieldName |
||
1379 | * @return bool TRUE if the association exists and is single-valued, FALSE otherwise. |
||
1380 | */ |
||
1381 | public function isSingleValuedReference($fieldName) |
||
1386 | |||
1387 | /** |
||
1388 | * Checks whether the class has a mapped association for the specified field |
||
1389 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
1390 | * |
||
1391 | * @param string $fieldName |
||
1392 | * @return bool TRUE if the association exists and is collection-valued, FALSE otherwise. |
||
1393 | */ |
||
1394 | public function isCollectionValuedReference($fieldName) |
||
1399 | |||
1400 | /** |
||
1401 | * Checks whether the class has a mapped embedded document for the specified field |
||
1402 | * and if yes, checks whether it is a single-valued association (to-one). |
||
1403 | * |
||
1404 | * @param string $fieldName |
||
1405 | * @return bool TRUE if the association exists and is single-valued, FALSE otherwise. |
||
1406 | */ |
||
1407 | public function isSingleValuedEmbed($fieldName) |
||
1412 | |||
1413 | /** |
||
1414 | * Checks whether the class has a mapped embedded document for the specified field |
||
1415 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
1416 | * |
||
1417 | * @param string $fieldName |
||
1418 | * @return bool TRUE if the association exists and is collection-valued, FALSE otherwise. |
||
1419 | */ |
||
1420 | public function isCollectionValuedEmbed($fieldName) |
||
1425 | |||
1426 | /** |
||
1427 | * Sets the ID generator used to generate IDs for instances of this class. |
||
1428 | * |
||
1429 | * @param AbstractIdGenerator $generator |
||
1430 | */ |
||
1431 | 1306 | public function setIdGenerator($generator) |
|
1435 | |||
1436 | /** |
||
1437 | * Casts the identifier to its portable PHP type. |
||
1438 | * |
||
1439 | * @param mixed $id |
||
1440 | * @return mixed $id |
||
1441 | */ |
||
1442 | 590 | public function getPHPIdentifierValue($id) |
|
1447 | |||
1448 | /** |
||
1449 | * Casts the identifier to its database type. |
||
1450 | * |
||
1451 | * @param mixed $id |
||
1452 | * @return mixed $id |
||
1453 | */ |
||
1454 | 654 | public function getDatabaseIdentifierValue($id) |
|
1459 | |||
1460 | /** |
||
1461 | * Sets the document identifier of a document. |
||
1462 | * |
||
1463 | * The value will be converted to a PHP type before being set. |
||
1464 | * |
||
1465 | * @param object $document |
||
1466 | * @param mixed $id |
||
1467 | */ |
||
1468 | 519 | public function setIdentifierValue($document, $id) |
|
1473 | |||
1474 | /** |
||
1475 | * Gets the document identifier as a PHP type. |
||
1476 | * |
||
1477 | * @param object $document |
||
1478 | * @return mixed $id |
||
1479 | */ |
||
1480 | 602 | public function getIdentifierValue($document) |
|
1484 | |||
1485 | /** |
||
1486 | * {@inheritDoc} |
||
1487 | * |
||
1488 | * Since MongoDB only allows exactly one identifier field this is a proxy |
||
1489 | * to {@see getIdentifierValue()} and returns an array with the identifier |
||
1490 | * field as a key. |
||
1491 | */ |
||
1492 | public function getIdentifierValues($object) |
||
1496 | |||
1497 | /** |
||
1498 | * Get the document identifier object as a database type. |
||
1499 | * |
||
1500 | * @param object $document |
||
1501 | * |
||
1502 | * @return ObjectId $id The ObjectId |
||
1503 | */ |
||
1504 | 31 | public function getIdentifierObject($document) |
|
1508 | |||
1509 | /** |
||
1510 | * Sets the specified field to the specified value on the given document. |
||
1511 | * |
||
1512 | * @param object $document |
||
1513 | * @param string $field |
||
1514 | * @param mixed $value |
||
1515 | */ |
||
1516 | 8 | public function setFieldValue($document, $field, $value) |
|
1526 | |||
1527 | /** |
||
1528 | * Gets the specified field's value off the given document. |
||
1529 | * |
||
1530 | * @param object $document |
||
1531 | * @param string $field |
||
1532 | * |
||
1533 | * @return mixed |
||
1534 | */ |
||
1535 | 27 | public function getFieldValue($document, $field) |
|
1543 | |||
1544 | /** |
||
1545 | * Gets the mapping of a field. |
||
1546 | * |
||
1547 | * @param string $fieldName The field name. |
||
1548 | * |
||
1549 | * @return array The field mapping. |
||
1550 | * |
||
1551 | * @throws MappingException if the $fieldName is not found in the fieldMappings array |
||
1552 | */ |
||
1553 | 167 | public function getFieldMapping($fieldName) |
|
1560 | |||
1561 | /** |
||
1562 | * Gets mappings of fields holding embedded document(s). |
||
1563 | * |
||
1564 | * @return array of field mappings |
||
1565 | */ |
||
1566 | 558 | public function getEmbeddedFieldsMappings() |
|
1575 | |||
1576 | /** |
||
1577 | * Gets the field mapping by its DB name. |
||
1578 | * E.g. it returns identifier's mapping when called with _id. |
||
1579 | * |
||
1580 | * @param string $dbFieldName |
||
1581 | * |
||
1582 | * @return array |
||
1583 | * @throws MappingException |
||
1584 | */ |
||
1585 | 4 | public function getFieldMappingByDbFieldName($dbFieldName) |
|
1595 | |||
1596 | /** |
||
1597 | * Check if the field is not null. |
||
1598 | * |
||
1599 | * @param string $fieldName The field name |
||
1600 | * |
||
1601 | * @return bool TRUE if the field is not null, FALSE otherwise. |
||
1602 | */ |
||
1603 | 1 | public function isNullable($fieldName) |
|
1611 | |||
1612 | /** |
||
1613 | * Checks whether the document has a discriminator field and value configured. |
||
1614 | * |
||
1615 | * @return bool |
||
1616 | */ |
||
1617 | 492 | public function hasDiscriminator() |
|
1621 | |||
1622 | /** |
||
1623 | * Sets the type of Id generator to use for the mapped class. |
||
1624 | * |
||
1625 | * @param string $generatorType Generator type. |
||
1626 | */ |
||
1627 | 885 | public function setIdGeneratorType($generatorType) |
|
1631 | |||
1632 | /** |
||
1633 | * Sets the Id generator options. |
||
1634 | * |
||
1635 | * @param array $generatorOptions Generator options. |
||
1636 | */ |
||
1637 | public function setIdGeneratorOptions($generatorOptions) |
||
1641 | |||
1642 | /** |
||
1643 | * @return bool |
||
1644 | */ |
||
1645 | 565 | public function isInheritanceTypeNone() |
|
1649 | |||
1650 | /** |
||
1651 | * Checks whether the mapped class uses the SINGLE_COLLECTION inheritance mapping strategy. |
||
1652 | * |
||
1653 | * @return bool |
||
1654 | */ |
||
1655 | 884 | public function isInheritanceTypeSingleCollection() |
|
1659 | |||
1660 | /** |
||
1661 | * Checks whether the mapped class uses the COLLECTION_PER_CLASS inheritance mapping strategy. |
||
1662 | * |
||
1663 | * @return bool |
||
1664 | */ |
||
1665 | public function isInheritanceTypeCollectionPerClass() |
||
1669 | |||
1670 | /** |
||
1671 | * Sets the mapped subclasses of this class. |
||
1672 | * |
||
1673 | * @param string[] $subclasses The names of all mapped subclasses. |
||
1674 | */ |
||
1675 | 2 | public function setSubclasses(array $subclasses) |
|
1685 | |||
1686 | /** |
||
1687 | * Sets the parent class names. |
||
1688 | * Assumes that the class names in the passed array are in the order: |
||
1689 | * directParent -> directParentParent -> directParentParentParent ... -> root. |
||
1690 | * |
||
1691 | * @param string[] $classNames |
||
1692 | */ |
||
1693 | 1361 | public function setParentClasses(array $classNames) |
|
1701 | |||
1702 | /** |
||
1703 | * Checks whether the class will generate a new \MongoDB\BSON\ObjectId instance for us. |
||
1704 | * |
||
1705 | * @return bool TRUE if the class uses the AUTO generator, FALSE otherwise. |
||
1706 | */ |
||
1707 | public function isIdGeneratorAuto() |
||
1711 | |||
1712 | /** |
||
1713 | * Checks whether the class will use a collection to generate incremented identifiers. |
||
1714 | * |
||
1715 | * @return bool TRUE if the class uses the INCREMENT generator, FALSE otherwise. |
||
1716 | */ |
||
1717 | public function isIdGeneratorIncrement() |
||
1721 | |||
1722 | /** |
||
1723 | * Checks whether the class will generate a uuid id. |
||
1724 | * |
||
1725 | * @return bool TRUE if the class uses the UUID generator, FALSE otherwise. |
||
1726 | */ |
||
1727 | public function isIdGeneratorUuid() |
||
1731 | |||
1732 | /** |
||
1733 | * Checks whether the class uses no id generator. |
||
1734 | * |
||
1735 | * @return bool TRUE if the class does not use any id generator, FALSE otherwise. |
||
1736 | */ |
||
1737 | public function isIdGeneratorNone() |
||
1741 | |||
1742 | /** |
||
1743 | * Sets the version field mapping used for versioning. Sets the default |
||
1744 | * value to use depending on the column type. |
||
1745 | * |
||
1746 | * @param array $mapping The version field mapping array |
||
1747 | * |
||
1748 | * @throws LockException |
||
1749 | */ |
||
1750 | 67 | public function setVersionMapping(array &$mapping) |
|
1759 | |||
1760 | /** |
||
1761 | * Sets whether this class is to be versioned for optimistic locking. |
||
1762 | * |
||
1763 | * @param bool $bool |
||
1764 | */ |
||
1765 | 885 | public function setVersioned($bool) |
|
1769 | |||
1770 | /** |
||
1771 | * Sets the name of the field that is to be used for versioning if this class is |
||
1772 | * versioned for optimistic locking. |
||
1773 | * |
||
1774 | * @param string $versionField |
||
1775 | */ |
||
1776 | 885 | public function setVersionField($versionField) |
|
1780 | |||
1781 | /** |
||
1782 | * Sets the version field mapping used for versioning. Sets the default |
||
1783 | * value to use depending on the column type. |
||
1784 | * |
||
1785 | * @param array $mapping The version field mapping array |
||
1786 | * |
||
1787 | * @throws LockException |
||
1788 | */ |
||
1789 | 22 | public function setLockMapping(array &$mapping) |
|
1798 | |||
1799 | /** |
||
1800 | * Sets whether this class is to allow pessimistic locking. |
||
1801 | * |
||
1802 | * @param bool $bool |
||
1803 | */ |
||
1804 | public function setLockable($bool) |
||
1808 | |||
1809 | /** |
||
1810 | * Sets the name of the field that is to be used for storing whether a document |
||
1811 | * is currently locked or not. |
||
1812 | * |
||
1813 | * @param string $lockField |
||
1814 | */ |
||
1815 | public function setLockField($lockField) |
||
1819 | |||
1820 | /** |
||
1821 | * Marks this class as read only, no change tracking is applied to it. |
||
1822 | */ |
||
1823 | 5 | public function markReadOnly() |
|
1827 | |||
1828 | /** |
||
1829 | * {@inheritDoc} |
||
1830 | */ |
||
1831 | public function getFieldNames() |
||
1835 | |||
1836 | /** |
||
1837 | * {@inheritDoc} |
||
1838 | */ |
||
1839 | public function getAssociationNames() |
||
1843 | |||
1844 | /** |
||
1845 | * {@inheritDoc} |
||
1846 | */ |
||
1847 | 23 | public function getTypeOfField($fieldName) |
|
1852 | |||
1853 | /** |
||
1854 | * {@inheritDoc} |
||
1855 | */ |
||
1856 | 4 | public function getAssociationTargetClass($assocName) |
|
1857 | { |
||
1858 | 4 | if (! isset($this->associationMappings[$assocName])) { |
|
1859 | 2 | throw new InvalidArgumentException("Association name expected, '" . $assocName . "' is not an association."); |
|
1860 | } |
||
1861 | |||
1862 | 2 | return $this->associationMappings[$assocName]['targetDocument']; |
|
1863 | } |
||
1864 | |||
1865 | /** |
||
1866 | * Retrieve the collectionClass associated with an association |
||
1867 | * |
||
1868 | * @param string $assocName |
||
1869 | */ |
||
1870 | 1 | public function getAssociationCollectionClass($assocName) |
|
1882 | |||
1883 | /** |
||
1884 | * {@inheritDoc} |
||
1885 | */ |
||
1886 | public function isAssociationInverseSide($fieldName) |
||
1890 | |||
1891 | /** |
||
1892 | * {@inheritDoc} |
||
1893 | */ |
||
1894 | public function getAssociationMappedByTargetField($fieldName) |
||
1898 | |||
1899 | /** |
||
1900 | * Map a field. |
||
1901 | * |
||
1902 | * @param array $mapping The mapping information. |
||
1903 | * |
||
1904 | * @return array |
||
1905 | * |
||
1906 | * @throws MappingException |
||
1907 | */ |
||
1908 | 1399 | public function mapField(array $mapping) |
|
2080 | |||
2081 | /** |
||
2082 | * Determines which fields get serialized. |
||
2083 | * |
||
2084 | * It is only serialized what is necessary for best unserialization performance. |
||
2085 | * That means any metadata properties that are not set or empty or simply have |
||
2086 | * their default value are NOT serialized. |
||
2087 | * |
||
2088 | * Parts that are also NOT serialized because they can not be properly unserialized: |
||
2089 | * - reflClass (ReflectionClass) |
||
2090 | * - reflFields (ReflectionProperty array) |
||
2091 | * |
||
2092 | * @return array The names of all the fields that should be serialized. |
||
2093 | */ |
||
2094 | 6 | public function __sleep() |
|
2168 | |||
2169 | /** |
||
2170 | * Restores some state that can not be serialized/unserialized. |
||
2171 | * |
||
2172 | */ |
||
2173 | 6 | public function __wakeup() |
|
2189 | |||
2190 | /** |
||
2191 | * Creates a new instance of the mapped class, without invoking the constructor. |
||
2192 | * |
||
2193 | * @return object |
||
2194 | */ |
||
2195 | 354 | public function newInstance() |
|
2199 | } |
||
2200 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..