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 | private const ALLOWED_GRIDFS_FIELDS = ['_id', 'chunkSize', 'filename', 'length', 'metadata', 'uploadDate']; |
||
| 178 | |||
| 179 | /** |
||
| 180 | * READ-ONLY: The name of the mongo database the document is mapped to. |
||
| 181 | * |
||
| 182 | * @var string|null |
||
| 183 | */ |
||
| 184 | public $db; |
||
| 185 | |||
| 186 | /** |
||
| 187 | * READ-ONLY: The name of the mongo collection the document is mapped to. |
||
| 188 | * |
||
| 189 | * @var string |
||
| 190 | */ |
||
| 191 | public $collection; |
||
| 192 | |||
| 193 | /** |
||
| 194 | * READ-ONLY: The name of the GridFS bucket the document is mapped to. |
||
| 195 | * |
||
| 196 | * @var string |
||
| 197 | */ |
||
| 198 | public $bucketName = 'fs'; |
||
| 199 | |||
| 200 | /** |
||
| 201 | * READ-ONLY: If the collection should be a fixed size. |
||
| 202 | * |
||
| 203 | * @var bool |
||
| 204 | */ |
||
| 205 | public $collectionCapped = false; |
||
| 206 | |||
| 207 | /** |
||
| 208 | * READ-ONLY: If the collection is fixed size, its size in bytes. |
||
| 209 | * |
||
| 210 | * @var int|null |
||
| 211 | */ |
||
| 212 | public $collectionSize; |
||
| 213 | |||
| 214 | /** |
||
| 215 | * READ-ONLY: If the collection is fixed size, the maximum number of elements to store in the collection. |
||
| 216 | * |
||
| 217 | * @var int|null |
||
| 218 | */ |
||
| 219 | public $collectionMax; |
||
| 220 | |||
| 221 | /** |
||
| 222 | * READ-ONLY Describes how MongoDB clients route read operations to the members of a replica set. |
||
| 223 | * |
||
| 224 | * @var string|null |
||
| 225 | */ |
||
| 226 | public $readPreference; |
||
| 227 | |||
| 228 | /** |
||
| 229 | * READ-ONLY Associated with readPreference Allows to specify criteria so that your application can target read |
||
| 230 | * operations to specific members, based on custom parameters. |
||
| 231 | * |
||
| 232 | * @var string[][] |
||
| 233 | */ |
||
| 234 | public $readPreferenceTags = []; |
||
| 235 | |||
| 236 | /** |
||
| 237 | * READ-ONLY: Describes the level of acknowledgement requested from MongoDB for write operations. |
||
| 238 | * |
||
| 239 | * @var string|int|null |
||
| 240 | */ |
||
| 241 | public $writeConcern; |
||
| 242 | |||
| 243 | /** |
||
| 244 | * READ-ONLY: The field name of the document identifier. |
||
| 245 | * |
||
| 246 | * @var string|null |
||
| 247 | */ |
||
| 248 | public $identifier; |
||
| 249 | |||
| 250 | /** |
||
| 251 | * READ-ONLY: The array of indexes for the document collection. |
||
| 252 | * |
||
| 253 | * @var array |
||
| 254 | */ |
||
| 255 | public $indexes = []; |
||
| 256 | |||
| 257 | /** |
||
| 258 | * READ-ONLY: Keys and options describing shard key. Only for sharded collections. |
||
| 259 | * |
||
| 260 | * @var array<string, array> |
||
| 261 | */ |
||
| 262 | public $shardKey = []; |
||
| 263 | |||
| 264 | /** |
||
| 265 | * READ-ONLY: The name of the document class. |
||
| 266 | * |
||
| 267 | * @var string |
||
| 268 | */ |
||
| 269 | public $name; |
||
| 270 | |||
| 271 | /** |
||
| 272 | * READ-ONLY: The name of the document class that is at the root of the mapped document inheritance |
||
| 273 | * hierarchy. If the document is not part of a mapped inheritance hierarchy this is the same |
||
| 274 | * as {@link $documentName}. |
||
| 275 | * |
||
| 276 | * @var string |
||
| 277 | */ |
||
| 278 | public $rootDocumentName; |
||
| 279 | |||
| 280 | /** |
||
| 281 | * The name of the custom repository class used for the document class. |
||
| 282 | * (Optional). |
||
| 283 | * |
||
| 284 | * @var string|null |
||
| 285 | */ |
||
| 286 | public $customRepositoryClassName; |
||
| 287 | |||
| 288 | /** |
||
| 289 | * READ-ONLY: The names of the parent classes (ancestors). |
||
| 290 | * |
||
| 291 | * @var array |
||
| 292 | */ |
||
| 293 | public $parentClasses = []; |
||
| 294 | |||
| 295 | /** |
||
| 296 | * READ-ONLY: The names of all subclasses (descendants). |
||
| 297 | * |
||
| 298 | * @var array |
||
| 299 | */ |
||
| 300 | public $subClasses = []; |
||
| 301 | |||
| 302 | /** |
||
| 303 | * The ReflectionProperty instances of the mapped class. |
||
| 304 | * |
||
| 305 | * @var ReflectionProperty[] |
||
| 306 | */ |
||
| 307 | public $reflFields = []; |
||
| 308 | |||
| 309 | /** |
||
| 310 | * READ-ONLY: The inheritance mapping type used by the class. |
||
| 311 | * |
||
| 312 | * @var int |
||
| 313 | */ |
||
| 314 | public $inheritanceType = self::INHERITANCE_TYPE_NONE; |
||
| 315 | |||
| 316 | /** |
||
| 317 | * READ-ONLY: The Id generator type used by the class. |
||
| 318 | * |
||
| 319 | * @var int |
||
| 320 | */ |
||
| 321 | public $generatorType = self::GENERATOR_TYPE_AUTO; |
||
| 322 | |||
| 323 | /** |
||
| 324 | * READ-ONLY: The Id generator options. |
||
| 325 | * |
||
| 326 | * @var array |
||
| 327 | */ |
||
| 328 | public $generatorOptions = []; |
||
| 329 | |||
| 330 | /** |
||
| 331 | * READ-ONLY: The ID generator used for generating IDs for this class. |
||
| 332 | * |
||
| 333 | * @var AbstractIdGenerator|null |
||
| 334 | */ |
||
| 335 | public $idGenerator; |
||
| 336 | |||
| 337 | /** |
||
| 338 | * READ-ONLY: The field mappings of the class. |
||
| 339 | * Keys are field names and values are mapping definitions. |
||
| 340 | * |
||
| 341 | * The mapping definition array has the following values: |
||
| 342 | * |
||
| 343 | * - <b>fieldName</b> (string) |
||
| 344 | * The name of the field in the Document. |
||
| 345 | * |
||
| 346 | * - <b>id</b> (boolean, optional) |
||
| 347 | * Marks the field as the primary key of the document. Multiple fields of an |
||
| 348 | * document can have the id attribute, forming a composite key. |
||
| 349 | * |
||
| 350 | * @var array |
||
| 351 | */ |
||
| 352 | public $fieldMappings = []; |
||
| 353 | |||
| 354 | /** |
||
| 355 | * READ-ONLY: The association mappings of the class. |
||
| 356 | * Keys are field names and values are mapping definitions. |
||
| 357 | * |
||
| 358 | * @var array |
||
| 359 | */ |
||
| 360 | public $associationMappings = []; |
||
| 361 | |||
| 362 | /** |
||
| 363 | * READ-ONLY: Array of fields to also load with a given method. |
||
| 364 | * |
||
| 365 | * @var array |
||
| 366 | */ |
||
| 367 | public $alsoLoadMethods = []; |
||
| 368 | |||
| 369 | /** |
||
| 370 | * READ-ONLY: The registered lifecycle callbacks for documents of this class. |
||
| 371 | * |
||
| 372 | * @var array |
||
| 373 | */ |
||
| 374 | public $lifecycleCallbacks = []; |
||
| 375 | |||
| 376 | /** |
||
| 377 | * READ-ONLY: The discriminator value of this class. |
||
| 378 | * |
||
| 379 | * <b>This does only apply to the JOINED and SINGLE_COLLECTION inheritance mapping strategies |
||
| 380 | * where a discriminator field is used.</b> |
||
| 381 | * |
||
| 382 | * @see discriminatorField |
||
| 383 | * |
||
| 384 | * @var mixed |
||
| 385 | */ |
||
| 386 | public $discriminatorValue; |
||
| 387 | |||
| 388 | /** |
||
| 389 | * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. |
||
| 390 | * |
||
| 391 | * <b>This does only apply to the SINGLE_COLLECTION inheritance mapping strategy |
||
| 392 | * where a discriminator field is used.</b> |
||
| 393 | * |
||
| 394 | * @see discriminatorField |
||
| 395 | * |
||
| 396 | * @var mixed |
||
| 397 | */ |
||
| 398 | public $discriminatorMap = []; |
||
| 399 | |||
| 400 | /** |
||
| 401 | * READ-ONLY: The definition of the discriminator field used in SINGLE_COLLECTION |
||
| 402 | * inheritance mapping. |
||
| 403 | * |
||
| 404 | * @var string|null |
||
| 405 | */ |
||
| 406 | public $discriminatorField; |
||
| 407 | |||
| 408 | /** |
||
| 409 | * READ-ONLY: The default value for discriminatorField in case it's not set in the document |
||
| 410 | * |
||
| 411 | * @see discriminatorField |
||
| 412 | * |
||
| 413 | * @var string|null |
||
| 414 | */ |
||
| 415 | public $defaultDiscriminatorValue; |
||
| 416 | |||
| 417 | /** |
||
| 418 | * READ-ONLY: Whether this class describes the mapping of a mapped superclass. |
||
| 419 | * |
||
| 420 | * @var bool |
||
| 421 | */ |
||
| 422 | public $isMappedSuperclass = false; |
||
| 423 | |||
| 424 | /** |
||
| 425 | * READ-ONLY: Whether this class describes the mapping of a embedded document. |
||
| 426 | * |
||
| 427 | * @var bool |
||
| 428 | */ |
||
| 429 | public $isEmbeddedDocument = false; |
||
| 430 | |||
| 431 | /** |
||
| 432 | * READ-ONLY: Whether this class describes the mapping of an aggregation result document. |
||
| 433 | * |
||
| 434 | * @var bool |
||
| 435 | */ |
||
| 436 | public $isQueryResultDocument = false; |
||
| 437 | |||
| 438 | /** |
||
| 439 | * READ-ONLY: Whether this class describes the mapping of a database view. |
||
| 440 | * |
||
| 441 | * @var bool |
||
| 442 | */ |
||
| 443 | private $isView = false; |
||
| 444 | |||
| 445 | /** |
||
| 446 | * READ-ONLY: Whether this class describes the mapping of a gridFS file |
||
| 447 | * |
||
| 448 | * @var bool |
||
| 449 | */ |
||
| 450 | public $isFile = false; |
||
| 451 | |||
| 452 | /** |
||
| 453 | * READ-ONLY: The default chunk size in bytes for the file |
||
| 454 | * |
||
| 455 | * @var int|null |
||
| 456 | */ |
||
| 457 | public $chunkSizeBytes; |
||
| 458 | |||
| 459 | /** |
||
| 460 | * READ-ONLY: The policy used for change-tracking on entities of this class. |
||
| 461 | * |
||
| 462 | * @var int |
||
| 463 | */ |
||
| 464 | public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; |
||
| 465 | |||
| 466 | /** |
||
| 467 | * READ-ONLY: A flag for whether or not instances of this class are to be versioned |
||
| 468 | * with optimistic locking. |
||
| 469 | * |
||
| 470 | * @var bool $isVersioned |
||
| 471 | */ |
||
| 472 | public $isVersioned = false; |
||
| 473 | |||
| 474 | /** |
||
| 475 | * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). |
||
| 476 | * |
||
| 477 | * @var string|null $versionField |
||
| 478 | */ |
||
| 479 | public $versionField; |
||
| 480 | |||
| 481 | /** |
||
| 482 | * READ-ONLY: A flag for whether or not instances of this class are to allow pessimistic |
||
| 483 | * locking. |
||
| 484 | * |
||
| 485 | * @var bool $isLockable |
||
| 486 | */ |
||
| 487 | public $isLockable = false; |
||
| 488 | |||
| 489 | /** |
||
| 490 | * READ-ONLY: The name of the field which is used for locking a document. |
||
| 491 | * |
||
| 492 | * @var mixed $lockField |
||
| 493 | */ |
||
| 494 | public $lockField; |
||
| 495 | |||
| 496 | /** |
||
| 497 | * The ReflectionClass instance of the mapped class. |
||
| 498 | * |
||
| 499 | * @var ReflectionClass |
||
| 500 | */ |
||
| 501 | public $reflClass; |
||
| 502 | |||
| 503 | /** |
||
| 504 | * READ_ONLY: A flag for whether or not this document is read-only. |
||
| 505 | * |
||
| 506 | * @var bool |
||
| 507 | */ |
||
| 508 | public $isReadOnly; |
||
| 509 | |||
| 510 | /** @var InstantiatorInterface */ |
||
| 511 | private $instantiator; |
||
| 512 | |||
| 513 | /** @var string|null */ |
||
| 514 | private $rootClass; |
||
| 515 | |||
| 516 | /** |
||
| 517 | * Initializes a new ClassMetadata instance that will hold the object-document mapping |
||
| 518 | 1681 | * metadata of the class with the given name. |
|
| 519 | */ |
||
| 520 | 1681 | public function __construct(string $documentName) |
|
| 528 | |||
| 529 | /** |
||
| 530 | * Helper method to get reference id of ref* type references |
||
| 531 | * |
||
| 532 | * @internal |
||
| 533 | * |
||
| 534 | * @param mixed $reference |
||
| 535 | * |
||
| 536 | 121 | * @return mixed |
|
| 537 | */ |
||
| 538 | 121 | public static function getReferenceId($reference, string $storeAs) |
|
| 542 | |||
| 543 | /** |
||
| 544 | 189 | * Returns the reference prefix used for a reference |
|
| 545 | */ |
||
| 546 | 189 | private static function getReferencePrefix(string $storeAs) : string |
|
| 554 | |||
| 555 | /** |
||
| 556 | * Returns a fully qualified field name for a given reference |
||
| 557 | * |
||
| 558 | * @internal |
||
| 559 | * |
||
| 560 | 145 | * @param string $pathPrefix The field path prefix |
|
| 561 | */ |
||
| 562 | 145 | public static function getReferenceFieldName(string $storeAs, string $pathPrefix = '') : string |
|
| 570 | |||
| 571 | /** |
||
| 572 | 1601 | * {@inheritDoc} |
|
| 573 | */ |
||
| 574 | 1601 | public function getReflectionClass() : ReflectionClass |
|
| 578 | |||
| 579 | /** |
||
| 580 | 366 | * {@inheritDoc} |
|
| 581 | */ |
||
| 582 | 366 | public function isIdentifier($fieldName) : bool |
|
| 586 | |||
| 587 | /** |
||
| 588 | * Sets the mapped identifier field of this class. |
||
| 589 | * |
||
| 590 | 1035 | * @internal |
|
| 591 | */ |
||
| 592 | 1035 | public function setIdentifier(?string $identifier) : void |
|
| 596 | |||
| 597 | /** |
||
| 598 | * {@inheritDoc} |
||
| 599 | * |
||
| 600 | * Since MongoDB only allows exactly one identifier field |
||
| 601 | 12 | * this will always return an array with only one value |
|
| 602 | */ |
||
| 603 | 12 | public function getIdentifier() : array |
|
| 607 | |||
| 608 | /** |
||
| 609 | * Since MongoDB only allows exactly one identifier field |
||
| 610 | * this will always return an array with only one value |
||
| 611 | * |
||
| 612 | 109 | * return (string|null)[] |
|
| 613 | */ |
||
| 614 | 109 | public function getIdentifierFieldNames() : array |
|
| 618 | |||
| 619 | /** |
||
| 620 | 1011 | * {@inheritDoc} |
|
| 621 | */ |
||
| 622 | 1011 | public function hasField($fieldName) : bool |
|
| 626 | |||
| 627 | /** |
||
| 628 | 1056 | * Sets the inheritance type used by the class and it's subclasses. |
|
| 629 | */ |
||
| 630 | 1056 | public function setInheritanceType(int $type) : void |
|
| 634 | |||
| 635 | /** |
||
| 636 | 1587 | * Checks whether a mapped field is inherited from an entity superclass. |
|
| 637 | */ |
||
| 638 | 1587 | public function isInheritedField(string $fieldName) : bool |
|
| 642 | |||
| 643 | /** |
||
| 644 | 990 | * Registers a custom repository class for the document class. |
|
| 645 | */ |
||
| 646 | 990 | public function setCustomRepositoryClass(?string $repositoryClassName) : void |
|
| 654 | |||
| 655 | /** |
||
| 656 | * Dispatches the lifecycle event of the given document by invoking all |
||
| 657 | * registered callbacks. |
||
| 658 | * |
||
| 659 | * @throws InvalidArgumentException If document class is not this class or |
||
| 660 | 667 | * a Proxy of this class. |
|
| 661 | */ |
||
| 662 | 667 | public function invokeLifecycleCallbacks(string $event, object $document, ?array $arguments = null) : void |
|
| 684 | |||
| 685 | /** |
||
| 686 | * Checks whether the class has callbacks registered for a lifecycle event. |
||
| 687 | */ |
||
| 688 | public function hasLifecycleCallbacks(string $event) : bool |
||
| 692 | |||
| 693 | /** |
||
| 694 | * Gets the registered lifecycle callbacks for an event. |
||
| 695 | */ |
||
| 696 | public function getLifecycleCallbacks(string $event) : array |
||
| 700 | |||
| 701 | /** |
||
| 702 | * Adds a lifecycle callback for documents of this class. |
||
| 703 | * |
||
| 704 | 940 | * If the callback is already registered, this is a NOOP. |
|
| 705 | */ |
||
| 706 | 940 | public function addLifecycleCallback(string $callback, string $event) : void |
|
| 714 | |||
| 715 | /** |
||
| 716 | * Sets the lifecycle callbacks for documents of this class. |
||
| 717 | * |
||
| 718 | 1034 | * Any previously registered callbacks are overwritten. |
|
| 719 | */ |
||
| 720 | 1034 | public function setLifecycleCallbacks(array $callbacks) : void |
|
| 724 | |||
| 725 | /** |
||
| 726 | * Registers a method for loading document data before field hydration. |
||
| 727 | * |
||
| 728 | * Note: A method may be registered multiple times for different fields. |
||
| 729 | * it will be invoked only once for the first field found. |
||
| 730 | * |
||
| 731 | 14 | * @param array|string $fields Database field name(s) |
|
| 732 | */ |
||
| 733 | 14 | public function registerAlsoLoadMethod(string $method, $fields) : void |
|
| 737 | |||
| 738 | /** |
||
| 739 | * Sets the AlsoLoad methods for documents of this class. |
||
| 740 | * |
||
| 741 | 1034 | * Any previously registered methods are overwritten. |
|
| 742 | */ |
||
| 743 | 1034 | public function setAlsoLoadMethods(array $methods) : void |
|
| 747 | |||
| 748 | /** |
||
| 749 | * Sets the discriminator field. |
||
| 750 | * |
||
| 751 | * The field name is the the unmapped database field. Discriminator values |
||
| 752 | * are only used to discern the hydration class and are not mapped to class |
||
| 753 | * properties. |
||
| 754 | * |
||
| 755 | * @param array|string|null $discriminatorField |
||
| 756 | * |
||
| 757 | * @throws MappingException If the discriminator field conflicts with the |
||
| 758 | 1065 | * "name" attribute of a mapped field. |
|
| 759 | */ |
||
| 760 | 1065 | public function setDiscriminatorField($discriminatorField) : void |
|
| 790 | |||
| 791 | /** |
||
| 792 | * Sets the discriminator values used by this class. |
||
| 793 | * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. |
||
| 794 | * |
||
| 795 | 1054 | * @throws MappingException |
|
| 796 | */ |
||
| 797 | 1054 | public function setDiscriminatorMap(array $map) : void |
|
| 821 | |||
| 822 | /** |
||
| 823 | * Sets the default discriminator value to be used for this class |
||
| 824 | * Used for SINGLE_TABLE inheritance mapping strategies if the document has no discriminator value |
||
| 825 | * |
||
| 826 | 1037 | * @throws MappingException |
|
| 827 | */ |
||
| 828 | 1037 | public function setDefaultDiscriminatorValue(?string $defaultDiscriminatorValue) : void |
|
| 846 | |||
| 847 | /** |
||
| 848 | * Sets the discriminator value for this class. |
||
| 849 | * Used for JOINED/SINGLE_TABLE inheritance and multiple document types in a single |
||
| 850 | * collection. |
||
| 851 | * |
||
| 852 | 4 | * @throws MappingException |
|
| 853 | */ |
||
| 854 | 4 | public function setDiscriminatorValue(string $value) : void |
|
| 863 | |||
| 864 | /** |
||
| 865 | 283 | * Add a index for this Document. |
|
| 866 | */ |
||
| 867 | 283 | public function addIndex(array $keys, array $options = []) : void |
|
| 890 | |||
| 891 | /** |
||
| 892 | 50 | * Returns the array of indexes for this Document. |
|
| 893 | */ |
||
| 894 | 50 | public function getIndexes() : array |
|
| 898 | |||
| 899 | /** |
||
| 900 | * Checks whether this document has indexes or not. |
||
| 901 | */ |
||
| 902 | public function hasIndexes() : bool |
||
| 906 | |||
| 907 | /** |
||
| 908 | * Set shard key for this Document. |
||
| 909 | * |
||
| 910 | 162 | * @throws MappingException |
|
| 911 | */ |
||
| 912 | 162 | public function setShardKey(array $keys, array $options = []) : void |
|
| 957 | |||
| 958 | 27 | public function getShardKey() : array |
|
| 962 | |||
| 963 | /** |
||
| 964 | 1289 | * Checks whether this document has shard key or not. |
|
| 965 | */ |
||
| 966 | 1289 | public function isSharded() : bool |
|
| 970 | |||
| 971 | /** |
||
| 972 | 1034 | * Sets the read preference used by this class. |
|
| 973 | */ |
||
| 974 | 1034 | public function setReadPreference(?string $readPreference, array $tags) : void |
|
| 979 | |||
| 980 | /** |
||
| 981 | * Sets the write concern used by this class. |
||
| 982 | * |
||
| 983 | 1044 | * @param string|int|null $writeConcern |
|
| 984 | */ |
||
| 985 | 1044 | public function setWriteConcern($writeConcern) : void |
|
| 989 | |||
| 990 | /** |
||
| 991 | 11 | * @return int|string|null |
|
| 992 | */ |
||
| 993 | 11 | public function getWriteConcern() |
|
| 997 | |||
| 998 | /** |
||
| 999 | 615 | * Whether there is a write concern configured for this class. |
|
| 1000 | */ |
||
| 1001 | 615 | public function hasWriteConcern() : bool |
|
| 1005 | |||
| 1006 | /** |
||
| 1007 | 1035 | * Sets the change tracking policy used by this class. |
|
| 1008 | */ |
||
| 1009 | 1035 | public function setChangeTrackingPolicy(int $policy) : void |
|
| 1013 | |||
| 1014 | /** |
||
| 1015 | 70 | * Whether the change tracking policy of this class is "deferred explicit". |
|
| 1016 | */ |
||
| 1017 | 70 | public function isChangeTrackingDeferredExplicit() : bool |
|
| 1021 | |||
| 1022 | /** |
||
| 1023 | 626 | * Whether the change tracking policy of this class is "deferred implicit". |
|
| 1024 | */ |
||
| 1025 | 626 | public function isChangeTrackingDeferredImplicit() : bool |
|
| 1029 | |||
| 1030 | /** |
||
| 1031 | 346 | * Whether the change tracking policy of this class is "notify". |
|
| 1032 | */ |
||
| 1033 | 346 | public function isChangeTrackingNotify() : bool |
|
| 1037 | |||
| 1038 | /** |
||
| 1039 | 1 | * Gets the ReflectionProperties of the mapped class. |
|
| 1040 | */ |
||
| 1041 | 1 | public function getReflectionProperties() : array |
|
| 1045 | |||
| 1046 | /** |
||
| 1047 | 108 | * Gets a ReflectionProperty for a specific field of the mapped class. |
|
| 1048 | */ |
||
| 1049 | 108 | public function getReflectionProperty(string $name) : ReflectionProperty |
|
| 1053 | |||
| 1054 | /** |
||
| 1055 | 1609 | * {@inheritDoc} |
|
| 1056 | */ |
||
| 1057 | 1609 | public function getName() : string |
|
| 1061 | |||
| 1062 | /** |
||
| 1063 | 1495 | * Returns the database this Document is mapped to. |
|
| 1064 | */ |
||
| 1065 | 1495 | public function getDatabase() : ?string |
|
| 1069 | |||
| 1070 | /** |
||
| 1071 | 179 | * Set the database this Document is mapped to. |
|
| 1072 | */ |
||
| 1073 | 179 | public function setDatabase(?string $db) : void |
|
| 1077 | |||
| 1078 | /** |
||
| 1079 | 1494 | * Get the collection this Document is mapped to. |
|
| 1080 | */ |
||
| 1081 | 1494 | public function getCollection() : string |
|
| 1085 | |||
| 1086 | /** |
||
| 1087 | * Sets the collection this Document is mapped to. |
||
| 1088 | * |
||
| 1089 | * @param array|string $name |
||
| 1090 | * |
||
| 1091 | 1681 | * @throws InvalidArgumentException |
|
| 1092 | */ |
||
| 1093 | 1681 | public function setCollection($name) : void |
|
| 1107 | |||
| 1108 | 137 | public function getBucketName() : ?string |
|
| 1112 | |||
| 1113 | 1 | public function setBucketName(string $bucketName) : void |
|
| 1118 | |||
| 1119 | 12 | public function getChunkSizeBytes() : ?int |
|
| 1123 | |||
| 1124 | 140 | public function setChunkSizeBytes(int $chunkSizeBytes) : void |
|
| 1128 | |||
| 1129 | /** |
||
| 1130 | 11 | * Get whether or not the documents collection is capped. |
|
| 1131 | */ |
||
| 1132 | 11 | public function getCollectionCapped() : bool |
|
| 1136 | |||
| 1137 | /** |
||
| 1138 | 1 | * Set whether or not the documents collection is capped. |
|
| 1139 | */ |
||
| 1140 | 1 | public function setCollectionCapped(bool $bool) : void |
|
| 1144 | |||
| 1145 | /** |
||
| 1146 | 11 | * Get the collection size |
|
| 1147 | */ |
||
| 1148 | 11 | public function getCollectionSize() : ?int |
|
| 1152 | |||
| 1153 | /** |
||
| 1154 | 1 | * Set the collection size. |
|
| 1155 | */ |
||
| 1156 | 1 | public function setCollectionSize(int $size) : void |
|
| 1160 | |||
| 1161 | /** |
||
| 1162 | 11 | * Get the collection max. |
|
| 1163 | */ |
||
| 1164 | 11 | public function getCollectionMax() : ?int |
|
| 1168 | |||
| 1169 | /** |
||
| 1170 | 1 | * Set the collection max. |
|
| 1171 | */ |
||
| 1172 | 1 | public function setCollectionMax(int $max) : void |
|
| 1176 | |||
| 1177 | /** |
||
| 1178 | * Returns TRUE if this Document is mapped to a collection FALSE otherwise. |
||
| 1179 | */ |
||
| 1180 | public function isMappedToCollection() : bool |
||
| 1184 | |||
| 1185 | /** |
||
| 1186 | * Validates the storage strategy of a mapping for consistency |
||
| 1187 | * |
||
| 1188 | 1619 | * @throws MappingException |
|
| 1189 | */ |
||
| 1190 | 1619 | private function applyStorageStrategy(array &$mapping) : void |
|
| 1236 | |||
| 1237 | 6 | /** |
|
| 1238 | 6 | * Map a single embedded document. |
|
| 1239 | 6 | */ |
|
| 1240 | 5 | public function mapOneEmbedded(array $mapping) : void |
|
| 1246 | |||
| 1247 | 6 | /** |
|
| 1248 | 6 | * Map a collection of embedded documents. |
|
| 1249 | 6 | */ |
|
| 1250 | 6 | public function mapManyEmbedded(array $mapping) : void |
|
| 1256 | |||
| 1257 | 3 | /** |
|
| 1258 | 3 | * Map a single document reference. |
|
| 1259 | 3 | */ |
|
| 1260 | 3 | public function mapOneReference(array $mapping) : void |
|
| 1266 | |||
| 1267 | 1 | /** |
|
| 1268 | 1 | * Map a collection of document references. |
|
| 1269 | 1 | */ |
|
| 1270 | 1 | public function mapManyReference(array $mapping) : void |
|
| 1276 | |||
| 1277 | /** |
||
| 1278 | 205 | * Adds a field mapping without completing/validating it. |
|
| 1279 | * This is mainly used to add inherited field mappings to derived classes. |
||
| 1280 | 205 | * |
|
| 1281 | * @internal |
||
| 1282 | 205 | */ |
|
| 1283 | 205 | public function addInheritedFieldMapping(array $fieldMapping) : void |
|
| 1293 | |||
| 1294 | /** |
||
| 1295 | * Adds an association mapping without completing/validating it. |
||
| 1296 | * This is mainly used to add inherited association mappings to derived classes. |
||
| 1297 | 154 | * |
|
| 1298 | * @internal |
||
| 1299 | 154 | * |
|
| 1300 | 154 | * @throws MappingException |
|
| 1301 | */ |
||
| 1302 | public function addInheritedAssociationMapping(array $mapping) : void |
||
| 1306 | |||
| 1307 | 33 | /** |
|
| 1308 | * Checks whether the class has a mapped association with the given field name. |
||
| 1309 | */ |
||
| 1310 | public function hasReference(string $fieldName) : bool |
||
| 1314 | |||
| 1315 | 4 | /** |
|
| 1316 | * Checks whether the class has a mapped embed with the given field name. |
||
| 1317 | */ |
||
| 1318 | public function hasEmbed(string $fieldName) : bool |
||
| 1322 | |||
| 1323 | 6 | /** |
|
| 1324 | * {@inheritDoc} |
||
| 1325 | 6 | * |
|
| 1326 | * Checks whether the class has a mapped association (embed or reference) with the given field name. |
||
| 1327 | */ |
||
| 1328 | public function hasAssociation($fieldName) : bool |
||
| 1332 | |||
| 1333 | /** |
||
| 1334 | * {@inheritDoc} |
||
| 1335 | * |
||
| 1336 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
| 1337 | * is a single valued association. |
||
| 1338 | */ |
||
| 1339 | public function isSingleValuedAssociation($fieldName) : bool |
||
| 1343 | |||
| 1344 | /** |
||
| 1345 | * {@inheritDoc} |
||
| 1346 | * |
||
| 1347 | * Checks whether the class has a mapped reference or embed for the specified field and |
||
| 1348 | * is a collection valued association. |
||
| 1349 | */ |
||
| 1350 | public function isCollectionValuedAssociation($fieldName) : bool |
||
| 1354 | 1 | ||
| 1355 | /** |
||
| 1356 | 1 | * Checks whether the class has a mapped association for the specified field |
|
| 1357 | 1 | * and if yes, checks whether it is a single-valued association (to-one). |
|
| 1358 | */ |
||
| 1359 | public function isSingleValuedReference(string $fieldName) : bool |
||
| 1364 | |||
| 1365 | /** |
||
| 1366 | * Checks whether the class has a mapped association for the specified field |
||
| 1367 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
| 1368 | */ |
||
| 1369 | public function isCollectionValuedReference(string $fieldName) : bool |
||
| 1374 | |||
| 1375 | /** |
||
| 1376 | * Checks whether the class has a mapped embedded document for the specified field |
||
| 1377 | * and if yes, checks whether it is a single-valued association (to-one). |
||
| 1378 | */ |
||
| 1379 | public function isSingleValuedEmbed(string $fieldName) : bool |
||
| 1384 | |||
| 1385 | /** |
||
| 1386 | * Checks whether the class has a mapped embedded document for the specified field |
||
| 1387 | * and if yes, checks whether it is a collection-valued association (to-many). |
||
| 1388 | */ |
||
| 1389 | public function isCollectionValuedEmbed(string $fieldName) : bool |
||
| 1394 | |||
| 1395 | 1543 | /** |
|
| 1396 | 1543 | * Sets the ID generator used to generate IDs for instances of this class. |
|
| 1397 | */ |
||
| 1398 | public function setIdGenerator(AbstractIdGenerator $generator) : void |
||
| 1402 | |||
| 1403 | /** |
||
| 1404 | * Casts the identifier to its portable PHP type. |
||
| 1405 | 667 | * |
|
| 1406 | * @param mixed $id |
||
| 1407 | 667 | * |
|
| 1408 | * @return mixed $id |
||
| 1409 | 667 | */ |
|
| 1410 | public function getPHPIdentifierValue($id) |
||
| 1416 | |||
| 1417 | /** |
||
| 1418 | * Casts the identifier to its database type. |
||
| 1419 | 737 | * |
|
| 1420 | * @param mixed $id |
||
| 1421 | 737 | * |
|
| 1422 | * @return mixed $id |
||
| 1423 | 737 | */ |
|
| 1424 | public function getDatabaseIdentifierValue($id) |
||
| 1430 | |||
| 1431 | /** |
||
| 1432 | * Sets the document identifier of a document. |
||
| 1433 | 597 | * |
|
| 1434 | * The value will be converted to a PHP type before being set. |
||
| 1435 | 597 | * |
|
| 1436 | 597 | * @param mixed $id |
|
| 1437 | 597 | */ |
|
| 1438 | public function setIdentifierValue(object $document, $id) : void |
||
| 1443 | |||
| 1444 | 675 | /** |
|
| 1445 | * Gets the document identifier as a PHP type. |
||
| 1446 | 675 | * |
|
| 1447 | * @return mixed $id |
||
| 1448 | */ |
||
| 1449 | public function getIdentifierValue(object $document) |
||
| 1453 | |||
| 1454 | /** |
||
| 1455 | * {@inheritDoc} |
||
| 1456 | * |
||
| 1457 | * Since MongoDB only allows exactly one identifier field this is a proxy |
||
| 1458 | * to {@see getIdentifierValue()} and returns an array with the identifier |
||
| 1459 | * field as a key. |
||
| 1460 | */ |
||
| 1461 | public function getIdentifierValues($object) : array |
||
| 1465 | |||
| 1466 | 31 | /** |
|
| 1467 | * Get the document identifier object as a database type. |
||
| 1468 | 31 | * |
|
| 1469 | * @return mixed $id |
||
| 1470 | */ |
||
| 1471 | public function getIdentifierObject(object $document) |
||
| 1475 | |||
| 1476 | 8 | /** |
|
| 1477 | * Sets the specified field to the specified value on the given document. |
||
| 1478 | 8 | * |
|
| 1479 | * @param mixed $value |
||
| 1480 | */ |
||
| 1481 | 1 | public function setFieldValue(object $document, string $field, $value) : void |
|
| 1491 | |||
| 1492 | 33 | /** |
|
| 1493 | * Gets the specified field's value off the given document. |
||
| 1494 | 33 | * |
|
| 1495 | 1 | * @return mixed |
|
| 1496 | */ |
||
| 1497 | public function getFieldValue(object $document, string $field) |
||
| 1505 | |||
| 1506 | 201 | /** |
|
| 1507 | * Gets the mapping of a field. |
||
| 1508 | 201 | * |
|
| 1509 | 6 | * @throws MappingException If the $fieldName is not found in the fieldMappings array. |
|
| 1510 | */ |
||
| 1511 | public function getFieldMapping(string $fieldName) : array |
||
| 1519 | |||
| 1520 | 604 | /** |
|
| 1521 | 604 | * Gets mappings of fields holding embedded document(s). |
|
| 1522 | */ |
||
| 1523 | 464 | public function getEmbeddedFieldsMappings() : array |
|
| 1532 | |||
| 1533 | /** |
||
| 1534 | 17 | * Gets the field mapping by its DB name. |
|
| 1535 | * E.g. it returns identifier's mapping when called with _id. |
||
| 1536 | 17 | * |
|
| 1537 | 17 | * @throws MappingException |
|
| 1538 | 15 | */ |
|
| 1539 | public function getFieldMappingByDbFieldName(string $dbFieldName) : array |
||
| 1549 | |||
| 1550 | 1 | /** |
|
| 1551 | * Check if the field is not null. |
||
| 1552 | 1 | */ |
|
| 1553 | public function isNullable(string $fieldName) : bool |
||
| 1559 | |||
| 1560 | /** |
||
| 1561 | * Checks whether the document has a discriminator field and value configured. |
||
| 1562 | */ |
||
| 1563 | public function hasDiscriminator() : bool |
||
| 1567 | |||
| 1568 | 1034 | /** |
|
| 1569 | 1034 | * Sets the type of Id generator to use for the mapped class. |
|
| 1570 | */ |
||
| 1571 | public function setIdGeneratorType(int $generatorType) : void |
||
| 1575 | |||
| 1576 | /** |
||
| 1577 | * Sets the Id generator options. |
||
| 1578 | */ |
||
| 1579 | 631 | public function setIdGeneratorOptions(array $generatorOptions) : void |
|
| 1583 | |||
| 1584 | public function isInheritanceTypeNone() : bool |
||
| 1588 | |||
| 1589 | 1031 | /** |
|
| 1590 | * Checks whether the mapped class uses the SINGLE_COLLECTION inheritance mapping strategy. |
||
| 1591 | */ |
||
| 1592 | public function isInheritanceTypeSingleCollection() : bool |
||
| 1596 | |||
| 1597 | /** |
||
| 1598 | * Checks whether the mapped class uses the COLLECTION_PER_CLASS inheritance mapping strategy. |
||
| 1599 | */ |
||
| 1600 | public function isInheritanceTypeCollectionPerClass() : bool |
||
| 1604 | |||
| 1605 | 2 | /** |
|
| 1606 | * Sets the mapped subclasses of this class. |
||
| 1607 | 2 | * |
|
| 1608 | 2 | * @param string[] $subclasses The names of all mapped subclasses. |
|
| 1609 | */ |
||
| 1610 | 2 | public function setSubclasses(array $subclasses) : void |
|
| 1616 | |||
| 1617 | /** |
||
| 1618 | * Sets the parent class names. |
||
| 1619 | 1596 | * Assumes that the class names in the passed array are in the order: |
|
| 1620 | * directParent -> directParentParent -> directParentParentParent ... -> root. |
||
| 1621 | 1596 | * |
|
| 1622 | * @param string[] $classNames |
||
| 1623 | 1596 | */ |
|
| 1624 | 1595 | public function setParentClasses(array $classNames) : void |
|
| 1634 | |||
| 1635 | /** |
||
| 1636 | * Checks whether the class will generate a new \MongoDB\BSON\ObjectId instance for us. |
||
| 1637 | */ |
||
| 1638 | public function isIdGeneratorAuto() : bool |
||
| 1642 | |||
| 1643 | /** |
||
| 1644 | * Checks whether the class will use a collection to generate incremented identifiers. |
||
| 1645 | */ |
||
| 1646 | public function isIdGeneratorIncrement() : bool |
||
| 1650 | |||
| 1651 | /** |
||
| 1652 | * Checks whether the class will generate a uuid id. |
||
| 1653 | */ |
||
| 1654 | public function isIdGeneratorUuid() : bool |
||
| 1658 | |||
| 1659 | /** |
||
| 1660 | * Checks whether the class uses no id generator. |
||
| 1661 | */ |
||
| 1662 | public function isIdGeneratorNone() : bool |
||
| 1666 | |||
| 1667 | /** |
||
| 1668 | 172 | * Sets the version field mapping used for versioning. Sets the default |
|
| 1669 | * value to use depending on the column type. |
||
| 1670 | 172 | * |
|
| 1671 | 1 | * @throws LockException |
|
| 1672 | */ |
||
| 1673 | public function setVersionMapping(array &$mapping) : void |
||
| 1682 | |||
| 1683 | 1034 | /** |
|
| 1684 | 1034 | * Sets whether this class is to be versioned for optimistic locking. |
|
| 1685 | */ |
||
| 1686 | public function setVersioned(bool $bool) : void |
||
| 1690 | 1034 | ||
| 1691 | /** |
||
| 1692 | 1034 | * Sets the name of the field that is to be used for versioning if this class is |
|
| 1693 | 1034 | * versioned for optimistic locking. |
|
| 1694 | */ |
||
| 1695 | public function setVersionField(?string $versionField) : void |
||
| 1699 | |||
| 1700 | /** |
||
| 1701 | 25 | * Sets the version field mapping used for versioning. Sets the default |
|
| 1702 | * value to use depending on the column type. |
||
| 1703 | 25 | * |
|
| 1704 | 1 | * @throws LockException |
|
| 1705 | */ |
||
| 1706 | public function setLockMapping(array &$mapping) : void |
||
| 1715 | |||
| 1716 | /** |
||
| 1717 | * Sets whether this class is to allow pessimistic locking. |
||
| 1718 | */ |
||
| 1719 | public function setLockable(bool $bool) : void |
||
| 1723 | |||
| 1724 | /** |
||
| 1725 | * Sets the name of the field that is to be used for storing whether a document |
||
| 1726 | * is currently locked or not. |
||
| 1727 | */ |
||
| 1728 | public function setLockField(string $lockField) : void |
||
| 1732 | |||
| 1733 | 5 | /** |
|
| 1734 | 5 | * Marks this class as read only, no change tracking is applied to it. |
|
| 1735 | */ |
||
| 1736 | 11 | public function markReadOnly() : void |
|
| 1740 | |||
| 1741 | 1591 | public function getRootClass() : ?string |
|
| 1745 | |||
| 1746 | 133 | public function isView() : bool |
|
| 1750 | 133 | ||
| 1751 | public function markViewOf(string $rootClass) : void |
||
| 1756 | |||
| 1757 | /** |
||
| 1758 | * {@inheritDoc} |
||
| 1759 | */ |
||
| 1760 | public function getFieldNames() : array |
||
| 1764 | |||
| 1765 | /** |
||
| 1766 | * {@inheritDoc} |
||
| 1767 | */ |
||
| 1768 | public function getAssociationNames() : array |
||
| 1772 | |||
| 1773 | /** |
||
| 1774 | * {@inheritDoc} |
||
| 1775 | */ |
||
| 1776 | public function getTypeOfField($fieldName) : ?string |
||
| 1781 | |||
| 1782 | 5 | /** |
|
| 1783 | 2 | * {@inheritDoc} |
|
| 1784 | */ |
||
| 1785 | public function getAssociationTargetClass($assocName) : ?string |
||
| 1793 | |||
| 1794 | /** |
||
| 1795 | * Retrieve the collectionClass associated with an association |
||
| 1796 | */ |
||
| 1797 | public function getAssociationCollectionClass(string $assocName) : string |
||
| 1809 | |||
| 1810 | /** |
||
| 1811 | * {@inheritDoc} |
||
| 1812 | */ |
||
| 1813 | public function isAssociationInverseSide($fieldName) : bool |
||
| 1817 | |||
| 1818 | /** |
||
| 1819 | * {@inheritDoc} |
||
| 1820 | */ |
||
| 1821 | public function getAssociationMappedByTargetField($fieldName) |
||
| 1825 | |||
| 1826 | 1635 | /** |
|
| 1827 | * Map a field. |
||
| 1828 | 1635 | * |
|
| 1829 | 9 | * @throws MappingException |
|
| 1830 | */ |
||
| 1831 | 1635 | public function mapField(array $mapping) : array |
|
| 1995 | |||
| 1996 | /** |
||
| 1997 | * Determines which fields get serialized. |
||
| 1998 | * |
||
| 1999 | * It is only serialized what is necessary for best unserialization performance. |
||
| 2000 | * That means any metadata properties that are not set or empty or simply have |
||
| 2001 | * their default value are NOT serialized. |
||
| 2002 | * |
||
| 2003 | 6 | * Parts that are also NOT serialized because they can not be properly unserialized: |
|
| 2004 | * - reflClass (ReflectionClass) |
||
| 2005 | * - reflFields (ReflectionProperty array) |
||
| 2006 | * |
||
| 2007 | 6 | * @return array The names of all the fields that should be serialized. |
|
| 2008 | */ |
||
| 2009 | public function __sleep() |
||
| 2093 | |||
| 2094 | 6 | /** |
|
| 2095 | 6 | * Restores some state that can not be serialized/unserialized. |
|
| 2096 | */ |
||
| 2097 | 6 | public function __wakeup() |
|
| 2113 | 374 | ||
| 2114 | /** |
||
| 2115 | * Creates a new instance of the mapped class, without invoking the constructor. |
||
| 2116 | 146 | */ |
|
| 2117 | public function newInstance() : object |
||
| 2121 | 1618 | ||
| 2122 | private function isAllowedGridFSField(string $name) : bool |
||
| 2126 | |||
| 2127 | 1618 | private function typeRequirementsAreMet(array $mapping) : void |
|
| 2133 | |||
| 2134 | 1560 | private function checkDuplicateMapping(array $mapping) : void |
|
| 2159 | } |
||
| 2160 |
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
SomeClassto useselfinstead: