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 |
||
53 | class ClassMetadata implements BaseClassMetadata |
||
54 | { |
||
55 | /* The Id generator types. */ |
||
56 | /** |
||
57 | * AUTO means Doctrine will automatically create a new \MongoDB\BSON\ObjectId instance for us. |
||
58 | */ |
||
59 | public const GENERATOR_TYPE_AUTO = 1; |
||
60 | |||
61 | /** |
||
62 | * INCREMENT means a separate collection is used for maintaining and incrementing id generation. |
||
63 | * Offers full portability. |
||
64 | */ |
||
65 | public const GENERATOR_TYPE_INCREMENT = 2; |
||
66 | |||
67 | /** |
||
68 | * UUID means Doctrine will generate a uuid for us. |
||
69 | */ |
||
70 | public const GENERATOR_TYPE_UUID = 3; |
||
71 | |||
72 | /** |
||
73 | * ALNUM means Doctrine will generate Alpha-numeric string identifiers, using the INCREMENT |
||
74 | * generator to ensure identifier uniqueness |
||
75 | */ |
||
76 | public const GENERATOR_TYPE_ALNUM = 4; |
||
77 | |||
78 | /** |
||
79 | * CUSTOM means Doctrine expect a class parameter. It will then try to initiate that class |
||
80 | * and pass other options to the generator. It will throw an Exception if the class |
||
81 | * does not exist or if an option was passed for that there is not setter in the new |
||
82 | * generator class. |
||
83 | * |
||
84 | * The class will have to be a subtype of AbstractIdGenerator. |
||
85 | */ |
||
86 | public const GENERATOR_TYPE_CUSTOM = 5; |
||
87 | |||
88 | /** |
||
89 | * NONE means Doctrine will not generate any id for us and you are responsible for manually |
||
90 | * assigning an id. |
||
91 | */ |
||
92 | public const GENERATOR_TYPE_NONE = 6; |
||
93 | |||
94 | /** |
||
95 | * Default discriminator field name. |
||
96 | * |
||
97 | * This is used for associations value for associations where a that do not define a "targetDocument" or |
||
98 | * "discriminatorField" option in their mapping. |
||
99 | */ |
||
100 | public const DEFAULT_DISCRIMINATOR_FIELD = '_doctrine_class_name'; |
||
101 | |||
102 | public const REFERENCE_ONE = 1; |
||
103 | public const REFERENCE_MANY = 2; |
||
104 | public const EMBED_ONE = 3; |
||
105 | public const EMBED_MANY = 4; |
||
106 | public const MANY = 'many'; |
||
107 | public const ONE = 'one'; |
||
108 | |||
109 | /** |
||
110 | * The types of storeAs references |
||
111 | */ |
||
112 | public const REFERENCE_STORE_AS_ID = 'id'; |
||
113 | public const REFERENCE_STORE_AS_DB_REF = 'dbRef'; |
||
114 | public const REFERENCE_STORE_AS_DB_REF_WITH_DB = 'dbRefWithDb'; |
||
115 | public const REFERENCE_STORE_AS_REF = 'ref'; |
||
116 | |||
117 | /* The inheritance mapping types */ |
||
118 | /** |
||
119 | * NONE means the class does not participate in an inheritance hierarchy |
||
120 | * and therefore does not need an inheritance mapping type. |
||
121 | */ |
||
122 | public const INHERITANCE_TYPE_NONE = 1; |
||
123 | |||
124 | /** |
||
125 | * SINGLE_COLLECTION means the class will be persisted according to the rules of |
||
126 | * <tt>Single Collection Inheritance</tt>. |
||
127 | */ |
||
128 | public const INHERITANCE_TYPE_SINGLE_COLLECTION = 2; |
||
129 | |||
130 | /** |
||
131 | * COLLECTION_PER_CLASS means the class will be persisted according to the rules |
||
132 | * of <tt>Concrete Collection Inheritance</tt>. |
||
133 | */ |
||
134 | public const INHERITANCE_TYPE_COLLECTION_PER_CLASS = 3; |
||
135 | |||
136 | /** |
||
137 | * DEFERRED_IMPLICIT means that changes of entities are calculated at commit-time |
||
138 | * by doing a property-by-property comparison with the original data. This will |
||
139 | * be done for all entities that are in MANAGED state at commit-time. |
||
140 | * |
||
141 | * This is the default change tracking policy. |
||
142 | */ |
||
143 | public const CHANGETRACKING_DEFERRED_IMPLICIT = 1; |
||
144 | |||
145 | /** |
||
146 | * DEFERRED_EXPLICIT means that changes of entities are calculated at commit-time |
||
147 | * by doing a property-by-property comparison with the original data. This will |
||
148 | * be done only for entities that were explicitly saved (through persist() or a cascade). |
||
149 | */ |
||
150 | public const CHANGETRACKING_DEFERRED_EXPLICIT = 2; |
||
151 | |||
152 | /** |
||
153 | * NOTIFY means that Doctrine relies on the entities sending out notifications |
||
154 | * when their properties change. Such entity classes must implement |
||
155 | * the <tt>NotifyPropertyChanged</tt> interface. |
||
156 | */ |
||
157 | public const CHANGETRACKING_NOTIFY = 3; |
||
158 | |||
159 | /** |
||
160 | * SET means that fields will be written to the database using a $set operator |
||
161 | */ |
||
162 | public const STORAGE_STRATEGY_SET = 'set'; |
||
163 | |||
164 | /** |
||
165 | * INCREMENT means that fields will be written to the database by calculating |
||
166 | * the difference and using the $inc operator |
||
167 | */ |
||
168 | public const STORAGE_STRATEGY_INCREMENT = 'increment'; |
||
169 | |||
170 | public const STORAGE_STRATEGY_PUSH_ALL = 'pushAll'; |
||
171 | public const STORAGE_STRATEGY_ADD_TO_SET = 'addToSet'; |
||
172 | public const STORAGE_STRATEGY_ATOMIC_SET = 'atomicSet'; |
||
173 | public const STORAGE_STRATEGY_ATOMIC_SET_ARRAY = 'atomicSetArray'; |
||
174 | public const STORAGE_STRATEGY_SET_ARRAY = 'setArray'; |
||
175 | |||
176 | /** |
||
177 | * READ-ONLY: The name of the mongo database the document is mapped to. |
||
178 | * @var string |
||
179 | */ |
||
180 | public $db; |
||
181 | |||
182 | /** |
||
183 | * READ-ONLY: The name of the mongo collection the document is mapped to. |
||
184 | * @var string |
||
185 | */ |
||
186 | public $collection; |
||
187 | |||
188 | /** |
||
189 | * READ-ONLY: If the collection should be a fixed size. |
||
190 | * @var bool |
||
191 | */ |
||
192 | public $collectionCapped; |
||
193 | |||
194 | /** |
||
195 | * READ-ONLY: If the collection is fixed size, its size in bytes. |
||
196 | * @var int|null |
||
197 | */ |
||
198 | public $collectionSize; |
||
199 | |||
200 | /** |
||
201 | * READ-ONLY: If the collection is fixed size, the maximum number of elements to store in the collection. |
||
202 | * @var int|null |
||
203 | */ |
||
204 | public $collectionMax; |
||
205 | |||
206 | /** |
||
207 | * READ-ONLY Describes how MongoDB clients route read operations to the members of a replica set. |
||
208 | * @var string|int|null |
||
209 | */ |
||
210 | public $readPreference; |
||
211 | |||
212 | /** |
||
213 | * READ-ONLY Associated with readPreference Allows to specify criteria so that your application can target read |
||
214 | * operations to specific members, based on custom parameters. |
||
215 | * @var string[][]|null |
||
216 | */ |
||
217 | public $readPreferenceTags; |
||
218 | |||
219 | /** |
||
220 | * READ-ONLY: Describes the level of acknowledgement requested from MongoDB for write operations. |
||
221 | * @var string|int|null |
||
222 | */ |
||
223 | public $writeConcern; |
||
224 | |||
225 | /** |
||
226 | * READ-ONLY: The field name of the document identifier. |
||
227 | * @var string|null |
||
228 | */ |
||
229 | public $identifier; |
||
230 | |||
231 | /** |
||
232 | * READ-ONLY: The array of indexes for the document collection. |
||
233 | * @var array |
||
234 | */ |
||
235 | public $indexes = []; |
||
236 | |||
237 | /** |
||
238 | * READ-ONLY: Keys and options describing shard key. Only for sharded collections. |
||
239 | * @var string|null |
||
240 | */ |
||
241 | public $shardKey; |
||
242 | |||
243 | /** |
||
244 | * READ-ONLY: The name of the document class. |
||
245 | * @var string |
||
246 | */ |
||
247 | public $name; |
||
248 | |||
249 | /** |
||
250 | * READ-ONLY: The namespace the document class is contained in. |
||
251 | * |
||
252 | * @var string |
||
253 | * @todo Not really needed. Usage could be localized. |
||
254 | */ |
||
255 | public $namespace; |
||
256 | |||
257 | /** |
||
258 | * READ-ONLY: The name of the document class that is at the root of the mapped document inheritance |
||
259 | * hierarchy. If the document is not part of a mapped inheritance hierarchy this is the same |
||
260 | * as {@link $documentName}. |
||
261 | * |
||
262 | * @var string |
||
263 | */ |
||
264 | public $rootDocumentName; |
||
265 | |||
266 | /** |
||
267 | * The name of the custom repository class used for the document class. |
||
268 | * (Optional). |
||
269 | * |
||
270 | * @var string |
||
271 | */ |
||
272 | public $customRepositoryClassName; |
||
273 | |||
274 | /** |
||
275 | * READ-ONLY: The names of the parent classes (ancestors). |
||
276 | * |
||
277 | * @var array |
||
278 | */ |
||
279 | public $parentClasses = []; |
||
280 | |||
281 | /** |
||
282 | * READ-ONLY: The names of all subclasses (descendants). |
||
283 | * |
||
284 | * @var array |
||
285 | */ |
||
286 | public $subClasses = []; |
||
287 | |||
288 | /** |
||
289 | * The ReflectionProperty instances of the mapped class. |
||
290 | * |
||
291 | * @var \ReflectionProperty[] |
||
292 | */ |
||
293 | public $reflFields = []; |
||
294 | |||
295 | /** |
||
296 | * READ-ONLY: The inheritance mapping type used by the class. |
||
297 | * |
||
298 | * @var int |
||
299 | */ |
||
300 | public $inheritanceType = self::INHERITANCE_TYPE_NONE; |
||
301 | |||
302 | /** |
||
303 | * READ-ONLY: The Id generator type used by the class. |
||
304 | * |
||
305 | * @var string |
||
306 | */ |
||
307 | public $generatorType = self::GENERATOR_TYPE_AUTO; |
||
308 | |||
309 | /** |
||
310 | * READ-ONLY: The Id generator options. |
||
311 | * |
||
312 | * @var array |
||
313 | */ |
||
314 | public $generatorOptions = []; |
||
315 | |||
316 | /** |
||
317 | * READ-ONLY: The ID generator used for generating IDs for this class. |
||
318 | * |
||
319 | * @var AbstractIdGenerator |
||
320 | */ |
||
321 | public $idGenerator; |
||
322 | |||
323 | /** |
||
324 | * READ-ONLY: The field mappings of the class. |
||
325 | * Keys are field names and values are mapping definitions. |
||
326 | * |
||
327 | * The mapping definition array has the following values: |
||
328 | * |
||
329 | * - <b>fieldName</b> (string) |
||
330 | * The name of the field in the Document. |
||
331 | * |
||
332 | * - <b>id</b> (boolean, optional) |
||
333 | * Marks the field as the primary key of the document. Multiple fields of an |
||
334 | * document can have the id attribute, forming a composite key. |
||
335 | * |
||
336 | * @var array |
||
337 | */ |
||
338 | public $fieldMappings = []; |
||
339 | |||
340 | /** |
||
341 | * READ-ONLY: The association mappings of the class. |
||
342 | * Keys are field names and values are mapping definitions. |
||
343 | * |
||
344 | * @var array |
||
345 | */ |
||
346 | public $associationMappings = []; |
||
347 | |||
348 | /** |
||
349 | * READ-ONLY: Array of fields to also load with a given method. |
||
350 | * |
||
351 | * @var array |
||
352 | */ |
||
353 | public $alsoLoadMethods = []; |
||
354 | |||
355 | /** |
||
356 | * READ-ONLY: The registered lifecycle callbacks for documents of this class. |
||
357 | * |
||
358 | * @var array |
||
359 | */ |
||
360 | public $lifecycleCallbacks = []; |
||
361 | |||
362 | /** |
||
363 | * READ-ONLY: The discriminator value of this class. |
||
364 | * |
||
365 | * <b>This does only apply to the JOINED and SINGLE_COLLECTION inheritance mapping strategies |
||
366 | * where a discriminator field is used.</b> |
||
367 | * |
||
368 | * @var mixed |
||
369 | * @see discriminatorField |
||
370 | */ |
||
371 | public $discriminatorValue; |
||
372 | |||
373 | /** |
||
374 | * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. |
||
375 | * |
||
376 | * <b>This does only apply to the SINGLE_COLLECTION inheritance mapping strategy |
||
377 | * where a discriminator field is used.</b> |
||
378 | * |
||
379 | * @var mixed |
||
380 | * @see discriminatorField |
||
381 | */ |
||
382 | public $discriminatorMap = []; |
||
383 | |||
384 | /** |
||
385 | * READ-ONLY: The definition of the discriminator field used in SINGLE_COLLECTION |
||
386 | * inheritance mapping. |
||
387 | * |
||
388 | * @var string |
||
389 | */ |
||
390 | public $discriminatorField; |
||
391 | |||
392 | /** |
||
393 | * READ-ONLY: The default value for discriminatorField in case it's not set in the document |
||
394 | * |
||
395 | * @var string |
||
396 | * @see discriminatorField |
||
397 | */ |
||
398 | public $defaultDiscriminatorValue; |
||
399 | |||
400 | /** |
||
401 | * READ-ONLY: Whether this class describes the mapping of a mapped superclass. |
||
402 | * |
||
403 | * @var bool |
||
404 | */ |
||
405 | public $isMappedSuperclass = false; |
||
406 | |||
407 | /** |
||
408 | * READ-ONLY: Whether this class describes the mapping of a embedded document. |
||
409 | * |
||
410 | * @var bool |
||
411 | */ |
||
412 | public $isEmbeddedDocument = false; |
||
413 | |||
414 | /** |
||
415 | * READ-ONLY: Whether this class describes the mapping of an aggregation result document. |
||
416 | * |
||
417 | * @var bool |
||
418 | */ |
||
419 | public $isQueryResultDocument = false; |
||
420 | |||
421 | /** |
||
422 | * READ-ONLY: The policy used for change-tracking on entities of this class. |
||
423 | * |
||
424 | * @var int |
||
425 | */ |
||
426 | public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; |
||
427 | |||
428 | /** |
||
429 | * READ-ONLY: A flag for whether or not instances of this class are to be versioned |
||
430 | * with optimistic locking. |
||
431 | * |
||
432 | * @var bool $isVersioned |
||
433 | */ |
||
434 | public $isVersioned; |
||
435 | |||
436 | /** |
||
437 | * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). |
||
438 | * |
||
439 | * @var mixed $versionField |
||
440 | */ |
||
441 | public $versionField; |
||
442 | |||
443 | /** |
||
444 | * READ-ONLY: A flag for whether or not instances of this class are to allow pessimistic |
||
445 | * locking. |
||
446 | * |
||
447 | * @var bool $isLockable |
||
448 | */ |
||
449 | public $isLockable; |
||
450 | |||
451 | /** |
||
452 | * READ-ONLY: The name of the field which is used for locking a document. |
||
453 | * |
||
454 | * @var mixed $lockField |
||
455 | */ |
||
456 | public $lockField; |
||
457 | |||
458 | /** |
||
459 | * The ReflectionClass instance of the mapped class. |
||
460 | * |
||
461 | * @var \ReflectionClass |
||
462 | */ |
||
463 | public $reflClass; |
||
464 | |||
465 | /** |
||
466 | * READ_ONLY: A flag for whether or not this document is read-only. |
||
467 | * |
||
468 | * @var bool |
||
469 | */ |
||
470 | public $isReadOnly; |
||
471 | |||
472 | /** @var InstantiatorInterface|null */ |
||
473 | private $instantiator; |
||
474 | |||
475 | /** |
||
476 | * Initializes a new ClassMetadata instance that will hold the object-document mapping |
||
477 | * metadata of the class with the given name. |
||
478 | * |
||
479 | * @param string $documentName The name of the document class the new instance is used for. |
||
480 | */ |
||
481 | 1482 | public function __construct($documentName) |
|
490 | |||
491 | /** |
||
492 | * Helper method to get reference id of ref* type references |
||
493 | * @param mixed $reference |
||
494 | * @param string $storeAs |
||
495 | * @return mixed |
||
496 | * @internal |
||
497 | */ |
||
498 | 121 | public static function getReferenceId($reference, $storeAs) |
|
502 | |||
503 | /** |
||
504 | * Returns the reference prefix used for a reference |
||
505 | * @param string $storeAs |
||
506 | * @return string |
||
507 | */ |
||
508 | 186 | private static function getReferencePrefix($storeAs) |
|
516 | |||
517 | /** |
||
518 | * Returns a fully qualified field name for a given reference |
||
519 | * @param string $storeAs |
||
520 | * @param string $pathPrefix The field path prefix |
||
521 | * @return string |
||
522 | * @internal |
||
523 | */ |
||
524 | 134 | public static function getReferenceFieldName($storeAs, $pathPrefix = '') |
|
532 | |||
533 | /** |
||
534 | * {@inheritDoc} |
||
535 | */ |
||
536 | 1370 | public function getReflectionClass() |
|
544 | |||
545 | /** |
||
546 | * {@inheritDoc} |
||
547 | */ |
||
548 | 324 | public function isIdentifier($fieldName) |
|
552 | |||
553 | /** |
||
554 | * INTERNAL: |
||
555 | * Sets the mapped identifier field of this class. |
||
556 | * |
||
557 | * @param string $identifier |
||
558 | */ |
||
559 | 888 | public function setIdentifier($identifier) |
|
563 | |||
564 | /** |
||
565 | * {@inheritDoc} |
||
566 | * |
||
567 | * Since MongoDB only allows exactly one identifier field |
||
568 | * this will always return an array with only one value |
||
569 | */ |
||
570 | 39 | public function getIdentifier() |
|
574 | |||
575 | /** |
||
576 | * {@inheritDoc} |
||
577 | * |
||
578 | * Since MongoDB only allows exactly one identifier field |
||
579 | * this will always return an array with only one value |
||
580 | */ |
||
581 | 98 | public function getIdentifierFieldNames() |
|
585 | |||
586 | /** |
||
587 | * {@inheritDoc} |
||
588 | */ |
||
589 | 891 | public function hasField($fieldName) |
|
593 | |||
594 | /** |
||
595 | * Sets the inheritance type used by the class and it's subclasses. |
||
596 | * |
||
597 | * @param int $type |
||
598 | */ |
||
599 | 904 | public function setInheritanceType($type) |
|
603 | |||
604 | /** |
||
605 | * Checks whether a mapped field is inherited from an entity superclass. |
||
606 | * |
||
607 | * @param string $fieldName |
||
608 | * |
||
609 | * @return bool TRUE if the field is inherited, FALSE otherwise. |
||
610 | */ |
||
611 | 1366 | public function isInheritedField($fieldName) |
|
615 | |||
616 | /** |
||
617 | * Registers a custom repository class for the document class. |
||
618 | * |
||
619 | * @param string $repositoryClassName The class name of the custom repository. |
||
620 | */ |
||
621 | 836 | public function setCustomRepositoryClass($repositoryClassName) |
|
633 | |||
634 | /** |
||
635 | * Dispatches the lifecycle event of the given document by invoking all |
||
636 | * registered callbacks. |
||
637 | * |
||
638 | * @param string $event Lifecycle event |
||
639 | * @param object $document Document on which the event occurred |
||
640 | * @param array $arguments Arguments to pass to all callbacks |
||
641 | * @throws \InvalidArgumentException If document class is not this class or |
||
642 | * a Proxy of this class. |
||
643 | */ |
||
644 | 602 | public function invokeLifecycleCallbacks($event, $document, ?array $arguments = null) |
|
662 | |||
663 | /** |
||
664 | * Checks whether the class has callbacks registered for a lifecycle event. |
||
665 | * |
||
666 | * @param string $event Lifecycle event |
||
667 | * |
||
668 | * @return bool |
||
669 | */ |
||
670 | public function hasLifecycleCallbacks($event) |
||
674 | |||
675 | /** |
||
676 | * Gets the registered lifecycle callbacks for an event. |
||
677 | * |
||
678 | * @param string $event |
||
679 | * @return array |
||
680 | */ |
||
681 | public function getLifecycleCallbacks($event) |
||
685 | |||
686 | /** |
||
687 | * Adds a lifecycle callback for documents of this class. |
||
688 | * |
||
689 | * If the callback is already registered, this is a NOOP. |
||
690 | * |
||
691 | * @param string $callback |
||
692 | * @param string $event |
||
693 | */ |
||
694 | 803 | public function addLifecycleCallback($callback, $event) |
|
702 | |||
703 | /** |
||
704 | * Sets the lifecycle callbacks for documents of this class. |
||
705 | * |
||
706 | * Any previously registered callbacks are overwritten. |
||
707 | * |
||
708 | * @param array $callbacks |
||
709 | */ |
||
710 | 887 | public function setLifecycleCallbacks(array $callbacks) |
|
714 | |||
715 | /** |
||
716 | * Registers a method for loading document data before field hydration. |
||
717 | * |
||
718 | * Note: A method may be registered multiple times for different fields. |
||
719 | * it will be invoked only once for the first field found. |
||
720 | * |
||
721 | * @param string $method Method name |
||
722 | * @param array|string $fields Database field name(s) |
||
723 | */ |
||
724 | 14 | public function registerAlsoLoadMethod($method, $fields) |
|
728 | |||
729 | /** |
||
730 | * Sets the AlsoLoad methods for documents of this class. |
||
731 | * |
||
732 | * Any previously registered methods are overwritten. |
||
733 | * |
||
734 | * @param array $methods |
||
735 | */ |
||
736 | 887 | public function setAlsoLoadMethods(array $methods) |
|
740 | |||
741 | /** |
||
742 | * Sets the discriminator field. |
||
743 | * |
||
744 | * The field name is the the unmapped database field. Discriminator values |
||
745 | * are only used to discern the hydration class and are not mapped to class |
||
746 | * properties. |
||
747 | * |
||
748 | * @param string $discriminatorField |
||
749 | * |
||
750 | * @throws MappingException If the discriminator field conflicts with the |
||
751 | * "name" attribute of a mapped field. |
||
752 | */ |
||
753 | 913 | public function setDiscriminatorField($discriminatorField) |
|
778 | |||
779 | /** |
||
780 | * Sets the discriminator values used by this class. |
||
781 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. |
||
782 | * |
||
783 | * @param array $map |
||
784 | * |
||
785 | * @throws MappingException |
||
786 | */ |
||
787 | 906 | public function setDiscriminatorMap(array $map) |
|
806 | |||
807 | /** |
||
808 | * Sets the default discriminator value to be used for this class |
||
809 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies if the document has no discriminator value |
||
810 | * |
||
811 | * @param string $defaultDiscriminatorValue |
||
812 | * |
||
813 | * @throws MappingException |
||
814 | */ |
||
815 | 890 | public function setDefaultDiscriminatorValue($defaultDiscriminatorValue) |
|
829 | |||
830 | /** |
||
831 | * Sets the discriminator value for this class. |
||
832 | * Used for JOINED/SINGLE_TABLE inheritance and multiple document types in a single |
||
833 | * collection. |
||
834 | * |
||
835 | * @param string $value |
||
836 | */ |
||
837 | 3 | public function setDiscriminatorValue($value) |
|
842 | |||
843 | /** |
||
844 | * Add a index for this Document. |
||
845 | * |
||
846 | * @param array $keys Array of keys for the index. |
||
847 | * @param array $options Array of options for the index. |
||
848 | */ |
||
849 | 183 | public function addIndex($keys, array $options = []) |
|
871 | |||
872 | /** |
||
873 | * Returns the array of indexes for this Document. |
||
874 | * |
||
875 | * @return array $indexes The array of indexes. |
||
876 | */ |
||
877 | 23 | public function getIndexes() |
|
881 | |||
882 | /** |
||
883 | * Checks whether this document has indexes or not. |
||
884 | * |
||
885 | * @return bool |
||
886 | */ |
||
887 | public function hasIndexes() |
||
891 | |||
892 | /** |
||
893 | * Set shard key for this Document. |
||
894 | * |
||
895 | * @param array $keys Array of document keys. |
||
896 | * @param array $options Array of sharding options. |
||
897 | * |
||
898 | * @throws MappingException |
||
899 | */ |
||
900 | 71 | public function setShardKey(array $keys, array $options = []) |
|
944 | |||
945 | /** |
||
946 | * @return array |
||
947 | */ |
||
948 | 17 | public function getShardKey() |
|
952 | |||
953 | /** |
||
954 | * Checks whether this document has shard key or not. |
||
955 | * |
||
956 | * @return bool |
||
957 | */ |
||
958 | 1099 | public function isSharded() |
|
962 | |||
963 | /** |
||
964 | * Sets the read preference used by this class. |
||
965 | * |
||
966 | * @param string $readPreference |
||
967 | * @param array|null $tags |
||
968 | */ |
||
969 | 887 | public function setReadPreference($readPreference, $tags) |
|
974 | |||
975 | /** |
||
976 | * Sets the write concern used by this class. |
||
977 | * |
||
978 | * @param string $writeConcern |
||
979 | */ |
||
980 | 897 | public function setWriteConcern($writeConcern) |
|
984 | |||
985 | /** |
||
986 | * @return string |
||
987 | */ |
||
988 | 11 | public function getWriteConcern() |
|
992 | |||
993 | /** |
||
994 | * Whether there is a write concern configured for this class. |
||
995 | * |
||
996 | * @return bool |
||
997 | */ |
||
998 | 551 | public function hasWriteConcern() |
|
1002 | |||
1003 | /** |
||
1004 | * Sets the change tracking policy used by this class. |
||
1005 | * |
||
1006 | * @param int $policy |
||
1007 | */ |
||
1008 | 889 | public function setChangeTrackingPolicy($policy) |
|
1012 | |||
1013 | /** |
||
1014 | * Whether the change tracking policy of this class is "deferred explicit". |
||
1015 | * |
||
1016 | * @return bool |
||
1017 | */ |
||
1018 | 62 | public function isChangeTrackingDeferredExplicit() |
|
1022 | |||
1023 | /** |
||
1024 | * Whether the change tracking policy of this class is "deferred implicit". |
||
1025 | * |
||
1026 | * @return bool |
||
1027 | */ |
||
1028 | 571 | public function isChangeTrackingDeferredImplicit() |
|
1032 | |||
1033 | /** |
||
1034 | * Whether the change tracking policy of this class is "notify". |
||
1035 | * |
||
1036 | * @return bool |
||
1037 | */ |
||
1038 | 310 | public function isChangeTrackingNotify() |
|
1042 | |||
1043 | /** |
||
1044 | * Gets the ReflectionProperties of the mapped class. |
||
1045 | * |
||
1046 | * @return array An array of ReflectionProperty instances. |
||
1047 | */ |
||
1048 | 98 | public function getReflectionProperties() |
|
1052 | |||
1053 | /** |
||
1054 | * Gets a ReflectionProperty for a specific field of the mapped class. |
||
1055 | * |
||
1056 | * @param string $name |
||
1057 | * |
||
1058 | * @return \ReflectionProperty |
||
1059 | */ |
||
1060 | public function getReflectionProperty($name) |
||
1064 | |||
1065 | /** |
||
1066 | * {@inheritDoc} |
||
1067 | */ |
||
1068 | 1375 | public function getName() |
|
1072 | |||
1073 | /** |
||
1074 | * The namespace this Document class belongs to. |
||
1075 | * |
||
1076 | * @return string $namespace The namespace name. |
||
1077 | */ |
||
1078 | public function getNamespace() |
||
1082 | |||
1083 | /** |
||
1084 | * Returns the database this Document is mapped to. |
||
1085 | * |
||
1086 | * @return string $db The database name. |
||
1087 | */ |
||
1088 | 1299 | public function getDatabase() |
|
1092 | |||
1093 | /** |
||
1094 | * Set the database this Document is mapped to. |
||
1095 | * |
||
1096 | * @param string $db The database name |
||
1097 | */ |
||
1098 | 92 | public function setDatabase($db) |
|
1102 | |||
1103 | /** |
||
1104 | * Get the collection this Document is mapped to. |
||
1105 | * |
||
1106 | * @return string $collection The collection name. |
||
1107 | */ |
||
1108 | 1300 | public function getCollection() |
|
1112 | |||
1113 | /** |
||
1114 | * Sets the collection this Document is mapped to. |
||
1115 | * |
||
1116 | * @param array|string $name |
||
1117 | * |
||
1118 | * @throws \InvalidArgumentException |
||
1119 | */ |
||
1120 | 1482 | public function setCollection($name) |
|
1134 | |||
1135 | /** |
||
1136 | * Get whether or not the documents collection is capped. |
||
1137 | * |
||
1138 | * @return bool |
||
1139 | */ |
||
1140 | 5 | public function getCollectionCapped() |
|
1144 | |||
1145 | /** |
||
1146 | * Set whether or not the documents collection is capped. |
||
1147 | * |
||
1148 | * @param bool $bool |
||
1149 | */ |
||
1150 | 1 | public function setCollectionCapped($bool) |
|
1154 | |||
1155 | /** |
||
1156 | * Get the collection size |
||
1157 | * |
||
1158 | * @return int |
||
1159 | */ |
||
1160 | 5 | public function getCollectionSize() |
|
1164 | |||
1165 | /** |
||
1166 | * Set the collection size. |
||
1167 | * |
||
1168 | * @param int $size |
||
1169 | */ |
||
1170 | 1 | public function setCollectionSize($size) |
|
1174 | |||
1175 | /** |
||
1176 | * Get the collection max. |
||
1177 | * |
||
1178 | * @return int |
||
1179 | */ |
||
1180 | 5 | public function getCollectionMax() |
|
1184 | |||
1185 | /** |
||
1186 | * Set the collection max. |
||
1187 | * |
||
1188 | * @param int $max |
||
1189 | */ |
||
1190 | 1 | public function setCollectionMax($max) |
|
1194 | |||
1195 | /** |
||
1196 | * Returns TRUE if this Document is mapped to a collection FALSE otherwise. |
||
1197 | * |
||
1198 | * @return bool |
||
1199 | */ |
||
1200 | public function isMappedToCollection() |
||
1204 | |||
1205 | /** |
||
1206 | * Validates the storage strategy of a mapping for consistency |
||
1207 | * @param array $mapping |
||
1208 | * @throws MappingException |
||
1209 | */ |
||
1210 | 1392 | private function applyStorageStrategy(array &$mapping) |
|
1253 | |||
1254 | /** |
||
1255 | * Map a single embedded document. |
||
1256 | * |
||
1257 | * @param array $mapping The mapping information. |
||
1258 | */ |
||
1259 | 6 | public function mapOneEmbedded(array $mapping) |
|
1265 | |||
1266 | /** |
||
1267 | * Map a collection of embedded documents. |
||
1268 | * |
||
1269 | * @param array $mapping The mapping information. |
||
1270 | */ |
||
1271 | 5 | public function mapManyEmbedded(array $mapping) |
|
1277 | |||
1278 | /** |
||
1279 | * Map a single document reference. |
||
1280 | * |
||
1281 | * @param array $mapping The mapping information. |
||
1282 | */ |
||
1283 | 2 | public function mapOneReference(array $mapping) |
|
1289 | |||
1290 | /** |
||
1291 | * Map a collection of document references. |
||
1292 | * |
||
1293 | * @param array $mapping The mapping information. |
||
1294 | */ |
||
1295 | 1 | public function mapManyReference(array $mapping) |
|
1301 | |||
1302 | /** |
||
1303 | * INTERNAL: |
||
1304 | * Adds a field mapping without completing/validating it. |
||
1305 | * This is mainly used to add inherited field mappings to derived classes. |
||
1306 | * |
||
1307 | * @param array $fieldMapping |
||
1308 | */ |
||
1309 | 116 | public function addInheritedFieldMapping(array $fieldMapping) |
|
1319 | |||
1320 | /** |
||
1321 | * INTERNAL: |
||
1322 | * Adds an association mapping without completing/validating it. |
||
1323 | * This is mainly used to add inherited association mappings to derived classes. |
||
1324 | * |
||
1325 | * @param array $mapping |
||
1326 | * |
||
1327 | * |
||
1328 | * @throws MappingException |
||
1329 | */ |
||
1330 | 68 | public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) |
|
1334 | |||
1335 | /** |
||
1336 | * Checks whether the class has a mapped association with the given field name. |
||
1337 | * |
||
1338 | * @param string $fieldName |
||
1339 | * @return bool |
||
1340 | */ |
||
1341 | 32 | public function hasReference($fieldName) |
|
1345 | |||
1346 | /** |
||
1347 | * Checks whether the class has a mapped embed with the given field name. |
||
1348 | * |
||
1349 | * @param string $fieldName |
||
1350 | * @return bool |
||
1351 | */ |
||
1352 | 5 | public function hasEmbed($fieldName) |
|
1356 | |||
1357 | /** |
||
1358 | * {@inheritDoc} |
||
1359 | * |
||
1360 | * Checks whether the class has a mapped association (embed or reference) with the given field name. |
||
1361 | */ |
||
1362 | 7 | public function hasAssociation($fieldName) |
|
1366 | |||
1367 | /** |
||
1368 | * {@inheritDoc} |
||
1369 | * |
||
1370 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
1371 | * is a single valued association. |
||
1372 | */ |
||
1373 | public function isSingleValuedAssociation($fieldName) |
||
1377 | |||
1378 | /** |
||
1379 | * {@inheritDoc} |
||
1380 | * |
||
1381 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
1382 | * is a collection valued association. |
||
1383 | */ |
||
1384 | public function isCollectionValuedAssociation($fieldName) |
||
1388 | |||
1389 | /** |
||
1390 | * Checks whether the class has a mapped association for the specified field |
||
1391 | * and if yes, checks whether it is a single-valued association (to-one). |
||
1392 | * |
||
1393 | * @param string $fieldName |
||
1394 | * @return bool TRUE if the association exists and is single-valued, FALSE otherwise. |
||
1395 | */ |
||
1396 | public function isSingleValuedReference($fieldName) |
||
1401 | |||
1402 | /** |
||
1403 | * Checks whether the class has a mapped association for the specified field |
||
1404 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
1405 | * |
||
1406 | * @param string $fieldName |
||
1407 | * @return bool TRUE if the association exists and is collection-valued, FALSE otherwise. |
||
1408 | */ |
||
1409 | public function isCollectionValuedReference($fieldName) |
||
1414 | |||
1415 | /** |
||
1416 | * Checks whether the class has a mapped embedded document for the specified field |
||
1417 | * and if yes, checks whether it is a single-valued association (to-one). |
||
1418 | * |
||
1419 | * @param string $fieldName |
||
1420 | * @return bool TRUE if the association exists and is single-valued, FALSE otherwise. |
||
1421 | */ |
||
1422 | public function isSingleValuedEmbed($fieldName) |
||
1427 | |||
1428 | /** |
||
1429 | * Checks whether the class has a mapped embedded document for the specified field |
||
1430 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
1431 | * |
||
1432 | * @param string $fieldName |
||
1433 | * @return bool TRUE if the association exists and is collection-valued, FALSE otherwise. |
||
1434 | */ |
||
1435 | public function isCollectionValuedEmbed($fieldName) |
||
1440 | |||
1441 | /** |
||
1442 | * Sets the ID generator used to generate IDs for instances of this class. |
||
1443 | * |
||
1444 | * @param AbstractIdGenerator $generator |
||
1445 | */ |
||
1446 | 1311 | public function setIdGenerator($generator) |
|
1450 | |||
1451 | /** |
||
1452 | * Casts the identifier to its portable PHP type. |
||
1453 | * |
||
1454 | * @param mixed $id |
||
1455 | * @return mixed $id |
||
1456 | */ |
||
1457 | 594 | public function getPHPIdentifierValue($id) |
|
1462 | |||
1463 | /** |
||
1464 | * Casts the identifier to its database type. |
||
1465 | * |
||
1466 | * @param mixed $id |
||
1467 | * @return mixed $id |
||
1468 | */ |
||
1469 | 657 | public function getDatabaseIdentifierValue($id) |
|
1474 | |||
1475 | /** |
||
1476 | * Sets the document identifier of a document. |
||
1477 | * |
||
1478 | * The value will be converted to a PHP type before being set. |
||
1479 | * |
||
1480 | * @param object $document |
||
1481 | * @param mixed $id |
||
1482 | */ |
||
1483 | 523 | public function setIdentifierValue($document, $id) |
|
1488 | |||
1489 | /** |
||
1490 | * Gets the document identifier as a PHP type. |
||
1491 | * |
||
1492 | * @param object $document |
||
1493 | * @return mixed $id |
||
1494 | */ |
||
1495 | 606 | public function getIdentifierValue($document) |
|
1499 | |||
1500 | /** |
||
1501 | * {@inheritDoc} |
||
1502 | * |
||
1503 | * Since MongoDB only allows exactly one identifier field this is a proxy |
||
1504 | * to {@see getIdentifierValue()} and returns an array with the identifier |
||
1505 | * field as a key. |
||
1506 | */ |
||
1507 | public function getIdentifierValues($object) |
||
1511 | |||
1512 | /** |
||
1513 | * Get the document identifier object as a database type. |
||
1514 | * |
||
1515 | * @param object $document |
||
1516 | * |
||
1517 | * @return ObjectId $id The ObjectId |
||
1518 | */ |
||
1519 | 31 | public function getIdentifierObject($document) |
|
1523 | |||
1524 | /** |
||
1525 | * Sets the specified field to the specified value on the given document. |
||
1526 | * |
||
1527 | * @param object $document |
||
1528 | * @param string $field |
||
1529 | * @param mixed $value |
||
1530 | */ |
||
1531 | 8 | public function setFieldValue($document, $field, $value) |
|
1541 | |||
1542 | /** |
||
1543 | * Gets the specified field's value off the given document. |
||
1544 | * |
||
1545 | * @param object $document |
||
1546 | * @param string $field |
||
1547 | * |
||
1548 | * @return mixed |
||
1549 | */ |
||
1550 | 27 | public function getFieldValue($document, $field) |
|
1558 | |||
1559 | /** |
||
1560 | * Gets the mapping of a field. |
||
1561 | * |
||
1562 | * @param string $fieldName The field name. |
||
1563 | * |
||
1564 | * @return array The field mapping. |
||
1565 | * |
||
1566 | * @throws MappingException If the $fieldName is not found in the fieldMappings array. |
||
1567 | */ |
||
1568 | 169 | public function getFieldMapping($fieldName) |
|
1575 | |||
1576 | /** |
||
1577 | * Gets mappings of fields holding embedded document(s). |
||
1578 | * |
||
1579 | * @return array of field mappings |
||
1580 | */ |
||
1581 | 562 | public function getEmbeddedFieldsMappings() |
|
1590 | |||
1591 | /** |
||
1592 | * Gets the field mapping by its DB name. |
||
1593 | * E.g. it returns identifier's mapping when called with _id. |
||
1594 | * |
||
1595 | * @param string $dbFieldName |
||
1596 | * |
||
1597 | * @return array |
||
1598 | * @throws MappingException |
||
1599 | */ |
||
1600 | 4 | public function getFieldMappingByDbFieldName($dbFieldName) |
|
1610 | |||
1611 | /** |
||
1612 | * Check if the field is not null. |
||
1613 | * |
||
1614 | * @param string $fieldName The field name |
||
1615 | * |
||
1616 | * @return bool TRUE if the field is not null, FALSE otherwise. |
||
1617 | */ |
||
1618 | 1 | public function isNullable($fieldName) |
|
1626 | |||
1627 | /** |
||
1628 | * Checks whether the document has a discriminator field and value configured. |
||
1629 | * |
||
1630 | * @return bool |
||
1631 | */ |
||
1632 | 497 | public function hasDiscriminator() |
|
1636 | |||
1637 | /** |
||
1638 | * Sets the type of Id generator to use for the mapped class. |
||
1639 | * |
||
1640 | * @param string $generatorType Generator type. |
||
1641 | */ |
||
1642 | 887 | public function setIdGeneratorType($generatorType) |
|
1646 | |||
1647 | /** |
||
1648 | * Sets the Id generator options. |
||
1649 | * |
||
1650 | * @param array $generatorOptions Generator options. |
||
1651 | */ |
||
1652 | public function setIdGeneratorOptions($generatorOptions) |
||
1656 | |||
1657 | /** |
||
1658 | * @return bool |
||
1659 | */ |
||
1660 | 569 | public function isInheritanceTypeNone() |
|
1664 | |||
1665 | /** |
||
1666 | * Checks whether the mapped class uses the SINGLE_COLLECTION inheritance mapping strategy. |
||
1667 | * |
||
1668 | * @return bool |
||
1669 | */ |
||
1670 | 886 | public function isInheritanceTypeSingleCollection() |
|
1674 | |||
1675 | /** |
||
1676 | * Checks whether the mapped class uses the COLLECTION_PER_CLASS inheritance mapping strategy. |
||
1677 | * |
||
1678 | * @return bool |
||
1679 | */ |
||
1680 | public function isInheritanceTypeCollectionPerClass() |
||
1684 | |||
1685 | /** |
||
1686 | * Sets the mapped subclasses of this class. |
||
1687 | * |
||
1688 | * @param string[] $subclasses The names of all mapped subclasses. |
||
1689 | */ |
||
1690 | 2 | public function setSubclasses(array $subclasses) |
|
1700 | |||
1701 | /** |
||
1702 | * Sets the parent class names. |
||
1703 | * Assumes that the class names in the passed array are in the order: |
||
1704 | * directParent -> directParentParent -> directParentParentParent ... -> root. |
||
1705 | * |
||
1706 | * @param string[] $classNames |
||
1707 | */ |
||
1708 | 1366 | public function setParentClasses(array $classNames) |
|
1718 | |||
1719 | /** |
||
1720 | * Checks whether the class will generate a new \MongoDB\BSON\ObjectId instance for us. |
||
1721 | * |
||
1722 | * @return bool TRUE if the class uses the AUTO generator, FALSE otherwise. |
||
1723 | */ |
||
1724 | public function isIdGeneratorAuto() |
||
1728 | |||
1729 | /** |
||
1730 | * Checks whether the class will use a collection to generate incremented identifiers. |
||
1731 | * |
||
1732 | * @return bool TRUE if the class uses the INCREMENT generator, FALSE otherwise. |
||
1733 | */ |
||
1734 | public function isIdGeneratorIncrement() |
||
1738 | |||
1739 | /** |
||
1740 | * Checks whether the class will generate a uuid id. |
||
1741 | * |
||
1742 | * @return bool TRUE if the class uses the UUID generator, FALSE otherwise. |
||
1743 | */ |
||
1744 | public function isIdGeneratorUuid() |
||
1748 | |||
1749 | /** |
||
1750 | * Checks whether the class uses no id generator. |
||
1751 | * |
||
1752 | * @return bool TRUE if the class does not use any id generator, FALSE otherwise. |
||
1753 | */ |
||
1754 | public function isIdGeneratorNone() |
||
1758 | |||
1759 | /** |
||
1760 | * Sets the version field mapping used for versioning. Sets the default |
||
1761 | * value to use depending on the column type. |
||
1762 | * |
||
1763 | * @param array $mapping The version field mapping array |
||
1764 | * |
||
1765 | * @throws LockException |
||
1766 | */ |
||
1767 | 67 | public function setVersionMapping(array &$mapping) |
|
1776 | |||
1777 | /** |
||
1778 | * Sets whether this class is to be versioned for optimistic locking. |
||
1779 | * |
||
1780 | * @param bool $bool |
||
1781 | */ |
||
1782 | 887 | public function setVersioned($bool) |
|
1786 | |||
1787 | /** |
||
1788 | * Sets the name of the field that is to be used for versioning if this class is |
||
1789 | * versioned for optimistic locking. |
||
1790 | * |
||
1791 | * @param string $versionField |
||
1792 | */ |
||
1793 | 887 | public function setVersionField($versionField) |
|
1797 | |||
1798 | /** |
||
1799 | * Sets the version field mapping used for versioning. Sets the default |
||
1800 | * value to use depending on the column type. |
||
1801 | * |
||
1802 | * @param array $mapping The version field mapping array |
||
1803 | * |
||
1804 | * @throws LockException |
||
1805 | */ |
||
1806 | 22 | public function setLockMapping(array &$mapping) |
|
1815 | |||
1816 | /** |
||
1817 | * Sets whether this class is to allow pessimistic locking. |
||
1818 | * |
||
1819 | * @param bool $bool |
||
1820 | */ |
||
1821 | public function setLockable($bool) |
||
1825 | |||
1826 | /** |
||
1827 | * Sets the name of the field that is to be used for storing whether a document |
||
1828 | * is currently locked or not. |
||
1829 | * |
||
1830 | * @param string $lockField |
||
1831 | */ |
||
1832 | public function setLockField($lockField) |
||
1836 | |||
1837 | /** |
||
1838 | * Marks this class as read only, no change tracking is applied to it. |
||
1839 | */ |
||
1840 | 5 | public function markReadOnly() |
|
1844 | |||
1845 | /** |
||
1846 | * {@inheritDoc} |
||
1847 | */ |
||
1848 | public function getFieldNames() |
||
1852 | |||
1853 | /** |
||
1854 | * {@inheritDoc} |
||
1855 | */ |
||
1856 | public function getAssociationNames() |
||
1860 | |||
1861 | /** |
||
1862 | * {@inheritDoc} |
||
1863 | */ |
||
1864 | 23 | public function getTypeOfField($fieldName) |
|
1869 | |||
1870 | /** |
||
1871 | * {@inheritDoc} |
||
1872 | */ |
||
1873 | 4 | public function getAssociationTargetClass($assocName) |
|
1881 | |||
1882 | /** |
||
1883 | * Retrieve the collectionClass associated with an association |
||
1884 | * |
||
1885 | * @param string $assocName |
||
1886 | */ |
||
1887 | 1 | public function getAssociationCollectionClass($assocName) |
|
1899 | |||
1900 | /** |
||
1901 | * {@inheritDoc} |
||
1902 | */ |
||
1903 | public function isAssociationInverseSide($fieldName) |
||
1907 | |||
1908 | /** |
||
1909 | * {@inheritDoc} |
||
1910 | */ |
||
1911 | public function getAssociationMappedByTargetField($fieldName) |
||
1915 | |||
1916 | /** |
||
1917 | * Map a field. |
||
1918 | * |
||
1919 | * @param array $mapping The mapping information. |
||
1920 | * |
||
1921 | * @return array |
||
1922 | * |
||
1923 | * @throws MappingException |
||
1924 | */ |
||
1925 | 1407 | public function mapField(array $mapping) |
|
2103 | |||
2104 | /** |
||
2105 | * Determines which fields get serialized. |
||
2106 | * |
||
2107 | * It is only serialized what is necessary for best unserialization performance. |
||
2108 | * That means any metadata properties that are not set or empty or simply have |
||
2109 | * their default value are NOT serialized. |
||
2110 | * |
||
2111 | * Parts that are also NOT serialized because they can not be properly unserialized: |
||
2112 | * - reflClass (ReflectionClass) |
||
2113 | * - reflFields (ReflectionProperty array) |
||
2114 | * |
||
2115 | * @return array The names of all the fields that should be serialized. |
||
2116 | */ |
||
2117 | 6 | public function __sleep() |
|
2191 | |||
2192 | /** |
||
2193 | * Restores some state that can not be serialized/unserialized. |
||
2194 | * |
||
2195 | */ |
||
2196 | 6 | public function __wakeup() |
|
2212 | |||
2213 | /** |
||
2214 | * Creates a new instance of the mapped class, without invoking the constructor. |
||
2215 | * |
||
2216 | * @return object |
||
2217 | */ |
||
2218 | 355 | public function newInstance() |
|
2222 | } |
||
2223 |
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..