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 |
||
51 | class ClassMetadata implements BaseClassMetadata |
||
52 | { |
||
53 | /* The Id generator types. */ |
||
54 | /** |
||
55 | * AUTO means Doctrine will automatically create a new \MongoDB\BSON\ObjectId instance for us. |
||
56 | */ |
||
57 | public const GENERATOR_TYPE_AUTO = 1; |
||
58 | |||
59 | /** |
||
60 | * INCREMENT means a separate collection is used for maintaining and incrementing id generation. |
||
61 | * Offers full portability. |
||
62 | */ |
||
63 | public const GENERATOR_TYPE_INCREMENT = 2; |
||
64 | |||
65 | /** |
||
66 | * UUID means Doctrine will generate a uuid for us. |
||
67 | */ |
||
68 | public const GENERATOR_TYPE_UUID = 3; |
||
69 | |||
70 | /** |
||
71 | * ALNUM means Doctrine will generate Alpha-numeric string identifiers, using the INCREMENT |
||
72 | * generator to ensure identifier uniqueness |
||
73 | */ |
||
74 | public const GENERATOR_TYPE_ALNUM = 4; |
||
75 | |||
76 | /** |
||
77 | * CUSTOM means Doctrine expect a class parameter. It will then try to initiate that class |
||
78 | * and pass other options to the generator. It will throw an Exception if the class |
||
79 | * does not exist or if an option was passed for that there is not setter in the new |
||
80 | * generator class. |
||
81 | * |
||
82 | * The class will have to be a subtype of AbstractIdGenerator. |
||
83 | */ |
||
84 | public const GENERATOR_TYPE_CUSTOM = 5; |
||
85 | |||
86 | /** |
||
87 | * NONE means Doctrine will not generate any id for us and you are responsible for manually |
||
88 | * assigning an id. |
||
89 | */ |
||
90 | public const GENERATOR_TYPE_NONE = 6; |
||
91 | |||
92 | /** |
||
93 | * Default discriminator field name. |
||
94 | * |
||
95 | * This is used for associations value for associations where a that do not define a "targetDocument" or |
||
96 | * "discriminatorField" option in their mapping. |
||
97 | */ |
||
98 | public const DEFAULT_DISCRIMINATOR_FIELD = '_doctrine_class_name'; |
||
99 | |||
100 | public const REFERENCE_ONE = 1; |
||
101 | public const REFERENCE_MANY = 2; |
||
102 | public const EMBED_ONE = 3; |
||
103 | public const EMBED_MANY = 4; |
||
104 | public const MANY = 'many'; |
||
105 | public const ONE = 'one'; |
||
106 | |||
107 | /** |
||
108 | * The types of storeAs references |
||
109 | */ |
||
110 | public const REFERENCE_STORE_AS_ID = 'id'; |
||
111 | public const REFERENCE_STORE_AS_DB_REF = 'dbRef'; |
||
112 | public const REFERENCE_STORE_AS_DB_REF_WITH_DB = 'dbRefWithDb'; |
||
113 | public const REFERENCE_STORE_AS_REF = 'ref'; |
||
114 | |||
115 | /* The inheritance mapping types */ |
||
116 | /** |
||
117 | * NONE means the class does not participate in an inheritance hierarchy |
||
118 | * and therefore does not need an inheritance mapping type. |
||
119 | */ |
||
120 | public const INHERITANCE_TYPE_NONE = 1; |
||
121 | |||
122 | /** |
||
123 | * SINGLE_COLLECTION means the class will be persisted according to the rules of |
||
124 | * <tt>Single Collection Inheritance</tt>. |
||
125 | */ |
||
126 | public const INHERITANCE_TYPE_SINGLE_COLLECTION = 2; |
||
127 | |||
128 | /** |
||
129 | * COLLECTION_PER_CLASS means the class will be persisted according to the rules |
||
130 | * of <tt>Concrete Collection Inheritance</tt>. |
||
131 | */ |
||
132 | public const INHERITANCE_TYPE_COLLECTION_PER_CLASS = 3; |
||
133 | |||
134 | /** |
||
135 | * DEFERRED_IMPLICIT means that changes of entities are calculated at commit-time |
||
136 | * by doing a property-by-property comparison with the original data. This will |
||
137 | * be done for all entities that are in MANAGED state at commit-time. |
||
138 | * |
||
139 | * This is the default change tracking policy. |
||
140 | */ |
||
141 | public const CHANGETRACKING_DEFERRED_IMPLICIT = 1; |
||
142 | |||
143 | /** |
||
144 | * DEFERRED_EXPLICIT means that changes of entities are calculated at commit-time |
||
145 | * by doing a property-by-property comparison with the original data. This will |
||
146 | * be done only for entities that were explicitly saved (through persist() or a cascade). |
||
147 | */ |
||
148 | public const CHANGETRACKING_DEFERRED_EXPLICIT = 2; |
||
149 | |||
150 | /** |
||
151 | * NOTIFY means that Doctrine relies on the entities sending out notifications |
||
152 | * when their properties change. Such entity classes must implement |
||
153 | * the <tt>NotifyPropertyChanged</tt> interface. |
||
154 | */ |
||
155 | public const CHANGETRACKING_NOTIFY = 3; |
||
156 | |||
157 | /** |
||
158 | * SET means that fields will be written to the database using a $set operator |
||
159 | */ |
||
160 | public const STORAGE_STRATEGY_SET = 'set'; |
||
161 | |||
162 | /** |
||
163 | * INCREMENT means that fields will be written to the database by calculating |
||
164 | * the difference and using the $inc operator |
||
165 | */ |
||
166 | public const STORAGE_STRATEGY_INCREMENT = 'increment'; |
||
167 | |||
168 | public const STORAGE_STRATEGY_PUSH_ALL = 'pushAll'; |
||
169 | public const STORAGE_STRATEGY_ADD_TO_SET = 'addToSet'; |
||
170 | public const STORAGE_STRATEGY_ATOMIC_SET = 'atomicSet'; |
||
171 | public const STORAGE_STRATEGY_ATOMIC_SET_ARRAY = 'atomicSetArray'; |
||
172 | public const STORAGE_STRATEGY_SET_ARRAY = 'setArray'; |
||
173 | |||
174 | private const ALLOWED_GRIDFS_FIELDS = ['_id', 'chunkSize', 'filename', 'length', 'metadata', 'uploadDate']; |
||
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: The name of the GridFS bucket the document is mapped to. |
||
190 | * @var string |
||
191 | */ |
||
192 | public $bucketName; |
||
193 | |||
194 | /** |
||
195 | * READ-ONLY: If the collection should be a fixed size. |
||
196 | * @var bool |
||
197 | */ |
||
198 | public $collectionCapped; |
||
199 | |||
200 | /** |
||
201 | * READ-ONLY: If the collection is fixed size, its size in bytes. |
||
202 | * @var int|null |
||
203 | */ |
||
204 | public $collectionSize; |
||
205 | |||
206 | /** |
||
207 | * READ-ONLY: If the collection is fixed size, the maximum number of elements to store in the collection. |
||
208 | * @var int|null |
||
209 | */ |
||
210 | public $collectionMax; |
||
211 | |||
212 | /** |
||
213 | * READ-ONLY Describes how MongoDB clients route read operations to the members of a replica set. |
||
214 | * @var string|int|null |
||
215 | */ |
||
216 | public $readPreference; |
||
217 | |||
218 | /** |
||
219 | * READ-ONLY Associated with readPreference Allows to specify criteria so that your application can target read |
||
220 | * operations to specific members, based on custom parameters. |
||
221 | * @var string[][]|null |
||
222 | */ |
||
223 | public $readPreferenceTags; |
||
224 | |||
225 | /** |
||
226 | * READ-ONLY: Describes the level of acknowledgement requested from MongoDB for write operations. |
||
227 | * @var string|int|null |
||
228 | */ |
||
229 | public $writeConcern; |
||
230 | |||
231 | /** |
||
232 | * READ-ONLY: The field name of the document identifier. |
||
233 | * @var string|null |
||
234 | */ |
||
235 | public $identifier; |
||
236 | |||
237 | /** |
||
238 | * READ-ONLY: The array of indexes for the document collection. |
||
239 | * @var array |
||
240 | */ |
||
241 | public $indexes = []; |
||
242 | |||
243 | /** |
||
244 | * READ-ONLY: Keys and options describing shard key. Only for sharded collections. |
||
245 | * @var string|null |
||
246 | */ |
||
247 | public $shardKey; |
||
248 | |||
249 | /** |
||
250 | * READ-ONLY: The name of the document class. |
||
251 | * @var string |
||
252 | */ |
||
253 | public $name; |
||
254 | |||
255 | /** |
||
256 | * READ-ONLY: The name of the document class that is at the root of the mapped document inheritance |
||
257 | * hierarchy. If the document is not part of a mapped inheritance hierarchy this is the same |
||
258 | * as {@link $documentName}. |
||
259 | * |
||
260 | * @var string |
||
261 | */ |
||
262 | public $rootDocumentName; |
||
263 | |||
264 | /** |
||
265 | * The name of the custom repository class used for the document class. |
||
266 | * (Optional). |
||
267 | * |
||
268 | * @var string |
||
269 | */ |
||
270 | public $customRepositoryClassName; |
||
271 | |||
272 | /** |
||
273 | * READ-ONLY: The names of the parent classes (ancestors). |
||
274 | * |
||
275 | * @var array |
||
276 | */ |
||
277 | public $parentClasses = []; |
||
278 | |||
279 | /** |
||
280 | * READ-ONLY: The names of all subclasses (descendants). |
||
281 | * |
||
282 | * @var array |
||
283 | */ |
||
284 | public $subClasses = []; |
||
285 | |||
286 | /** |
||
287 | * The ReflectionProperty instances of the mapped class. |
||
288 | * |
||
289 | * @var \ReflectionProperty[] |
||
290 | */ |
||
291 | public $reflFields = []; |
||
292 | |||
293 | /** |
||
294 | * READ-ONLY: The inheritance mapping type used by the class. |
||
295 | * |
||
296 | * @var int |
||
297 | */ |
||
298 | public $inheritanceType = self::INHERITANCE_TYPE_NONE; |
||
299 | |||
300 | /** |
||
301 | * READ-ONLY: The Id generator type used by the class. |
||
302 | * |
||
303 | * @var string |
||
304 | */ |
||
305 | public $generatorType = self::GENERATOR_TYPE_AUTO; |
||
306 | |||
307 | /** |
||
308 | * READ-ONLY: The Id generator options. |
||
309 | * |
||
310 | * @var array |
||
311 | */ |
||
312 | public $generatorOptions = []; |
||
313 | |||
314 | /** |
||
315 | * READ-ONLY: The ID generator used for generating IDs for this class. |
||
316 | * |
||
317 | * @var AbstractIdGenerator |
||
318 | */ |
||
319 | public $idGenerator; |
||
320 | |||
321 | /** |
||
322 | * READ-ONLY: The field mappings of the class. |
||
323 | * Keys are field names and values are mapping definitions. |
||
324 | * |
||
325 | * The mapping definition array has the following values: |
||
326 | * |
||
327 | * - <b>fieldName</b> (string) |
||
328 | * The name of the field in the Document. |
||
329 | * |
||
330 | * - <b>id</b> (boolean, optional) |
||
331 | * Marks the field as the primary key of the document. Multiple fields of an |
||
332 | * document can have the id attribute, forming a composite key. |
||
333 | * |
||
334 | * @var array |
||
335 | */ |
||
336 | public $fieldMappings = []; |
||
337 | |||
338 | /** |
||
339 | * READ-ONLY: The association mappings of the class. |
||
340 | * Keys are field names and values are mapping definitions. |
||
341 | * |
||
342 | * @var array |
||
343 | */ |
||
344 | public $associationMappings = []; |
||
345 | |||
346 | /** |
||
347 | * READ-ONLY: Array of fields to also load with a given method. |
||
348 | * |
||
349 | * @var array |
||
350 | */ |
||
351 | public $alsoLoadMethods = []; |
||
352 | |||
353 | /** |
||
354 | * READ-ONLY: The registered lifecycle callbacks for documents of this class. |
||
355 | * |
||
356 | * @var array |
||
357 | */ |
||
358 | public $lifecycleCallbacks = []; |
||
359 | |||
360 | /** |
||
361 | * READ-ONLY: The discriminator value of this class. |
||
362 | * |
||
363 | * <b>This does only apply to the JOINED and SINGLE_COLLECTION inheritance mapping strategies |
||
364 | * where a discriminator field is used.</b> |
||
365 | * |
||
366 | * @var mixed |
||
367 | * @see discriminatorField |
||
368 | */ |
||
369 | public $discriminatorValue; |
||
370 | |||
371 | /** |
||
372 | * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. |
||
373 | * |
||
374 | * <b>This does only apply to the SINGLE_COLLECTION inheritance mapping strategy |
||
375 | * where a discriminator field is used.</b> |
||
376 | * |
||
377 | * @var mixed |
||
378 | * @see discriminatorField |
||
379 | */ |
||
380 | public $discriminatorMap = []; |
||
381 | |||
382 | /** |
||
383 | * READ-ONLY: The definition of the discriminator field used in SINGLE_COLLECTION |
||
384 | * inheritance mapping. |
||
385 | * |
||
386 | * @var string |
||
387 | */ |
||
388 | public $discriminatorField; |
||
389 | |||
390 | /** |
||
391 | * READ-ONLY: The default value for discriminatorField in case it's not set in the document |
||
392 | * |
||
393 | * @var string |
||
394 | * @see discriminatorField |
||
395 | */ |
||
396 | public $defaultDiscriminatorValue; |
||
397 | |||
398 | /** |
||
399 | * READ-ONLY: Whether this class describes the mapping of a mapped superclass. |
||
400 | * |
||
401 | * @var bool |
||
402 | */ |
||
403 | public $isMappedSuperclass = false; |
||
404 | |||
405 | /** |
||
406 | * READ-ONLY: Whether this class describes the mapping of a embedded document. |
||
407 | * |
||
408 | * @var bool |
||
409 | */ |
||
410 | public $isEmbeddedDocument = false; |
||
411 | |||
412 | /** |
||
413 | * READ-ONLY: Whether this class describes the mapping of an aggregation result document. |
||
414 | * |
||
415 | * @var bool |
||
416 | */ |
||
417 | public $isQueryResultDocument = false; |
||
418 | |||
419 | /** |
||
420 | * READ-ONLY: Whether this class describes the mapping of a gridFS file |
||
421 | * |
||
422 | * @var bool |
||
423 | */ |
||
424 | public $isFile = false; |
||
425 | |||
426 | /** READ-ONLY: The default chunk size in bytes for the file */ |
||
427 | public $chunkSizeBytes = null; |
||
428 | |||
429 | /** |
||
430 | * READ-ONLY: The policy used for change-tracking on entities of this class. |
||
431 | * |
||
432 | * @var int |
||
433 | */ |
||
434 | public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; |
||
435 | |||
436 | /** |
||
437 | * READ-ONLY: A flag for whether or not instances of this class are to be versioned |
||
438 | * with optimistic locking. |
||
439 | * |
||
440 | * @var bool $isVersioned |
||
441 | */ |
||
442 | public $isVersioned; |
||
443 | |||
444 | /** |
||
445 | * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). |
||
446 | * |
||
447 | * @var mixed $versionField |
||
448 | */ |
||
449 | public $versionField; |
||
450 | |||
451 | /** |
||
452 | * READ-ONLY: A flag for whether or not instances of this class are to allow pessimistic |
||
453 | * locking. |
||
454 | * |
||
455 | * @var bool $isLockable |
||
456 | */ |
||
457 | public $isLockable; |
||
458 | |||
459 | /** |
||
460 | * READ-ONLY: The name of the field which is used for locking a document. |
||
461 | * |
||
462 | * @var mixed $lockField |
||
463 | */ |
||
464 | public $lockField; |
||
465 | |||
466 | /** |
||
467 | * The ReflectionClass instance of the mapped class. |
||
468 | * |
||
469 | * @var \ReflectionClass |
||
470 | */ |
||
471 | public $reflClass; |
||
472 | |||
473 | /** |
||
474 | * READ_ONLY: A flag for whether or not this document is read-only. |
||
475 | * |
||
476 | * @var bool |
||
477 | */ |
||
478 | public $isReadOnly; |
||
479 | |||
480 | /** @var InstantiatorInterface|null */ |
||
481 | private $instantiator; |
||
482 | |||
483 | /** |
||
484 | * Initializes a new ClassMetadata instance that will hold the object-document mapping |
||
485 | * metadata of the class with the given name. |
||
486 | * |
||
487 | * @param string $documentName The name of the document class the new instance is used for. |
||
488 | */ |
||
489 | 1519 | public function __construct($documentName) |
|
497 | |||
498 | /** |
||
499 | * Helper method to get reference id of ref* type references |
||
500 | * @param mixed $reference |
||
501 | * @param string $storeAs |
||
502 | * @return mixed |
||
503 | * @internal |
||
504 | */ |
||
505 | 122 | public static function getReferenceId($reference, $storeAs) |
|
509 | |||
510 | /** |
||
511 | * Returns the reference prefix used for a reference |
||
512 | * @param string $storeAs |
||
513 | * @return string |
||
514 | */ |
||
515 | 187 | private static function getReferencePrefix($storeAs) |
|
523 | |||
524 | /** |
||
525 | * Returns a fully qualified field name for a given reference |
||
526 | * @param string $storeAs |
||
527 | * @param string $pathPrefix The field path prefix |
||
528 | * @return string |
||
529 | * @internal |
||
530 | */ |
||
531 | 134 | public static function getReferenceFieldName($storeAs, $pathPrefix = '') |
|
539 | |||
540 | /** |
||
541 | * {@inheritDoc} |
||
542 | */ |
||
543 | 1404 | public function getReflectionClass() |
|
551 | |||
552 | /** |
||
553 | * {@inheritDoc} |
||
554 | */ |
||
555 | 331 | public function isIdentifier($fieldName) |
|
559 | |||
560 | /** |
||
561 | * INTERNAL: |
||
562 | * Sets the mapped identifier field of this class. |
||
563 | * |
||
564 | * @param string $identifier |
||
565 | */ |
||
566 | 912 | public function setIdentifier($identifier) |
|
570 | |||
571 | /** |
||
572 | * {@inheritDoc} |
||
573 | * |
||
574 | * Since MongoDB only allows exactly one identifier field |
||
575 | * this will always return an array with only one value |
||
576 | */ |
||
577 | 39 | public function getIdentifier() |
|
581 | |||
582 | /** |
||
583 | * {@inheritDoc} |
||
584 | * |
||
585 | * Since MongoDB only allows exactly one identifier field |
||
586 | * this will always return an array with only one value |
||
587 | */ |
||
588 | 104 | public function getIdentifierFieldNames() |
|
592 | |||
593 | /** |
||
594 | * {@inheritDoc} |
||
595 | */ |
||
596 | 901 | public function hasField($fieldName) |
|
600 | |||
601 | /** |
||
602 | * Sets the inheritance type used by the class and it's subclasses. |
||
603 | * |
||
604 | * @param int $type |
||
605 | */ |
||
606 | 928 | public function setInheritanceType($type) |
|
610 | |||
611 | /** |
||
612 | * Checks whether a mapped field is inherited from an entity superclass. |
||
613 | * |
||
614 | * @param string $fieldName |
||
615 | * |
||
616 | * @return bool TRUE if the field is inherited, FALSE otherwise. |
||
617 | */ |
||
618 | 1400 | public function isInheritedField($fieldName) |
|
622 | |||
623 | /** |
||
624 | * Registers a custom repository class for the document class. |
||
625 | * |
||
626 | * @param string $repositoryClassName The class name of the custom repository. |
||
627 | */ |
||
628 | 860 | public function setCustomRepositoryClass($repositoryClassName) |
|
636 | |||
637 | /** |
||
638 | * Dispatches the lifecycle event of the given document by invoking all |
||
639 | * registered callbacks. |
||
640 | * |
||
641 | * @param string $event Lifecycle event |
||
642 | * @param object $document Document on which the event occurred |
||
643 | * @param array $arguments Arguments to pass to all callbacks |
||
644 | * @throws \InvalidArgumentException If document class is not this class or |
||
645 | * a Proxy of this class. |
||
646 | */ |
||
647 | 607 | public function invokeLifecycleCallbacks($event, $document, ?array $arguments = null) |
|
665 | |||
666 | /** |
||
667 | * Checks whether the class has callbacks registered for a lifecycle event. |
||
668 | * |
||
669 | * @param string $event Lifecycle event |
||
670 | * |
||
671 | * @return bool |
||
672 | */ |
||
673 | public function hasLifecycleCallbacks($event) |
||
677 | |||
678 | /** |
||
679 | * Gets the registered lifecycle callbacks for an event. |
||
680 | * |
||
681 | * @param string $event |
||
682 | * @return array |
||
683 | */ |
||
684 | public function getLifecycleCallbacks($event) |
||
688 | |||
689 | /** |
||
690 | * Adds a lifecycle callback for documents of this class. |
||
691 | * |
||
692 | * If the callback is already registered, this is a NOOP. |
||
693 | * |
||
694 | * @param string $callback |
||
695 | * @param string $event |
||
696 | */ |
||
697 | 827 | public function addLifecycleCallback($callback, $event) |
|
705 | |||
706 | /** |
||
707 | * Sets the lifecycle callbacks for documents of this class. |
||
708 | * |
||
709 | * Any previously registered callbacks are overwritten. |
||
710 | * |
||
711 | * @param array $callbacks |
||
712 | */ |
||
713 | 911 | public function setLifecycleCallbacks(array $callbacks) |
|
717 | |||
718 | /** |
||
719 | * Registers a method for loading document data before field hydration. |
||
720 | * |
||
721 | * Note: A method may be registered multiple times for different fields. |
||
722 | * it will be invoked only once for the first field found. |
||
723 | * |
||
724 | * @param string $method Method name |
||
725 | * @param array|string $fields Database field name(s) |
||
726 | */ |
||
727 | 14 | public function registerAlsoLoadMethod($method, $fields) |
|
731 | |||
732 | /** |
||
733 | * Sets the AlsoLoad methods for documents of this class. |
||
734 | * |
||
735 | * Any previously registered methods are overwritten. |
||
736 | * |
||
737 | * @param array $methods |
||
738 | */ |
||
739 | 911 | public function setAlsoLoadMethods(array $methods) |
|
743 | |||
744 | /** |
||
745 | * Sets the discriminator field. |
||
746 | * |
||
747 | * The field name is the the unmapped database field. Discriminator values |
||
748 | * are only used to discern the hydration class and are not mapped to class |
||
749 | * properties. |
||
750 | * |
||
751 | * @param string $discriminatorField |
||
752 | * |
||
753 | * @throws MappingException If the discriminator field conflicts with the |
||
754 | * "name" attribute of a mapped field. |
||
755 | */ |
||
756 | 937 | public function setDiscriminatorField($discriminatorField) |
|
785 | |||
786 | /** |
||
787 | * Sets the discriminator values used by this class. |
||
788 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. |
||
789 | * |
||
790 | * @param array $map |
||
791 | * |
||
792 | * @throws MappingException |
||
793 | */ |
||
794 | 930 | public function setDiscriminatorMap(array $map) |
|
814 | |||
815 | /** |
||
816 | * Sets the default discriminator value to be used for this class |
||
817 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies if the document has no discriminator value |
||
818 | * |
||
819 | * @param string $defaultDiscriminatorValue |
||
820 | * |
||
821 | * @throws MappingException |
||
822 | */ |
||
823 | 914 | public function setDefaultDiscriminatorValue($defaultDiscriminatorValue) |
|
841 | |||
842 | /** |
||
843 | * Sets the discriminator value for this class. |
||
844 | * Used for JOINED/SINGLE_TABLE inheritance and multiple document types in a single |
||
845 | * collection. |
||
846 | * |
||
847 | * @param string $value |
||
848 | * |
||
849 | * @throws MappingException |
||
850 | */ |
||
851 | 3 | public function setDiscriminatorValue($value) |
|
860 | |||
861 | /** |
||
862 | * Add a index for this Document. |
||
863 | * |
||
864 | * @param array $keys Array of keys for the index. |
||
865 | * @param array $options Array of options for the index. |
||
866 | */ |
||
867 | 202 | public function addIndex($keys, array $options = []) |
|
889 | |||
890 | /** |
||
891 | * Returns the array of indexes for this Document. |
||
892 | * |
||
893 | * @return array $indexes The array of indexes. |
||
894 | */ |
||
895 | 23 | public function getIndexes() |
|
899 | |||
900 | /** |
||
901 | * Checks whether this document has indexes or not. |
||
902 | * |
||
903 | * @return bool |
||
904 | */ |
||
905 | public function hasIndexes() |
||
909 | |||
910 | /** |
||
911 | * Set shard key for this Document. |
||
912 | * |
||
913 | * @param array $keys Array of document keys. |
||
914 | * @param array $options Array of sharding options. |
||
915 | * |
||
916 | * @throws MappingException |
||
917 | */ |
||
918 | 91 | public function setShardKey(array $keys, array $options = []) |
|
962 | |||
963 | /** |
||
964 | * @return array |
||
965 | */ |
||
966 | 17 | public function getShardKey() |
|
970 | |||
971 | /** |
||
972 | * Checks whether this document has shard key or not. |
||
973 | * |
||
974 | * @return bool |
||
975 | */ |
||
976 | 1123 | public function isSharded() |
|
980 | |||
981 | /** |
||
982 | * Sets the read preference used by this class. |
||
983 | * |
||
984 | * @param string $readPreference |
||
985 | * @param array|null $tags |
||
986 | */ |
||
987 | 911 | public function setReadPreference($readPreference, $tags) |
|
992 | |||
993 | /** |
||
994 | * Sets the write concern used by this class. |
||
995 | * |
||
996 | * @param string $writeConcern |
||
997 | */ |
||
998 | 921 | public function setWriteConcern($writeConcern) |
|
1002 | |||
1003 | /** |
||
1004 | * @return string |
||
1005 | */ |
||
1006 | 11 | public function getWriteConcern() |
|
1010 | |||
1011 | /** |
||
1012 | * Whether there is a write concern configured for this class. |
||
1013 | * |
||
1014 | * @return bool |
||
1015 | */ |
||
1016 | 554 | public function hasWriteConcern() |
|
1020 | |||
1021 | /** |
||
1022 | * Sets the change tracking policy used by this class. |
||
1023 | * |
||
1024 | * @param int $policy |
||
1025 | */ |
||
1026 | 913 | public function setChangeTrackingPolicy($policy) |
|
1030 | |||
1031 | /** |
||
1032 | * Whether the change tracking policy of this class is "deferred explicit". |
||
1033 | * |
||
1034 | * @return bool |
||
1035 | */ |
||
1036 | 64 | public function isChangeTrackingDeferredExplicit() |
|
1040 | |||
1041 | /** |
||
1042 | * Whether the change tracking policy of this class is "deferred implicit". |
||
1043 | * |
||
1044 | * @return bool |
||
1045 | */ |
||
1046 | 577 | public function isChangeTrackingDeferredImplicit() |
|
1050 | |||
1051 | /** |
||
1052 | * Whether the change tracking policy of this class is "notify". |
||
1053 | * |
||
1054 | * @return bool |
||
1055 | */ |
||
1056 | 315 | public function isChangeTrackingNotify() |
|
1060 | |||
1061 | /** |
||
1062 | * Gets the ReflectionProperties of the mapped class. |
||
1063 | * |
||
1064 | * @return array An array of ReflectionProperty instances. |
||
1065 | */ |
||
1066 | 104 | public function getReflectionProperties() |
|
1070 | |||
1071 | /** |
||
1072 | * Gets a ReflectionProperty for a specific field of the mapped class. |
||
1073 | * |
||
1074 | * @param string $name |
||
1075 | * |
||
1076 | * @return \ReflectionProperty |
||
1077 | */ |
||
1078 | public function getReflectionProperty($name) |
||
1082 | |||
1083 | /** |
||
1084 | * {@inheritDoc} |
||
1085 | */ |
||
1086 | 1408 | public function getName() |
|
1090 | |||
1091 | /** |
||
1092 | * Returns the database this Document is mapped to. |
||
1093 | * |
||
1094 | * @return string $db The database name. |
||
1095 | */ |
||
1096 | 1329 | public function getDatabase() |
|
1100 | |||
1101 | /** |
||
1102 | * Set the database this Document is mapped to. |
||
1103 | * |
||
1104 | * @param string $db The database name |
||
1105 | */ |
||
1106 | 111 | public function setDatabase($db) |
|
1110 | |||
1111 | /** |
||
1112 | * Get the collection this Document is mapped to. |
||
1113 | * |
||
1114 | * @return string $collection The collection name. |
||
1115 | */ |
||
1116 | 1322 | public function getCollection() |
|
1120 | |||
1121 | /** |
||
1122 | * Sets the collection this Document is mapped to. |
||
1123 | * |
||
1124 | * @param array|string $name |
||
1125 | * |
||
1126 | * @throws \InvalidArgumentException |
||
1127 | */ |
||
1128 | 1519 | public function setCollection($name) |
|
1142 | |||
1143 | 17 | public function getBucketName(): ?string |
|
1147 | |||
1148 | 77 | public function setBucketName(string $bucketName): void |
|
1153 | |||
1154 | 8 | public function getChunkSizeBytes(): ?int |
|
1158 | |||
1159 | 77 | public function setChunkSizeBytes(int $chunkSizeBytes): void |
|
1163 | |||
1164 | /** |
||
1165 | * Get whether or not the documents collection is capped. |
||
1166 | * |
||
1167 | * @return bool |
||
1168 | */ |
||
1169 | 5 | public function getCollectionCapped() |
|
1173 | |||
1174 | /** |
||
1175 | * Set whether or not the documents collection is capped. |
||
1176 | * |
||
1177 | * @param bool $bool |
||
1178 | */ |
||
1179 | 1 | public function setCollectionCapped($bool) |
|
1183 | |||
1184 | /** |
||
1185 | * Get the collection size |
||
1186 | * |
||
1187 | * @return int |
||
1188 | */ |
||
1189 | 5 | public function getCollectionSize() |
|
1193 | |||
1194 | /** |
||
1195 | * Set the collection size. |
||
1196 | * |
||
1197 | * @param int $size |
||
1198 | */ |
||
1199 | 1 | public function setCollectionSize($size) |
|
1203 | |||
1204 | /** |
||
1205 | * Get the collection max. |
||
1206 | * |
||
1207 | * @return int |
||
1208 | */ |
||
1209 | 5 | public function getCollectionMax() |
|
1213 | |||
1214 | /** |
||
1215 | * Set the collection max. |
||
1216 | * |
||
1217 | * @param int $max |
||
1218 | */ |
||
1219 | 1 | public function setCollectionMax($max) |
|
1223 | |||
1224 | /** |
||
1225 | * Returns TRUE if this Document is mapped to a collection FALSE otherwise. |
||
1226 | * |
||
1227 | * @return bool |
||
1228 | */ |
||
1229 | public function isMappedToCollection() |
||
1233 | |||
1234 | /** |
||
1235 | * Validates the storage strategy of a mapping for consistency |
||
1236 | * @param array $mapping |
||
1237 | * @throws MappingException |
||
1238 | */ |
||
1239 | 1426 | private function applyStorageStrategy(array &$mapping) |
|
1282 | |||
1283 | /** |
||
1284 | * Map a single embedded document. |
||
1285 | * |
||
1286 | * @param array $mapping The mapping information. |
||
1287 | */ |
||
1288 | 6 | public function mapOneEmbedded(array $mapping) |
|
1294 | |||
1295 | /** |
||
1296 | * Map a collection of embedded documents. |
||
1297 | * |
||
1298 | * @param array $mapping The mapping information. |
||
1299 | */ |
||
1300 | 5 | public function mapManyEmbedded(array $mapping) |
|
1306 | |||
1307 | /** |
||
1308 | * Map a single document reference. |
||
1309 | * |
||
1310 | * @param array $mapping The mapping information. |
||
1311 | */ |
||
1312 | 2 | public function mapOneReference(array $mapping) |
|
1318 | |||
1319 | /** |
||
1320 | * Map a collection of document references. |
||
1321 | * |
||
1322 | * @param array $mapping The mapping information. |
||
1323 | */ |
||
1324 | 1 | public function mapManyReference(array $mapping) |
|
1330 | |||
1331 | /** |
||
1332 | * INTERNAL: |
||
1333 | * Adds a field mapping without completing/validating it. |
||
1334 | * This is mainly used to add inherited field mappings to derived classes. |
||
1335 | * |
||
1336 | * @param array $fieldMapping |
||
1337 | */ |
||
1338 | 136 | public function addInheritedFieldMapping(array $fieldMapping) |
|
1348 | |||
1349 | /** |
||
1350 | * INTERNAL: |
||
1351 | * Adds an association mapping without completing/validating it. |
||
1352 | * This is mainly used to add inherited association mappings to derived classes. |
||
1353 | * |
||
1354 | * @param array $mapping |
||
1355 | * |
||
1356 | * |
||
1357 | * @throws MappingException |
||
1358 | */ |
||
1359 | 88 | public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) |
|
1363 | |||
1364 | /** |
||
1365 | * Checks whether the class has a mapped association with the given field name. |
||
1366 | * |
||
1367 | * @param string $fieldName |
||
1368 | * @return bool |
||
1369 | */ |
||
1370 | 32 | public function hasReference($fieldName) |
|
1374 | |||
1375 | /** |
||
1376 | * Checks whether the class has a mapped embed with the given field name. |
||
1377 | * |
||
1378 | * @param string $fieldName |
||
1379 | * @return bool |
||
1380 | */ |
||
1381 | 5 | public function hasEmbed($fieldName) |
|
1385 | |||
1386 | /** |
||
1387 | * {@inheritDoc} |
||
1388 | * |
||
1389 | * Checks whether the class has a mapped association (embed or reference) with the given field name. |
||
1390 | */ |
||
1391 | 7 | public function hasAssociation($fieldName) |
|
1395 | |||
1396 | /** |
||
1397 | * {@inheritDoc} |
||
1398 | * |
||
1399 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
1400 | * is a single valued association. |
||
1401 | */ |
||
1402 | public function isSingleValuedAssociation($fieldName) |
||
1406 | |||
1407 | /** |
||
1408 | * {@inheritDoc} |
||
1409 | * |
||
1410 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
1411 | * is a collection valued association. |
||
1412 | */ |
||
1413 | public function isCollectionValuedAssociation($fieldName) |
||
1417 | |||
1418 | /** |
||
1419 | * Checks whether the class has a mapped association for the specified field |
||
1420 | * and if yes, checks whether it is a single-valued association (to-one). |
||
1421 | * |
||
1422 | * @param string $fieldName |
||
1423 | * @return bool TRUE if the association exists and is single-valued, FALSE otherwise. |
||
1424 | */ |
||
1425 | public function isSingleValuedReference($fieldName) |
||
1430 | |||
1431 | /** |
||
1432 | * Checks whether the class has a mapped association for the specified field |
||
1433 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
1434 | * |
||
1435 | * @param string $fieldName |
||
1436 | * @return bool TRUE if the association exists and is collection-valued, FALSE otherwise. |
||
1437 | */ |
||
1438 | public function isCollectionValuedReference($fieldName) |
||
1443 | |||
1444 | /** |
||
1445 | * Checks whether the class has a mapped embedded document for the specified field |
||
1446 | * and if yes, checks whether it is a single-valued association (to-one). |
||
1447 | * |
||
1448 | * @param string $fieldName |
||
1449 | * @return bool TRUE if the association exists and is single-valued, FALSE otherwise. |
||
1450 | */ |
||
1451 | public function isSingleValuedEmbed($fieldName) |
||
1456 | |||
1457 | /** |
||
1458 | * Checks whether the class has a mapped embedded document for the specified field |
||
1459 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
1460 | * |
||
1461 | * @param string $fieldName |
||
1462 | * @return bool TRUE if the association exists and is collection-valued, FALSE otherwise. |
||
1463 | */ |
||
1464 | public function isCollectionValuedEmbed($fieldName) |
||
1469 | |||
1470 | /** |
||
1471 | * Sets the ID generator used to generate IDs for instances of this class. |
||
1472 | * |
||
1473 | * @param AbstractIdGenerator $generator |
||
1474 | */ |
||
1475 | 1344 | public function setIdGenerator($generator) |
|
1479 | |||
1480 | /** |
||
1481 | * Casts the identifier to its portable PHP type. |
||
1482 | * |
||
1483 | * @param mixed $id |
||
1484 | * @return mixed $id |
||
1485 | */ |
||
1486 | 606 | public function getPHPIdentifierValue($id) |
|
1491 | |||
1492 | /** |
||
1493 | * Casts the identifier to its database type. |
||
1494 | * |
||
1495 | * @param mixed $id |
||
1496 | * @return mixed $id |
||
1497 | */ |
||
1498 | 669 | public function getDatabaseIdentifierValue($id) |
|
1503 | |||
1504 | /** |
||
1505 | * Sets the document identifier of a document. |
||
1506 | * |
||
1507 | * The value will be converted to a PHP type before being set. |
||
1508 | * |
||
1509 | * @param object $document |
||
1510 | * @param mixed $id |
||
1511 | */ |
||
1512 | 527 | public function setIdentifierValue($document, $id) |
|
1517 | |||
1518 | /** |
||
1519 | * Gets the document identifier as a PHP type. |
||
1520 | * |
||
1521 | * @param object $document |
||
1522 | * @return mixed $id |
||
1523 | */ |
||
1524 | 610 | public function getIdentifierValue($document) |
|
1528 | |||
1529 | /** |
||
1530 | * {@inheritDoc} |
||
1531 | * |
||
1532 | * Since MongoDB only allows exactly one identifier field this is a proxy |
||
1533 | * to {@see getIdentifierValue()} and returns an array with the identifier |
||
1534 | * field as a key. |
||
1535 | */ |
||
1536 | public function getIdentifierValues($object) |
||
1540 | |||
1541 | /** |
||
1542 | * Get the document identifier object as a database type. |
||
1543 | * |
||
1544 | * @param object $document |
||
1545 | * |
||
1546 | * @return ObjectId $id The ObjectId |
||
1547 | */ |
||
1548 | 31 | public function getIdentifierObject($document) |
|
1552 | |||
1553 | /** |
||
1554 | * Sets the specified field to the specified value on the given document. |
||
1555 | * |
||
1556 | * @param object $document |
||
1557 | * @param string $field |
||
1558 | * @param mixed $value |
||
1559 | */ |
||
1560 | 8 | public function setFieldValue($document, $field, $value) |
|
1570 | |||
1571 | /** |
||
1572 | * Gets the specified field's value off the given document. |
||
1573 | * |
||
1574 | * @param object $document |
||
1575 | * @param string $field |
||
1576 | * |
||
1577 | * @return mixed |
||
1578 | */ |
||
1579 | 27 | public function getFieldValue($document, $field) |
|
1587 | |||
1588 | /** |
||
1589 | * Gets the mapping of a field. |
||
1590 | * |
||
1591 | * @param string $fieldName The field name. |
||
1592 | * |
||
1593 | * @return array The field mapping. |
||
1594 | * |
||
1595 | * @throws MappingException If the $fieldName is not found in the fieldMappings array. |
||
1596 | */ |
||
1597 | 171 | public function getFieldMapping($fieldName) |
|
1604 | |||
1605 | /** |
||
1606 | * Gets mappings of fields holding embedded document(s). |
||
1607 | * |
||
1608 | * @return array of field mappings |
||
1609 | */ |
||
1610 | 565 | public function getEmbeddedFieldsMappings() |
|
1619 | |||
1620 | /** |
||
1621 | * Gets the field mapping by its DB name. |
||
1622 | * E.g. it returns identifier's mapping when called with _id. |
||
1623 | * |
||
1624 | * @param string $dbFieldName |
||
1625 | * |
||
1626 | * @return array |
||
1627 | * @throws MappingException |
||
1628 | */ |
||
1629 | 7 | public function getFieldMappingByDbFieldName($dbFieldName) |
|
1639 | |||
1640 | /** |
||
1641 | * Check if the field is not null. |
||
1642 | * |
||
1643 | * @param string $fieldName The field name |
||
1644 | * |
||
1645 | * @return bool TRUE if the field is not null, FALSE otherwise. |
||
1646 | */ |
||
1647 | 1 | public function isNullable($fieldName) |
|
1655 | |||
1656 | /** |
||
1657 | * Checks whether the document has a discriminator field and value configured. |
||
1658 | * |
||
1659 | * @return bool |
||
1660 | */ |
||
1661 | 507 | public function hasDiscriminator() |
|
1665 | |||
1666 | /** |
||
1667 | * Sets the type of Id generator to use for the mapped class. |
||
1668 | * |
||
1669 | * @param string $generatorType Generator type. |
||
1670 | */ |
||
1671 | 911 | public function setIdGeneratorType($generatorType) |
|
1675 | |||
1676 | /** |
||
1677 | * Sets the Id generator options. |
||
1678 | * |
||
1679 | * @param array $generatorOptions Generator options. |
||
1680 | */ |
||
1681 | public function setIdGeneratorOptions($generatorOptions) |
||
1685 | |||
1686 | /** |
||
1687 | * @return bool |
||
1688 | */ |
||
1689 | 574 | public function isInheritanceTypeNone() |
|
1693 | |||
1694 | /** |
||
1695 | * Checks whether the mapped class uses the SINGLE_COLLECTION inheritance mapping strategy. |
||
1696 | * |
||
1697 | * @return bool |
||
1698 | */ |
||
1699 | 910 | public function isInheritanceTypeSingleCollection() |
|
1703 | |||
1704 | /** |
||
1705 | * Checks whether the mapped class uses the COLLECTION_PER_CLASS inheritance mapping strategy. |
||
1706 | * |
||
1707 | * @return bool |
||
1708 | */ |
||
1709 | public function isInheritanceTypeCollectionPerClass() |
||
1713 | |||
1714 | /** |
||
1715 | * Sets the mapped subclasses of this class. |
||
1716 | * |
||
1717 | * @param string[] $subclasses The names of all mapped subclasses. |
||
1718 | */ |
||
1719 | 2 | public function setSubclasses(array $subclasses) |
|
1725 | |||
1726 | /** |
||
1727 | * Sets the parent class names. |
||
1728 | * Assumes that the class names in the passed array are in the order: |
||
1729 | * directParent -> directParentParent -> directParentParentParent ... -> root. |
||
1730 | * |
||
1731 | * @param string[] $classNames |
||
1732 | */ |
||
1733 | 1399 | public function setParentClasses(array $classNames) |
|
1743 | |||
1744 | /** |
||
1745 | * Checks whether the class will generate a new \MongoDB\BSON\ObjectId instance for us. |
||
1746 | * |
||
1747 | * @return bool TRUE if the class uses the AUTO generator, FALSE otherwise. |
||
1748 | */ |
||
1749 | public function isIdGeneratorAuto() |
||
1753 | |||
1754 | /** |
||
1755 | * Checks whether the class will use a collection to generate incremented identifiers. |
||
1756 | * |
||
1757 | * @return bool TRUE if the class uses the INCREMENT generator, FALSE otherwise. |
||
1758 | */ |
||
1759 | public function isIdGeneratorIncrement() |
||
1763 | |||
1764 | /** |
||
1765 | * Checks whether the class will generate a uuid id. |
||
1766 | * |
||
1767 | * @return bool TRUE if the class uses the UUID generator, FALSE otherwise. |
||
1768 | */ |
||
1769 | public function isIdGeneratorUuid() |
||
1773 | |||
1774 | /** |
||
1775 | * Checks whether the class uses no id generator. |
||
1776 | * |
||
1777 | * @return bool TRUE if the class does not use any id generator, FALSE otherwise. |
||
1778 | */ |
||
1779 | public function isIdGeneratorNone() |
||
1783 | |||
1784 | /** |
||
1785 | * Sets the version field mapping used for versioning. Sets the default |
||
1786 | * value to use depending on the column type. |
||
1787 | * |
||
1788 | * @param array $mapping The version field mapping array |
||
1789 | * |
||
1790 | * @throws LockException |
||
1791 | */ |
||
1792 | 87 | public function setVersionMapping(array &$mapping) |
|
1801 | |||
1802 | /** |
||
1803 | * Sets whether this class is to be versioned for optimistic locking. |
||
1804 | * |
||
1805 | * @param bool $bool |
||
1806 | */ |
||
1807 | 911 | public function setVersioned($bool) |
|
1811 | |||
1812 | /** |
||
1813 | * Sets the name of the field that is to be used for versioning if this class is |
||
1814 | * versioned for optimistic locking. |
||
1815 | * |
||
1816 | * @param string $versionField |
||
1817 | */ |
||
1818 | 911 | public function setVersionField($versionField) |
|
1822 | |||
1823 | /** |
||
1824 | * Sets the version field mapping used for versioning. Sets the default |
||
1825 | * value to use depending on the column type. |
||
1826 | * |
||
1827 | * @param array $mapping The version field mapping array |
||
1828 | * |
||
1829 | * @throws LockException |
||
1830 | */ |
||
1831 | 22 | public function setLockMapping(array &$mapping) |
|
1840 | |||
1841 | /** |
||
1842 | * Sets whether this class is to allow pessimistic locking. |
||
1843 | * |
||
1844 | * @param bool $bool |
||
1845 | */ |
||
1846 | public function setLockable($bool) |
||
1850 | |||
1851 | /** |
||
1852 | * Sets the name of the field that is to be used for storing whether a document |
||
1853 | * is currently locked or not. |
||
1854 | * |
||
1855 | * @param string $lockField |
||
1856 | */ |
||
1857 | public function setLockField($lockField) |
||
1861 | |||
1862 | /** |
||
1863 | * Marks this class as read only, no change tracking is applied to it. |
||
1864 | */ |
||
1865 | 5 | public function markReadOnly() |
|
1869 | |||
1870 | /** |
||
1871 | * {@inheritDoc} |
||
1872 | */ |
||
1873 | public function getFieldNames() |
||
1877 | |||
1878 | /** |
||
1879 | * {@inheritDoc} |
||
1880 | */ |
||
1881 | public function getAssociationNames() |
||
1885 | |||
1886 | /** |
||
1887 | * {@inheritDoc} |
||
1888 | */ |
||
1889 | 23 | public function getTypeOfField($fieldName) |
|
1894 | |||
1895 | /** |
||
1896 | * {@inheritDoc} |
||
1897 | */ |
||
1898 | 4 | public function getAssociationTargetClass($assocName) |
|
1906 | |||
1907 | /** |
||
1908 | * Retrieve the collectionClass associated with an association |
||
1909 | * |
||
1910 | * @param string $assocName |
||
1911 | */ |
||
1912 | 1 | public function getAssociationCollectionClass($assocName) |
|
1924 | |||
1925 | /** |
||
1926 | * {@inheritDoc} |
||
1927 | */ |
||
1928 | public function isAssociationInverseSide($fieldName) |
||
1932 | |||
1933 | /** |
||
1934 | * {@inheritDoc} |
||
1935 | */ |
||
1936 | public function getAssociationMappedByTargetField($fieldName) |
||
1940 | |||
1941 | /** |
||
1942 | * Map a field. |
||
1943 | * |
||
1944 | * @param array $mapping The mapping information. |
||
1945 | * |
||
1946 | * @return array |
||
1947 | * |
||
1948 | * @throws MappingException |
||
1949 | */ |
||
1950 | 1442 | public function mapField(array $mapping) |
|
2111 | |||
2112 | /** |
||
2113 | * Determines which fields get serialized. |
||
2114 | * |
||
2115 | * It is only serialized what is necessary for best unserialization performance. |
||
2116 | * That means any metadata properties that are not set or empty or simply have |
||
2117 | * their default value are NOT serialized. |
||
2118 | * |
||
2119 | * Parts that are also NOT serialized because they can not be properly unserialized: |
||
2120 | * - reflClass (ReflectionClass) |
||
2121 | * - reflFields (ReflectionProperty array) |
||
2122 | * |
||
2123 | * @return array The names of all the fields that should be serialized. |
||
2124 | */ |
||
2125 | 6 | public function __sleep() |
|
2204 | |||
2205 | /** |
||
2206 | * Restores some state that can not be serialized/unserialized. |
||
2207 | * |
||
2208 | */ |
||
2209 | 6 | public function __wakeup() |
|
2225 | |||
2226 | /** |
||
2227 | * Creates a new instance of the mapped class, without invoking the constructor. |
||
2228 | * |
||
2229 | * @return object |
||
2230 | */ |
||
2231 | 360 | public function newInstance() |
|
2235 | |||
2236 | 79 | private function isAllowedGridFSField(string $name): bool |
|
2240 | } |
||
2241 |
Let’s assume you have a class which uses late-static binding:
}
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: