doctrine / orm

@@ -12,9 +12,9 @@
Loading
12 12
use Doctrine\ORM\Query\QueryExpressionVisitor;
13 13
use InvalidArgumentException;
14 14
use RuntimeException;
15 +
use Stringable;
15 16
16 17
use function array_keys;
17 -
use function array_merge;
18 18
use function array_unshift;
19 19
use function assert;
20 20
use function count;
@@ -36,7 +36,7 @@
Loading
36 36
 * This class is responsible for building DQL query strings via an object oriented
37 37
 * PHP interface.
38 38
 */
39 -
class QueryBuilder
39 +
class QueryBuilder implements Stringable
40 40
{
41 41
    /**
42 42
     * The array of DQL parts collected.
@@ -378,7 +378,7 @@
Loading
378 378
     */
379 379
    public function getAllAliases(): array
380 380
    {
381 -
        return array_merge($this->getRootAliases(), array_keys($this->joinRootAliases));
381 +
        return [...$this->getRootAliases(), ...array_keys($this->joinRootAliases)];
382 382
    }
383 383
384 384
    /**
@@ -511,9 +511,8 @@
Loading
511 511
512 512
    /**
513 513
     * Gets the position of the first result the query object was set to retrieve (the "offset").
514 -
     * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
515 514
     */
516 -
    public function getFirstResult(): int|null
515 +
    public function getFirstResult(): int
517 516
    {
518 517
        return $this->firstResult;
519 518
    }

@@ -26,6 +26,7 @@
Loading
26 26
use ReflectionNamedType;
27 27
use ReflectionProperty;
28 28
use RuntimeException;
29 +
use Stringable;
29 30
30 31
use function array_diff;
31 32
use function array_flip;
@@ -139,7 +140,7 @@
Loading
139 140
 *     unique?: bool,
140 141
 * }
141 142
 */
142 -
class ClassMetadataInfo implements ClassMetadata
143 +
class ClassMetadataInfo implements ClassMetadata, Stringable
143 144
{
144 145
    /* The inheritance mapping types */
145 146
    /**
@@ -300,31 +301,21 @@
Loading
300 301
     */
301 302
    public const GENERATED_ALWAYS = 2;
302 303
303 -
    /**
304 -
     * READ-ONLY: The name of the entity class.
305 -
     *
306 -
     * @var string
307 -
     * @psalm-var class-string<T>
308 -
     */
309 -
    public $name;
310 -
311 304
    /**
312 305
     * READ-ONLY: The namespace the entity class is contained in.
313 306
     *
314 -
     * @var string
315 307
     * @todo Not really needed. Usage could be localized.
316 308
     */
317 -
    public $namespace;
309 +
    public string|null $namespace = null;
318 310
319 311
    /**
320 312
     * READ-ONLY: The name of the entity class that is at the root of the mapped entity inheritance
321 313
     * hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same
322 314
     * as {@link $name}.
323 315
     *
324 -
     * @var string
325 316
     * @psalm-var class-string
326 317
     */
327 -
    public $rootEntityName;
318 +
    public string $rootEntityName;
328 319
329 320
    /**
330 321
     * READ-ONLY: The definition of custom generator. Only used for CUSTOM
@@ -340,51 +331,46 @@
Loading
340 331
     * @todo Merge with tableGeneratorDefinition into generic generatorDefinition
341 332
     * @var array<string, string>|null
342 333
     */
343 -
    public $customGeneratorDefinition;
334 +
    public array|null $customGeneratorDefinition = null;
344 335
345 336
    /**
346 337
     * The name of the custom repository class used for the entity class.
347 338
     * (Optional).
348 339
     *
349 -
     * @var string|null
350 340
     * @psalm-var ?class-string<EntityRepository>
351 341
     */
352 -
    public $customRepositoryClassName;
342 +
    public string|null $customRepositoryClassName = null;
353 343
354 344
    /**
355 345
     * READ-ONLY: Whether this class describes the mapping of a mapped superclass.
356 -
     *
357 -
     * @var bool
358 346
     */
359 -
    public $isMappedSuperclass = false;
347 +
    public bool $isMappedSuperclass = false;
360 348
361 349
    /**
362 350
     * READ-ONLY: Whether this class describes the mapping of an embeddable class.
363 -
     *
364 -
     * @var bool
365 351
     */
366 -
    public $isEmbeddedClass = false;
352 +
    public bool $isEmbeddedClass = false;
367 353
368 354
    /**
369 355
     * READ-ONLY: The names of the parent classes (ancestors).
370 356
     *
371 357
     * @psalm-var list<class-string>
372 358
     */
373 -
    public $parentClasses = [];
359 +
    public array $parentClasses = [];
374 360
375 361
    /**
376 362
     * READ-ONLY: The names of all subclasses (descendants).
377 363
     *
378 364
     * @psalm-var list<class-string>
379 365
     */
380 -
    public $subClasses = [];
366 +
    public array $subClasses = [];
381 367
382 368
    /**
383 369
     * READ-ONLY: The names of all embedded classes based on properties.
384 370
     *
385 371
     * @psalm-var array<string, mixed[]>
386 372
     */
387 -
    public $embeddedClasses = [];
373 +
    public array $embeddedClasses = [];
388 374
389 375
    /**
390 376
     * READ-ONLY: The mappings of the results of native SQL queries.
@@ -404,7 +390,7 @@
Loading
404 390
     *                columns: mixed[]
405 391
     *            }>
406 392
     */
407 -
    public $sqlResultSetMappings = [];
393 +
    public array $sqlResultSetMappings = [];
408 394
409 395
    /**
410 396
     * READ-ONLY: The field names of all fields that are part of the identifier/primary key
@@ -412,23 +398,21 @@
Loading
412 398
     *
413 399
     * @psalm-var list<string>
414 400
     */
415 -
    public $identifier = [];
401 +
    public array $identifier = [];
416 402
417 403
    /**
418 404
     * READ-ONLY: The inheritance mapping type used by the class.
419 405
     *
420 -
     * @var int
421 406
     * @psalm-var self::INHERITANCE_TYPE_*
422 407
     */
423 -
    public $inheritanceType = self::INHERITANCE_TYPE_NONE;
408 +
    public int $inheritanceType = self::INHERITANCE_TYPE_NONE;
424 409
425 410
    /**
426 411
     * READ-ONLY: The Id generator type used by the class.
427 412
     *
428 -
     * @var int
429 413
     * @psalm-var self::GENERATOR_TYPE_*
430 414
     */
431 -
    public $generatorType = self::GENERATOR_TYPE_NONE;
415 +
    public int $generatorType = self::GENERATOR_TYPE_NONE;
432 416
433 417
    /**
434 418
     * READ-ONLY: The field mappings of the class.
@@ -478,7 +462,7 @@
Loading
478 462
     * @var mixed[]
479 463
     * @psalm-var array<string, FieldMapping>
480 464
     */
481 -
    public $fieldMappings = [];
465 +
    public array $fieldMappings = [];
482 466
483 467
    /**
484 468
     * READ-ONLY: An array of field names. Used to look up field names from column names.
@@ -486,7 +470,7 @@
Loading
486 470
     *
487 471
     * @psalm-var array<string, string>
488 472
     */
489 -
    public $fieldNames = [];
473 +
    public array $fieldNames = [];
490 474
491 475
    /**
492 476
     * READ-ONLY: A map of field names to column names. Keys are field names and values column names.
@@ -497,7 +481,7 @@
Loading
497 481
     *
498 482
     * @var mixed[]
499 483
     */
500 -
    public $columnNames = [];
484 +
    public array $columnNames = [];
501 485
502 486
    /**
503 487
     * READ-ONLY: The discriminator value of this class.
@@ -506,10 +490,8 @@
Loading
506 490
     * where a discriminator column is used.</b>
507 491
     *
508 492
     * @see discriminatorColumn
509 -
     *
510 -
     * @var mixed
511 493
     */
512 -
    public $discriminatorValue;
494 +
    public mixed $discriminatorValue = null;
513 495
514 496
    /**
515 497
     * READ-ONLY: The discriminator map of all mapped classes in the hierarchy.
@@ -523,7 +505,7 @@
Loading
523 505
     *
524 506
     * @psalm-var array<int|string, class-string>
525 507
     */
526 -
    public $discriminatorMap = [];
508 +
    public array $discriminatorMap = [];
527 509
528 510
    /**
529 511
     * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE
@@ -531,7 +513,7 @@
Loading
531 513
     *
532 514
     * @psalm-var array{name: string, fieldName: string, type: string, length?: int, columnDefinition?: string|null}|null
533 515
     */
534 -
    public $discriminatorColumn;
516 +
    public array|null $discriminatorColumn = null;
535 517
536 518
    /**
537 519
     * READ-ONLY: The primary table definition. The definition is an array with the
@@ -552,21 +534,21 @@
Loading
552 534
     *               quoted?: bool
553 535
     *           }
554 536
     */
555 -
    public $table;
537 +
    public array $table;
556 538
557 539
    /**
558 540
     * READ-ONLY: The registered lifecycle callbacks for entities of this class.
559 541
     *
560 542
     * @psalm-var array<string, list<string>>
561 543
     */
562 -
    public $lifecycleCallbacks = [];
544 +
    public array $lifecycleCallbacks = [];
563 545
564 546
    /**
565 547
     * READ-ONLY: The registered entity listeners.
566 548
     *
567 549
     * @psalm-var array<string, list<array{class: class-string, method: string}>>
568 550
     */
569 -
    public $entityListeners = [];
551 +
    public array $entityListeners = [];
570 552
571 553
    /**
572 554
     * READ-ONLY: The association mappings of this class.
@@ -623,40 +605,33 @@
Loading
623 605
     *
624 606
     * @psalm-var array<string, AssociationMapping>
625 607
     */
626 -
    public $associationMappings = [];
608 +
    public array $associationMappings = [];
627 609
628 610
    /**
629 611
     * READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite.
630 -
     *
631 -
     * @var bool
632 612
     */
633 -
    public $isIdentifierComposite = false;
613 +
    public bool $isIdentifierComposite = false;
634 614
635 615
    /**
636 616
     * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one foreign key association.
637 617
     *
638 618
     * This flag is necessary because some code blocks require special treatment of this cases.
639 -
     *
640 -
     * @var bool
641 619
     */
642 -
    public $containsForeignIdentifier = false;
620 +
    public bool $containsForeignIdentifier = false;
643 621
644 622
    /**
645 623
     * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one ENUM type.
646 624
     *
647 625
     * This flag is necessary because some code blocks require special treatment of this cases.
648 -
     *
649 -
     * @var bool
650 626
     */
651 -
    public $containsEnumIdentifier = false;
627 +
    public bool $containsEnumIdentifier = false;
652 628
653 629
    /**
654 630
     * READ-ONLY: The ID generator used for generating IDs for this class.
655 631
     *
656 -
     * @var AbstractIdGenerator
657 632
     * @todo Remove!
658 633
     */
659 -
    public $idGenerator;
634 +
    public AbstractIdGenerator $idGenerator;
660 635
661 636
    /**
662 637
     * READ-ONLY: The definition of the sequence generator of this class. Only used for the
@@ -675,47 +650,39 @@
Loading
675 650
     * @psalm-var array{sequenceName: string, allocationSize: string, initialValue: string, quoted?: mixed}|null
676 651
     * @todo Merge with tableGeneratorDefinition into generic generatorDefinition
677 652
     */
678 -
    public $sequenceGeneratorDefinition;
653 +
    public array|null $sequenceGeneratorDefinition = null;
679 654
680 655
    /**
681 656
     * READ-ONLY: The policy used for change-tracking on entities of this class.
682 -
     *
683 -
     * @var int
684 657
     */
685 -
    public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT;
658 +
    public int $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT;
686 659
687 660
    /**
688 661
     * READ-ONLY: A Flag indicating whether one or more columns of this class
689 662
     * have to be reloaded after insert / update operations.
690 -
     *
691 -
     * @var bool
692 663
     */
693 -
    public $requiresFetchAfterChange = false;
664 +
    public bool $requiresFetchAfterChange = false;
694 665
695 666
    /**
696 667
     * READ-ONLY: A flag for whether or not instances of this class are to be versioned
697 668
     * with optimistic locking.
698 -
     *
699 -
     * @var bool
700 669
     */
701 -
    public $isVersioned = false;
670 +
    public bool $isVersioned = false;
702 671
703 672
    /**
704 673
     * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any).
705 -
     *
706 -
     * @var string|null
707 674
     */
708 -
    public $versionField;
675 +
    public string|null $versionField = null;
709 676
710 677
    /** @var mixed[]|null */
711 -
    public $cache;
678 +
    public array|null $cache = null;
712 679
713 680
    /**
714 681
     * The ReflectionClass instance of the mapped class.
715 682
     *
716 -
     * @var ReflectionClass|null
683 +
     * @var ReflectionClass<T>|null
717 684
     */
718 -
    public $reflClass;
685 +
    public ReflectionClass|null $reflClass = null;
719 686
720 687
    /**
721 688
     * Is this entity marked as "read-only"?
@@ -723,39 +690,33 @@
Loading
723 690
     * That means it is never considered for change-tracking in the UnitOfWork. It is a very helpful performance
724 691
     * optimization for entities that are immutable, either in your domain or through the relation database
725 692
     * (coming from a view, or a history table for example).
726 -
     *
727 -
     * @var bool
728 693
     */
729 -
    public $isReadOnly = false;
694 +
    public bool $isReadOnly = false;
730 695
731 696
    /**
732 697
     * NamingStrategy determining the default column and table names.
733 -
     *
734 -
     * @var NamingStrategy
735 698
     */
736 -
    protected $namingStrategy;
699 +
    protected NamingStrategy $namingStrategy;
737 700
738 701
    /**
739 702
     * The ReflectionProperty instances of the mapped class.
740 703
     *
741 704
     * @var array<string, ReflectionProperty|null>
742 705
     */
743 -
    public $reflFields = [];
706 +
    public array $reflFields = [];
744 707
745 -
    /** @var InstantiatorInterface|null */
746 -
    private $instantiator;
708 +
    private InstantiatorInterface|null $instantiator = null;
747 709
748 710
    /**
749 711
     * Initializes a new ClassMetadata instance that will hold the object-relational mapping
750 712
     * metadata of the class with the given name.
751 713
     *
752 -
     * @param string $entityName The name of the entity class the new instance is used for.
753 -
     * @psalm-param class-string<T> $entityName
714 +
     * @param string $name The name of the entity class the new instance is used for.
715 +
     * @psalm-param class-string<T> $name
754 716
     */
755 -
    public function __construct($entityName, NamingStrategy|null $namingStrategy = null)
717 +
    public function __construct(public $name, NamingStrategy|null $namingStrategy = null)
756 718
    {
757 -
        $this->name           = $entityName;
758 -
        $this->rootEntityName = $entityName;
719 +
        $this->rootEntityName = $name;
759 720
        $this->namingStrategy = $namingStrategy ?: new DefaultNamingStrategy();
760 721
        $this->instantiator   = new Instantiator();
761 722
    }
@@ -766,19 +727,15 @@
Loading
766 727
     * @return ReflectionProperty[]|null[] An array of ReflectionProperty instances.
767 728
     * @psalm-return array<ReflectionProperty|null>
768 729
     */
769 -
    public function getReflectionProperties()
730 +
    public function getReflectionProperties(): array
770 731
    {
771 732
        return $this->reflFields;
772 733
    }
773 734
774 735
    /**
775 736
     * Gets a ReflectionProperty for a specific field of the mapped class.
776 -
     *
777 -
     * @param string $name
778 -
     *
779 -
     * @return ReflectionProperty
780 737
     */
781 -
    public function getReflectionProperty($name)
738 +
    public function getReflectionProperty(string $name): ReflectionProperty|null
782 739
    {
783 740
        return $this->reflFields[$name];
784 741
    }
@@ -786,11 +743,9 @@
Loading
786 743
    /**
787 744
     * Gets the ReflectionProperty for the single identifier field.
788 745
     *
789 -
     * @return ReflectionProperty
790 -
     *
791 746
     * @throws BadMethodCallException If the class has a composite identifier.
792 747
     */
793 -
    public function getSingleIdReflectionProperty()
748 +
    public function getSingleIdReflectionProperty(): ReflectionProperty|null
794 749
    {
795 750
        if ($this->isIdentifierComposite) {
796 751
            throw new BadMethodCallException('Class ' . $this->name . ' has a composite identifier.');
@@ -809,7 +764,7 @@
Loading
809 764
     *
810 765
     * @return array<string, mixed>
811 766
     */
812 -
    public function getIdentifierValues($entity)
767 +
    public function getIdentifierValues($entity): array
813 768
    {
814 769
        if ($this->isIdentifierComposite) {
815 770
            $id = [];
@@ -838,14 +793,11 @@
Loading
838 793
    /**
839 794
     * Populates the entity identifier of an entity.
840 795
     *
841 -
     * @param object $entity
842 796
     * @psalm-param array<string, mixed> $id
843 797
     *
844 -
     * @return void
845 -
     *
846 798
     * @todo Rename to assignIdentifier()
847 799
     */
848 -
    public function setIdentifierValues($entity, array $id)
800 +
    public function setIdentifierValues(object $entity, array $id): void
849 801
    {
850 802
        foreach ($id as $idField => $idValue) {
851 803
            $this->reflFields[$idField]->setValue($entity, $idValue);
@@ -854,27 +806,16 @@
Loading
854 806
855 807
    /**
856 808
     * Sets the specified field to the specified value on the given entity.
857 -
     *
858 -
     * @param object $entity
859 -
     * @param string $field
860 -
     * @param mixed  $value
861 -
     *
862 -
     * @return void
863 809
     */
864 -
    public function setFieldValue($entity, $field, $value)
810 +
    public function setFieldValue(object $entity, string $field, mixed $value): void
865 811
    {
866 812
        $this->reflFields[$field]->setValue($entity, $value);
867 813
    }
868 814
869 815
    /**
870 816
     * Gets the specified field's value off the given entity.
871 -
     *
872 -
     * @param object $entity
873 -
     * @param string $field
874 -
     *
875 -
     * @return mixed
876 817
     */
877 -
    public function getFieldValue($entity, $field)
818 +
    public function getFieldValue(object $entity, string $field): mixed
878 819
    {
879 820
        return $this->reflFields[$field]->getValue($entity);
880 821
    }
@@ -886,7 +827,7 @@
Loading
886 827
     *
887 828
     * @todo Construct meaningful string representation.
888 829
     */
889 -
    public function __toString()
830 +
    public function __toString(): string
890 831
    {
891 832
        return self::class . '@' . spl_object_id($this);
892 833
    }
@@ -1001,22 +942,16 @@
Loading
1001 942
1002 943
    /**
1003 944
     * Creates a new instance of the mapped class, without invoking the constructor.
1004 -
     *
1005 -
     * @return object
1006 945
     */
1007 -
    public function newInstance()
946 +
    public function newInstance(): object
1008 947
    {
1009 948
        return $this->instantiator->instantiate($this->name);
1010 949
    }
1011 950
1012 951
    /**
1013 952
     * Restores some state that can not be serialized/unserialized.
1014 -
     *
1015 -
     * @param ReflectionService $reflService
1016 -
     *
1017 -
     * @return void
1018 953
     */
1019 -
    public function wakeupReflection($reflService)
954 +
    public function wakeupReflection(ReflectionService $reflService): void
1020 955
    {
1021 956
        // Restore ReflectionClass and properties
1022 957
        $this->reflClass    = $reflService->getClass($this->name);
@@ -1095,10 +1030,8 @@
Loading
1095 1030
     * metadata of the class with the given name.
1096 1031
     *
1097 1032
     * @param ReflectionService $reflService The reflection service.
1098 -
     *
1099 -
     * @return void
1100 1033
     */
1101 -
    public function initializeReflection($reflService)
1034 +
    public function initializeReflection(ReflectionService $reflService): void
1102 1035
    {
1103 1036
        $this->reflClass = $reflService->getClass($this->name);
1104 1037
        $this->namespace = $reflService->getClassNamespace($this->name);
@@ -1113,11 +1046,9 @@
Loading
1113 1046
    /**
1114 1047
     * Validates Identifier.
1115 1048
     *
1116 -
     * @return void
1117 -
     *
1118 1049
     * @throws MappingException
1119 1050
     */
1120 -
    public function validateIdentifier()
1051 +
    public function validateIdentifier(): void
1121 1052
    {
1122 1053
        if ($this->isMappedSuperclass || $this->isEmbeddedClass) {
1123 1054
            return;
@@ -1136,11 +1067,9 @@
Loading
1136 1067
    /**
1137 1068
     * Validates association targets actually exist.
1138 1069
     *
1139 -
     * @return void
1140 -
     *
1141 1070
     * @throws MappingException
1142 1071
     */
1143 -
    public function validateAssociations()
1072 +
    public function validateAssociations(): void
1144 1073
    {
1145 1074
        foreach ($this->associationMappings as $mapping) {
1146 1075
            if (
@@ -1156,13 +1085,9 @@
Loading
1156 1085
    /**
1157 1086
     * Validates lifecycle callbacks.
1158 1087
     *
1159 -
     * @param ReflectionService $reflService
1160 -
     *
1161 -
     * @return void
1162 -
     *
1163 1088
     * @throws MappingException
1164 1089
     */
1165 -
    public function validateLifecycleCallbacks($reflService)
1090 +
    public function validateLifecycleCallbacks(ReflectionService $reflService): void
1166 1091
    {
1167 1092
        foreach ($this->lifecycleCallbacks as $callbacks) {
1168 1093
            foreach ($callbacks as $callbackFuncName) {
@@ -1175,18 +1100,16 @@
Loading
1175 1100
1176 1101
    /**
1177 1102
     * {@inheritDoc}
1103 +
     *
1104 +
     * Can return null when using static reflection, in violation of the LSP
1178 1105
     */
1179 1106
    public function getReflectionClass()
1180 1107
    {
1181 1108
        return $this->reflClass;
1182 1109
    }
1183 1110
1184 -
    /**
1185 -
     * @psalm-param array{usage?: mixed, region?: mixed} $cache
1186 -
     *
1187 -
     * @return void
1188 -
     */
1189 -
    public function enableCache(array $cache)
1111 +
    /** @psalm-param array{usage?: mixed, region?: mixed} $cache */
1112 +
    public function enableCache(array $cache): void
1190 1113
    {
1191 1114
        if (! isset($cache['usage'])) {
1192 1115
            $cache['usage'] = self::CACHE_USAGE_READ_ONLY;
@@ -1199,26 +1122,19 @@
Loading
1199 1122
        $this->cache = $cache;
1200 1123
    }
1201 1124
1202 -
    /**
1203 -
     * @param string $fieldName
1204 -
     * @psalm-param array{usage?: int, region?: string} $cache
1205 -
     *
1206 -
     * @return void
1207 -
     */
1208 -
    public function enableAssociationCache($fieldName, array $cache)
1125 +
    /** @psalm-param array{usage?: int, region?: string} $cache */
1126 +
    public function enableAssociationCache(string $fieldName, array $cache): void
1209 1127
    {
1210 1128
        $this->associationMappings[$fieldName]['cache'] = $this->getAssociationCacheDefaults($fieldName, $cache);
1211 1129
    }
1212 1130
1213 1131
    /**
1214 -
     * @param string $fieldName
1215 -
     * @param array  $cache
1216 1132
     * @psalm-param array{usage?: int, region?: string|null} $cache
1217 1133
     *
1218 1134
     * @return int[]|string[]
1219 1135
     * @psalm-return array{usage: int, region: string|null}
1220 1136
     */
1221 -
    public function getAssociationCacheDefaults($fieldName, array $cache)
1137 +
    public function getAssociationCacheDefaults(string $fieldName, array $cache): array
1222 1138
    {
1223 1139
        if (! isset($cache['usage'])) {
1224 1140
            $cache['usage'] = $this->cache['usage'] ?? self::CACHE_USAGE_READ_ONLY;
@@ -1233,42 +1149,32 @@
Loading
1233 1149
1234 1150
    /**
1235 1151
     * Sets the change tracking policy used by this class.
1236 -
     *
1237 -
     * @param int $policy
1238 -
     *
1239 -
     * @return void
1240 1152
     */
1241 -
    public function setChangeTrackingPolicy($policy)
1153 +
    public function setChangeTrackingPolicy(int $policy): void
1242 1154
    {
1243 1155
        $this->changeTrackingPolicy = $policy;
1244 1156
    }
1245 1157
1246 1158
    /**
1247 1159
     * Whether the change tracking policy of this class is "deferred explicit".
1248 -
     *
1249 -
     * @return bool
1250 1160
     */
1251 -
    public function isChangeTrackingDeferredExplicit()
1161 +
    public function isChangeTrackingDeferredExplicit(): bool
1252 1162
    {
1253 1163
        return $this->changeTrackingPolicy === self::CHANGETRACKING_DEFERRED_EXPLICIT;
1254 1164
    }
1255 1165
1256 1166
    /**
1257 1167
     * Whether the change tracking policy of this class is "deferred implicit".
1258 -
     *
1259 -
     * @return bool
1260 1168
     */
1261 -
    public function isChangeTrackingDeferredImplicit()
1169 +
    public function isChangeTrackingDeferredImplicit(): bool
1262 1170
    {
1263 1171
        return $this->changeTrackingPolicy === self::CHANGETRACKING_DEFERRED_IMPLICIT;
1264 1172
    }
1265 1173
1266 1174
    /**
1267 1175
     * Whether the change tracking policy of this class is "notify".
1268 -
     *
1269 -
     * @return bool
1270 1176
     */
1271 -
    public function isChangeTrackingNotify()
1177 +
    public function isChangeTrackingNotify(): bool
1272 1178
    {
1273 1179
        return $this->changeTrackingPolicy === self::CHANGETRACKING_NOTIFY;
1274 1180
    }
@@ -1289,28 +1195,14 @@
Loading
1289 1195
        return in_array($fieldName, $this->identifier, true);
1290 1196
    }
1291 1197
1292 -
    /**
1293 -
     * Checks if the field is unique.
1294 -
     *
1295 -
     * @param string $fieldName The field name.
1296 -
     *
1297 -
     * @return bool TRUE if the field is unique, FALSE otherwise.
1298 -
     */
1299 -
    public function isUniqueField($fieldName)
1198 +
    public function isUniqueField(string $fieldName): bool
1300 1199
    {
1301 1200
        $mapping = $this->getFieldMapping($fieldName);
1302 1201
1303 1202
        return $mapping !== false && isset($mapping['unique']) && $mapping['unique'];
1304 1203
    }
1305 1204
1306 -
    /**
1307 -
     * Checks if the field is not null.
1308 -
     *
1309 -
     * @param string $fieldName The field name.
1310 -
     *
1311 -
     * @return bool TRUE if the field is not null, FALSE otherwise.
1312 -
     */
1313 -
    public function isNullable($fieldName)
1205 +
    public function isNullable(string $fieldName): bool
1314 1206
    {
1315 1207
        $mapping = $this->getFieldMapping($fieldName);
1316 1208
@@ -1321,12 +1213,8 @@
Loading
1321 1213
     * Gets a column name for a field name.
1322 1214
     * If the column name for the field cannot be found, the given field name
1323 1215
     * is returned.
1324 -
     *
1325 -
     * @param string $fieldName The field name.
1326 -
     *
1327 -
     * @return string The column name.
1328 1216
     */
1329 -
    public function getColumnName($fieldName)
1217 +
    public function getColumnName(string $fieldName): string
1330 1218
    {
1331 1219
        return $this->columnNames[$fieldName] ?? $fieldName;
1332 1220
    }
@@ -1335,14 +1223,12 @@
Loading
1335 1223
     * Gets the mapping of a (regular) field that holds some data but not a
1336 1224
     * reference to another object.
1337 1225
     *
1338 -
     * @param string $fieldName The field name.
1339 -
     *
1340 1226
     * @return mixed[] The field mapping.
1341 1227
     * @psalm-return FieldMapping
1342 1228
     *
1343 1229
     * @throws MappingException
1344 1230
     */
1345 -
    public function getFieldMapping($fieldName)
1231 +
    public function getFieldMapping(string $fieldName): array
1346 1232
    {
1347 1233
        if (! isset($this->fieldMappings[$fieldName])) {
1348 1234
            throw MappingException::mappingNotFound($this->name, $fieldName);
@@ -1364,7 +1250,7 @@
Loading
1364 1250
     *
1365 1251
     * @throws MappingException
1366 1252
     */
1367 -
    public function getAssociationMapping($fieldName)
1253 +
    public function getAssociationMapping(string $fieldName): array
1368 1254
    {
1369 1255
        if (! isset($this->associationMappings[$fieldName])) {
1370 1256
            throw MappingException::mappingNotFound($this->name, $fieldName);
@@ -1378,7 +1264,7 @@
Loading
1378 1264
     *
1379 1265
     * @psalm-return array<string, AssociationMapping>
1380 1266
     */
1381 -
    public function getAssociationMappings()
1267 +
    public function getAssociationMappings(): array
1382 1268
    {
1383 1269
        return $this->associationMappings;
1384 1270
    }
@@ -1387,11 +1273,9 @@
Loading
1387 1273
     * Gets the field name for a column name.
1388 1274
     * If no field name can be found the column name is returned.
1389 1275
     *
1390 -
     * @param string $columnName The column name.
1391 -
     *
1392 1276
     * @return string The column alias.
1393 1277
     */
1394 -
    public function getFieldName($columnName)
1278 +
    public function getFieldName(string $columnName): string
1395 1279
    {
1396 1280
        return $this->fieldNames[$columnName] ?? $columnName;
1397 1281
    }
@@ -1401,14 +1285,12 @@
Loading
1401 1285
     *
1402 1286
     * @see ClassMetadataInfo::$sqlResultSetMappings
1403 1287
     *
1404 -
     * @param string $name The result set mapping name.
1405 -
     *
1406 1288
     * @return mixed[]
1407 1289
     * @psalm-return array{name: string, entities: array, columns: array}
1408 1290
     *
1409 1291
     * @throws MappingException
1410 1292
     */
1411 -
    public function getSqlResultSetMapping($name)
1293 +
    public function getSqlResultSetMapping(string $name): array
1412 1294
    {
1413 1295
        if (! isset($this->sqlResultSetMappings[$name])) {
1414 1296
            throw MappingException::resultMappingNotFound($this->name, $name);
@@ -1423,15 +1305,13 @@
Loading
1423 1305
     * @return mixed[]
1424 1306
     * @psalm-return array<string, array{name: string, entities: array, columns: array}>
1425 1307
     */
1426 -
    public function getSqlResultSetMappings()
1308 +
    public function getSqlResultSetMappings(): array
1427 1309
    {
1428 1310
        return $this->sqlResultSetMappings;
1429 1311
    }
1430 1312
1431 1313
    /**
1432 1314
     * Checks whether given property has type
1433 -
     *
1434 -
     * @param string $name Property name
1435 1315
     */
1436 1316
    private function isTypedProperty(string $name): bool
1437 1317
    {
@@ -2051,11 +1931,9 @@
Loading
2051 1931
     * Gets the name of the single id field. Note that this only works on
2052 1932
     * entity classes that have a single-field pk.
2053 1933
     *
2054 -
     * @return string
2055 -
     *
2056 1934
     * @throws MappingException If the class doesn't have an identifier or it has a composite primary key.
2057 1935
     */
2058 -
    public function getSingleIdentifierFieldName()
1936 +
    public function getSingleIdentifierFieldName(): string
2059 1937
    {
2060 1938
        if ($this->isIdentifierComposite) {
2061 1939
            throw MappingException::singleIdNotAllowedOnCompositePrimaryKey($this->name);
@@ -2072,11 +1950,9 @@
Loading
2072 1950
     * Gets the column name of the single id column. Note that this only works on
2073 1951
     * entity classes that have a single-field pk.
2074 1952
     *
2075 -
     * @return string
2076 -
     *
2077 1953
     * @throws MappingException If the class doesn't have an identifier or it has a composite primary key.
2078 1954
     */
2079 -
    public function getSingleIdentifierColumnName()
1955 +
    public function getSingleIdentifierColumnName(): string
2080 1956
    {
2081 1957
        return $this->getColumnName($this->getSingleIdentifierFieldName());
2082 1958
    }
@@ -2087,10 +1963,8 @@
Loading
2087 1963
     * Mainly used by the ClassMetadataFactory to assign inherited identifiers.
2088 1964
     *
2089 1965
     * @psalm-param list<mixed> $identifier
2090 -
     *
2091 -
     * @return void
2092 1966
     */
2093 -
    public function setIdentifier(array $identifier)
1967 +
    public function setIdentifier(array $identifier): void
2094 1968
    {
2095 1969
        $this->identifier            = $identifier;
2096 1970
        $this->isIdentifierComposite = (count($this->identifier) > 1);
@@ -2117,7 +1991,7 @@
Loading
2117 1991
     * @return mixed[]
2118 1992
     * @psalm-return list<string>
2119 1993
     */
2120 -
    public function getColumnNames(array|null $fieldNames = null)
1994 +
    public function getColumnNames(array|null $fieldNames = null): array
2121 1995
    {
2122 1996
        if ($fieldNames === null) {
2123 1997
            return array_keys($this->fieldNames);
@@ -2131,7 +2005,7 @@
Loading
2131 2005
     *
2132 2006
     * @psalm-return list<string>
2133 2007
     */
2134 -
    public function getIdentifierColumnNames()
2008 +
    public function getIdentifierColumnNames(): array
2135 2009
    {
2136 2010
        $columnNames = [];
2137 2011
@@ -2144,9 +2018,7 @@
Loading
2144 2018
2145 2019
            // Association defined as Id field
2146 2020
            $joinColumns      = $this->associationMappings[$idProperty]['joinColumns'];
2147 -
            $assocColumnNames = array_map(static function ($joinColumn) {
2148 -
                return $joinColumn['name'];
2149 -
            }, $joinColumns);
2021 +
            $assocColumnNames = array_map(static fn ($joinColumn) => $joinColumn['name'], $joinColumns);
2150 2022
2151 2023
            $columnNames = array_merge($columnNames, $assocColumnNames);
2152 2024
        }
@@ -2157,28 +2029,22 @@
Loading
2157 2029
    /**
2158 2030
     * Sets the type of Id generator to use for the mapped class.
2159 2031
     *
2160 -
     * @param int $generatorType
2161 2032
     * @psalm-param self::GENERATOR_TYPE_* $generatorType
2162 -
     *
2163 -
     * @return void
2164 2033
     */
2165 -
    public function setIdGeneratorType($generatorType)
2034 +
    public function setIdGeneratorType(int $generatorType): void
2166 2035
    {
2167 2036
        $this->generatorType = $generatorType;
2168 2037
    }
2169 2038
2170 2039
    /**
2171 2040
     * Checks whether the mapped class uses an Id generator.
2172 -
     *
2173 -
     * @return bool TRUE if the mapped class uses an Id generator, FALSE otherwise.
2174 2041
     */
2175 -
    public function usesIdGenerator()
2042 +
    public function usesIdGenerator(): bool
2176 2043
    {
2177 2044
        return $this->generatorType !== self::GENERATOR_TYPE_NONE;
2178 2045
    }
2179 2046
2180 -
    /** @return bool */
2181 -
    public function isInheritanceTypeNone()
2047 +
    public function isInheritanceTypeNone(): bool
2182 2048
    {
2183 2049
        return $this->inheritanceType === self::INHERITANCE_TYPE_NONE;
2184 2050
    }
@@ -2189,7 +2055,7 @@
Loading
2189 2055
     * @return bool TRUE if the class participates in a JOINED inheritance mapping,
2190 2056
     * FALSE otherwise.
2191 2057
     */
2192 -
    public function isInheritanceTypeJoined()
2058 +
    public function isInheritanceTypeJoined(): bool
2193 2059
    {
2194 2060
        return $this->inheritanceType === self::INHERITANCE_TYPE_JOINED;
2195 2061
    }
@@ -2200,7 +2066,7 @@
Loading
2200 2066
     * @return bool TRUE if the class participates in a SINGLE_TABLE inheritance mapping,
2201 2067
     * FALSE otherwise.
2202 2068
     */
2203 -
    public function isInheritanceTypeSingleTable()
2069 +
    public function isInheritanceTypeSingleTable(): bool
2204 2070
    {
2205 2071
        return $this->inheritanceType === self::INHERITANCE_TYPE_SINGLE_TABLE;
2206 2072
    }
@@ -2211,17 +2077,15 @@
Loading
2211 2077
     * @return bool TRUE if the class participates in a TABLE_PER_CLASS inheritance mapping,
2212 2078
     * FALSE otherwise.
2213 2079
     */
2214 -
    public function isInheritanceTypeTablePerClass()
2080 +
    public function isInheritanceTypeTablePerClass(): bool
2215 2081
    {
2216 2082
        return $this->inheritanceType === self::INHERITANCE_TYPE_TABLE_PER_CLASS;
2217 2083
    }
2218 2084
2219 2085
    /**
2220 2086
     * Checks whether the class uses an identity column for the Id generation.
2221 -
     *
2222 -
     * @return bool TRUE if the class uses the IDENTITY generator, FALSE otherwise.
2223 2087
     */
2224 -
    public function isIdGeneratorIdentity()
2088 +
    public function isIdGeneratorIdentity(): bool
2225 2089
    {
2226 2090
        return $this->generatorType === self::GENERATOR_TYPE_IDENTITY;
2227 2091
    }
@@ -2229,11 +2093,9 @@
Loading
2229 2093
    /**
2230 2094
     * Checks whether the class uses a sequence for id generation.
2231 2095
     *
2232 -
     * @return bool TRUE if the class uses the SEQUENCE generator, FALSE otherwise.
2233 -
     *
2234 2096
     * @psalm-assert-if-true !null $this->sequenceGeneratorDefinition
2235 2097
     */
2236 -
    public function isIdGeneratorSequence()
2098 +
    public function isIdGeneratorSequence(): bool
2237 2099
    {
2238 2100
        return $this->generatorType === self::GENERATOR_TYPE_SEQUENCE;
2239 2101
    }
@@ -2241,10 +2103,8 @@
Loading
2241 2103
    /**
2242 2104
     * Checks whether the class has a natural identifier/pk (which means it does
2243 2105
     * not use any Id generator.
2244 -
     *
2245 -
     * @return bool
2246 2106
     */
2247 -
    public function isIdentifierNatural()
2107 +
    public function isIdentifierNatural(): bool
2248 2108
    {
2249 2109
        return $this->generatorType === self::GENERATOR_TYPE_NONE;
2250 2110
    }
@@ -2263,30 +2123,24 @@
Loading
2263 2123
2264 2124
    /**
2265 2125
     * Gets the name of the primary table.
2266 -
     *
2267 -
     * @return string
2268 2126
     */
2269 -
    public function getTableName()
2127 +
    public function getTableName(): string
2270 2128
    {
2271 2129
        return $this->table['name'];
2272 2130
    }
2273 2131
2274 2132
    /**
2275 2133
     * Gets primary table's schema name.
2276 -
     *
2277 -
     * @return string|null
2278 2134
     */
2279 -
    public function getSchemaName()
2135 +
    public function getSchemaName(): string|null
2280 2136
    {
2281 2137
        return $this->table['schema'] ?? null;
2282 2138
    }
2283 2139
2284 2140
    /**
2285 2141
     * Gets the table name to use for temporary identifier tables of this class.
2286 -
     *
2287 -
     * @return string
2288 2142
     */
2289 -
    public function getTemporaryIdTableName()
2143 +
    public function getTemporaryIdTableName(): string
2290 2144
    {
2291 2145
        // replace dots with underscores because PostgreSQL creates temporary tables in a special schema
2292 2146
        return str_replace('.', '_', $this->getTableName() . '_id_tmp');
@@ -2296,10 +2150,8 @@
Loading
2296 2150
     * Sets the mapped subclasses of this class.
2297 2151
     *
2298 2152
     * @psalm-param list<string> $subclasses The names of all mapped subclasses.
2299 -
     *
2300 -
     * @return void
2301 2153
     */
2302 -
    public function setSubclasses(array $subclasses)
2154 +
    public function setSubclasses(array $subclasses): void
2303 2155
    {
2304 2156
        foreach ($subclasses as $subclass) {
2305 2157
            $this->subClasses[] = $this->fullyQualifiedClassName($subclass);
@@ -2312,10 +2164,8 @@
Loading
2312 2164
     * directParent -> directParentParent -> directParentParentParent ... -> root.
2313 2165
     *
2314 2166
     * @psalm-param list<class-string> $classNames
2315 -
     *
2316 -
     * @return void
2317 2167
     */
2318 -
    public function setParentClasses(array $classNames)
2168 +
    public function setParentClasses(array $classNames): void
2319 2169
    {
2320 2170
        $this->parentClasses = $classNames;
2321 2171
@@ -2327,14 +2177,11 @@
Loading
2327 2177
    /**
2328 2178
     * Sets the inheritance type used by the class and its subclasses.
2329 2179
     *
2330 -
     * @param int $type
2331 2180
     * @psalm-param self::INHERITANCE_TYPE_* $type
2332 2181
     *
2333 -
     * @return void
2334 -
     *
2335 2182
     * @throws MappingException
2336 2183
     */
2337 -
    public function setInheritanceType($type)
2184 +
    public function setInheritanceType(int $type): void
2338 2185
    {
2339 2186
        if (! $this->isInheritanceType($type)) {
2340 2187
            throw MappingException::invalidInheritanceType($this->name, $type);
@@ -2346,14 +2193,11 @@
Loading
2346 2193
    /**
2347 2194
     * Sets the association to override association mapping of property for an entity relationship.
2348 2195
     *
2349 -
     * @param string $fieldName
2350 2196
     * @psalm-param array<string, mixed> $overrideMapping
2351 2197
     *
2352 -
     * @return void
2353 -
     *
2354 2198
     * @throws MappingException
2355 2199
     */
2356 -
    public function setAssociationOverride($fieldName, array $overrideMapping)
2200 +
    public function setAssociationOverride(string $fieldName, array $overrideMapping): void
2357 2201
    {
2358 2202
        if (! isset($this->associationMappings[$fieldName])) {
2359 2203
            throw MappingException::invalidOverrideFieldName($this->name, $fieldName);
@@ -2411,14 +2255,11 @@
Loading
2411 2255
    /**
2412 2256
     * Sets the override for a mapped field.
2413 2257
     *
2414 -
     * @param string $fieldName
2415 2258
     * @psalm-param array<string, mixed> $overrideMapping
2416 2259
     *
2417 -
     * @return void
2418 -
     *
2419 2260
     * @throws MappingException
2420 2261
     */
2421 -
    public function setAttributeOverride($fieldName, array $overrideMapping)
2262 +
    public function setAttributeOverride(string $fieldName, array $overrideMapping): void
2422 2263
    {
2423 2264
        if (! isset($this->fieldMappings[$fieldName])) {
2424 2265
            throw MappingException::invalidOverrideFieldName($this->name, $fieldName);
@@ -2458,44 +2299,29 @@
Loading
2458 2299
2459 2300
    /**
2460 2301
     * Checks whether a mapped field is inherited from an entity superclass.
2461 -
     *
2462 -
     * @param string $fieldName
2463 -
     *
2464 -
     * @return bool TRUE if the field is inherited, FALSE otherwise.
2465 2302
     */
2466 -
    public function isInheritedField($fieldName)
2303 +
    public function isInheritedField(string $fieldName): bool
2467 2304
    {
2468 2305
        return isset($this->fieldMappings[$fieldName]['inherited']);
2469 2306
    }
2470 2307
2471 2308
    /**
2472 2309
     * Checks if this entity is the root in any entity-inheritance-hierarchy.
2473 -
     *
2474 -
     * @return bool
2475 2310
     */
2476 -
    public function isRootEntity()
2311 +
    public function isRootEntity(): bool
2477 2312
    {
2478 2313
        return $this->name === $this->rootEntityName;
2479 2314
    }
2480 2315
2481 2316
    /**
2482 2317
     * Checks whether a mapped association field is inherited from a superclass.
2483 -
     *
2484 -
     * @param string $fieldName
2485 -
     *
2486 -
     * @return bool TRUE if the field is inherited, FALSE otherwise.
2487 2318
     */
2488 -
    public function isInheritedAssociation($fieldName)
2319 +
    public function isInheritedAssociation(string $fieldName): bool
2489 2320
    {
2490 2321
        return isset($this->associationMappings[$fieldName]['inherited']);
2491 2322
    }
2492 2323
2493 -
    /**
2494 -
     * @param string $fieldName
2495 -
     *
2496 -
     * @return bool
2497 -
     */
2498 -
    public function isInheritedEmbeddedClass($fieldName)
2324 +
    public function isInheritedEmbeddedClass(string $fieldName): bool
2499 2325
    {
2500 2326
        return isset($this->embeddedClasses[$fieldName]['inherited']);
2501 2327
    }
@@ -2504,12 +2330,8 @@
Loading
2504 2330
     * Sets the name of the primary table the class is mapped to.
2505 2331
     *
2506 2332
     * @deprecated Use {@link setPrimaryTable}.
2507 -
     *
2508 -
     * @param string $tableName The table name.
2509 -
     *
2510 -
     * @return void
2511 2333
     */
2512 -
    public function setTableName($tableName)
2334 +
    public function setTableName(string $tableName): void
2513 2335
    {
2514 2336
        $this->table['name'] = $tableName;
2515 2337
    }
@@ -2525,10 +2347,8 @@
Loading
2525 2347
     * If a key is omitted, the current value is kept.
2526 2348
     *
2527 2349
     * @psalm-param array<string, mixed> $table The table description.
2528 -
     *
2529 -
     * @return void
2530 2350
     */
2531 -
    public function setPrimaryTable(array $table)
2351 +
    public function setPrimaryTable(array $table): void
2532 2352
    {
2533 2353
        if (isset($table['name'])) {
2534 2354
            // Split schema and table name from a table name like "myschema.mytable"
@@ -2567,8 +2387,6 @@
Loading
2567 2387
2568 2388
    /**
2569 2389
     * Checks whether the given type identifies an inheritance type.
2570 -
     *
2571 -
     * @return bool TRUE if the given type identifies an inheritance type, FALSE otherwise.
2572 2390
     */
2573 2391
    private function isInheritanceType(int $type): bool
2574 2392
    {
@@ -2583,11 +2401,9 @@
Loading
2583 2401
     *
2584 2402
     * @psalm-param array<string, mixed> $mapping The field mapping.
2585 2403
     *
2586 -
     * @return void
2587 -
     *
2588 2404
     * @throws MappingException
2589 2405
     */
2590 -
    public function mapField(array $mapping)
2406 +
    public function mapField(array $mapping): void
2591 2407
    {
2592 2408
        $mapping = $this->validateAndCompleteFieldMapping($mapping);
2593 2409
        $this->assertFieldNotMapped($mapping['fieldName']);
@@ -2606,11 +2422,9 @@
Loading
2606 2422
     *
2607 2423
     * @psalm-param AssociationMapping $mapping
2608 2424
     *
2609 -
     * @return void
2610 -
     *
2611 2425
     * @throws MappingException
2612 2426
     */
2613 -
    public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/)
2427 +
    public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/): void
2614 2428
    {
2615 2429
        if (isset($this->associationMappings[$mapping['fieldName']])) {
2616 2430
            throw MappingException::duplicateAssociationMapping($this->name, $mapping['fieldName']);
@@ -2625,10 +2439,8 @@
Loading
2625 2439
     * This is mainly used to add inherited field mappings to derived classes.
2626 2440
     *
2627 2441
     * @psalm-param array<string, mixed> $fieldMapping
2628 -
     *
2629 -
     * @return void
2630 2442
     */
2631 -
    public function addInheritedFieldMapping(array $fieldMapping)
2443 +
    public function addInheritedFieldMapping(array $fieldMapping): void
2632 2444
    {
2633 2445
        $this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping;
2634 2446
        $this->columnNames[$fieldMapping['fieldName']]   = $fieldMapping['columnName'];
@@ -2641,11 +2453,9 @@
Loading
2641 2453
     *
2642 2454
     * @psalm-param array<string, mixed> $resultMapping
2643 2455
     *
2644 -
     * @return void
2645 -
     *
2646 2456
     * @throws MappingException
2647 2457
     */
2648 -
    public function addSqlResultSetMapping(array $resultMapping)
2458 +
    public function addSqlResultSetMapping(array $resultMapping): void
2649 2459
    {
2650 2460
        if (! isset($resultMapping['name'])) {
2651 2461
            throw MappingException::nameIsMandatoryForSqlResultSetMapping($this->name);
@@ -2698,10 +2508,8 @@
Loading
2698 2508
     * Adds a one-to-one mapping.
2699 2509
     *
2700 2510
     * @param array<string, mixed> $mapping The mapping.
2701 -
     *
2702 -
     * @return void
2703 2511
     */
2704 -
    public function mapOneToOne(array $mapping)
2512 +
    public function mapOneToOne(array $mapping): void
2705 2513
    {
2706 2514
        $mapping['type'] = self::ONE_TO_ONE;
2707 2515
@@ -2714,10 +2522,8 @@
Loading
2714 2522
     * Adds a one-to-many mapping.
2715 2523
     *
2716 2524
     * @psalm-param array<string, mixed> $mapping The mapping.
2717 -
     *
2718 -
     * @return void
2719 2525
     */
2720 -
    public function mapOneToMany(array $mapping)
2526 +
    public function mapOneToMany(array $mapping): void
2721 2527
    {
2722 2528
        $mapping['type'] = self::ONE_TO_MANY;
2723 2529
@@ -2730,10 +2536,8 @@
Loading
2730 2536
     * Adds a many-to-one mapping.
2731 2537
     *
2732 2538
     * @psalm-param array<string, mixed> $mapping The mapping.
2733 -
     *
2734 -
     * @return void
2735 2539
     */
2736 -
    public function mapManyToOne(array $mapping)
2540 +
    public function mapManyToOne(array $mapping): void
2737 2541
    {
2738 2542
        $mapping['type'] = self::MANY_TO_ONE;
2739 2543
@@ -2747,10 +2551,8 @@
Loading
2747 2551
     * Adds a many-to-many mapping.
2748 2552
     *
2749 2553
     * @psalm-param array<string, mixed> $mapping The mapping.
2750 -
     *
2751 -
     * @return void
2752 2554
     */
2753 -
    public function mapManyToMany(array $mapping)
2555 +
    public function mapManyToMany(array $mapping): void
2754 2556
    {
2755 2557
        $mapping['type'] = self::MANY_TO_MANY;
2756 2558
@@ -2764,11 +2566,9 @@
Loading
2764 2566
     *
2765 2567
     * @psalm-param array<string, mixed> $assocMapping
2766 2568
     *
2767 -
     * @return void
2768 -
     *
2769 2569
     * @throws MappingException
2770 2570
     */
2771 -
    protected function _storeAssociationMapping(array $assocMapping)
2571 +
    protected function _storeAssociationMapping(array $assocMapping): void
2772 2572
    {
2773 2573
        $sourceFieldName = $assocMapping['fieldName'];
2774 2574
@@ -2782,10 +2582,8 @@
Loading
2782 2582
     *
2783 2583
     * @param string|null $repositoryClassName The class name of the custom mapper.
2784 2584
     * @psalm-param class-string<EntityRepository>|null $repositoryClassName
2785 -
     *
2786 -
     * @return void
2787 2585
     */
2788 -
    public function setCustomRepositoryClass($repositoryClassName)
2586 +
    public function setCustomRepositoryClass(string|null $repositoryClassName): void
2789 2587
    {
2790 2588
        $this->customRepositoryClassName = $this->fullyQualifiedClassName($repositoryClassName);
2791 2589
    }
@@ -2797,11 +2595,8 @@
Loading
2797 2595
     * @deprecated Deprecated since version 2.4 in favor of \Doctrine\ORM\Event\ListenersInvoker
2798 2596
     *
2799 2597
     * @param string $lifecycleEvent The lifecycle event.
2800 -
     * @param object $entity         The Entity on which the event occurred.
2801 -
     *
2802 -
     * @return void
2803 2598
     */
2804 -
    public function invokeLifecycleCallbacks($lifecycleEvent, $entity)
2599 +
    public function invokeLifecycleCallbacks(string $lifecycleEvent, object $entity): void
2805 2600
    {
2806 2601
        foreach ($this->lifecycleCallbacks[$lifecycleEvent] as $callback) {
2807 2602
            $entity->$callback();
@@ -2810,12 +2605,8 @@
Loading
2810 2605
2811 2606
    /**
2812 2607
     * Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event.
2813 -
     *
2814 -
     * @param string $lifecycleEvent
2815 -
     *
2816 -
     * @return bool
2817 2608
     */
2818 -
    public function hasLifecycleCallbacks($lifecycleEvent)
2609 +
    public function hasLifecycleCallbacks(string $lifecycleEvent): bool
2819 2610
    {
2820 2611
        return isset($this->lifecycleCallbacks[$lifecycleEvent]);
2821 2612
    }
@@ -2823,25 +2614,18 @@
Loading
2823 2614
    /**
2824 2615
     * Gets the registered lifecycle callbacks for an event.
2825 2616
     *
2826 -
     * @param string $event
2827 -
     *
2828 2617
     * @return string[]
2829 2618
     * @psalm-return list<string>
2830 2619
     */
2831 -
    public function getLifecycleCallbacks($event)
2620 +
    public function getLifecycleCallbacks(string $event): array
2832 2621
    {
2833 2622
        return $this->lifecycleCallbacks[$event] ?? [];
2834 2623
    }
2835 2624
2836 2625
    /**
2837 2626
     * Adds a lifecycle callback for entities of this class.
2838 -
     *
2839 -
     * @param string $callback
2840 -
     * @param string $event
2841 -
     *
2842 -
     * @return void
2843 2627
     */
2844 -
    public function addLifecycleCallback($callback, $event)
2628 +
    public function addLifecycleCallback(string $callback, string $event): void
2845 2629
    {
2846 2630
        if ($this->isEmbeddedClass) {
2847 2631
            Deprecation::trigger(
@@ -2865,10 +2649,8 @@
Loading
2865 2649
     * Any previously registered callbacks are overwritten.
2866 2650
     *
2867 2651
     * @psalm-param array<string, list<string>> $callbacks
2868 -
     *
2869 -
     * @return void
2870 2652
     */
2871 -
    public function setLifecycleCallbacks(array $callbacks)
2653 +
    public function setLifecycleCallbacks(array $callbacks): void
2872 2654
    {
2873 2655
        $this->lifecycleCallbacks = $callbacks;
2874 2656
    }
@@ -2880,11 +2662,9 @@
Loading
2880 2662
     * @param string $class     The listener class.
2881 2663
     * @param string $method    The listener callback method.
2882 2664
     *
2883 -
     * @return void
2884 -
     *
2885 2665
     * @throws MappingException
2886 2666
     */
2887 -
    public function addEntityListener($eventName, $class, $method)
2667 +
    public function addEntityListener(string $eventName, string $class, string $method): void
2888 2668
    {
2889 2669
        $class = $this->fullyQualifiedClassName($class);
2890 2670
@@ -2916,11 +2696,9 @@
Loading
2916 2696
     * @param mixed[]|null $columnDef
2917 2697
     * @psalm-param array{name: string|null, fieldName?: string, type?: string, length?: int, columnDefinition?: string|null}|null $columnDef
2918 2698
     *
2919 -
     * @return void
2920 -
     *
2921 2699
     * @throws MappingException
2922 2700
     */
2923 -
    public function setDiscriminatorColumn($columnDef)
2701 +
    public function setDiscriminatorColumn(array|null $columnDef): void
2924 2702
    {
2925 2703
        if ($columnDef !== null) {
2926 2704
            if (! isset($columnDef['name'])) {
@@ -2962,10 +2740,8 @@
Loading
2962 2740
     * Used for JOINED and SINGLE_TABLE inheritance mapping strategies.
2963 2741
     *
2964 2742
     * @param array<int|string, string> $map
2965 -
     *
2966 -
     * @return void
2967 2743
     */
2968 -
    public function setDiscriminatorMap(array $map)
2744 +
    public function setDiscriminatorMap(array $map): void
2969 2745
    {
2970 2746
        foreach ($map as $value => $className) {
2971 2747
            $this->addDiscriminatorMapClass($value, $className);
@@ -2975,14 +2751,9 @@
Loading
2975 2751
    /**
2976 2752
     * Adds one entry of the discriminator map with a new class and corresponding name.
2977 2753
     *
2978 -
     * @param int|string $name
2979 -
     * @param string     $className
2980 -
     *
2981 -
     * @return void
2982 -
     *
2983 2754
     * @throws MappingException
2984 2755
     */
2985 -
    public function addDiscriminatorMapClass($name, $className)
2756 +
    public function addDiscriminatorMapClass(int|string $name, string $className): void
2986 2757
    {
2987 2758
        $className = $this->fullyQualifiedClassName($className);
2988 2759
        $className = ltrim($className, '\\');
@@ -3023,12 +2794,8 @@
Loading
3023 2794
3024 2795
    /**
3025 2796
     * Is this an association that only has a single join column?
3026 -
     *
3027 -
     * @param string $fieldName
3028 -
     *
3029 -
     * @return bool
3030 2797
     */
3031 -
    public function isAssociationWithSingleJoinColumn($fieldName)
2798 +
    public function isAssociationWithSingleJoinColumn(string $fieldName): bool
3032 2799
    {
3033 2800
        return isset($this->associationMappings[$fieldName])
3034 2801
            && isset($this->associationMappings[$fieldName]['joinColumns'][0])
@@ -3038,13 +2805,9 @@
Loading
3038 2805
    /**
3039 2806
     * Returns the single association join column (if any).
3040 2807
     *
3041 -
     * @param string $fieldName
3042 -
     *
3043 -
     * @return string
3044 -
     *
3045 2808
     * @throws MappingException
3046 2809
     */
3047 -
    public function getSingleAssociationJoinColumnName($fieldName)
2810 +
    public function getSingleAssociationJoinColumnName(string $fieldName): string
3048 2811
    {
3049 2812
        if (! $this->isAssociationWithSingleJoinColumn($fieldName)) {
3050 2813
            throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName);
@@ -3056,13 +2819,9 @@
Loading
3056 2819
    /**
3057 2820
     * Returns the single association referenced join column name (if any).
3058 2821
     *
3059 -
     * @param string $fieldName
3060 -
     *
3061 -
     * @return string
3062 -
     *
3063 2822
     * @throws MappingException
3064 2823
     */
3065 -
    public function getSingleAssociationReferencedJoinColumnName($fieldName)
2824 +
    public function getSingleAssociationReferencedJoinColumnName(string $fieldName): string
3066 2825
    {
3067 2826
        if (! $this->isAssociationWithSingleJoinColumn($fieldName)) {
3068 2827
            throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName);
@@ -3076,13 +2835,9 @@
Loading
3076 2835
     *
3077 2836
     * This method is used in foreign-key as primary-key contexts.
3078 2837
     *
3079 -
     * @param string $columnName
3080 -
     *
3081 -
     * @return string
3082 -
     *
3083 2838
     * @throws MappingException
3084 2839
     */
3085 -
    public function getFieldForColumn($columnName)
2840 +
    public function getFieldForColumn(string $columnName): string
3086 2841
    {
3087 2842
        if (isset($this->fieldNames[$columnName])) {
3088 2843
            return $this->fieldNames[$columnName];
@@ -3102,12 +2857,8 @@
Loading
3102 2857
3103 2858
    /**
3104 2859
     * Sets the ID generator used to generate IDs for instances of this class.
3105 -
     *
3106 -
     * @param AbstractIdGenerator $generator
3107 -
     *
3108 -
     * @return void
3109 2860
     */
3110 -
    public function setIdGenerator($generator)
2861 +
    public function setIdGenerator(AbstractIdGenerator $generator): void
3111 2862
    {
3112 2863
        $this->idGenerator = $generator;
3113 2864
    }
@@ -3116,10 +2867,8 @@
Loading
3116 2867
     * Sets definition.
3117 2868
     *
3118 2869
     * @psalm-param array<string, string|null> $definition
3119 -
     *
3120 -
     * @return void
3121 2870
     */
3122 -
    public function setCustomGeneratorDefinition(array $definition)
2871 +
    public function setCustomGeneratorDefinition(array $definition): void
3123 2872
    {
3124 2873
        $this->customGeneratorDefinition = $definition;
3125 2874
    }
@@ -3139,11 +2888,9 @@
Loading
3139 2888
     *
3140 2889
     * @psalm-param array{sequenceName?: string, allocationSize?: int|string, initialValue?: int|string, quoted?: mixed} $definition
3141 2890
     *
3142 -
     * @return void
3143 -
     *
3144 2891
     * @throws MappingException
3145 2892
     */
3146 -
    public function setSequenceGeneratorDefinition(array $definition)
2893 +
    public function setSequenceGeneratorDefinition(array $definition): void
3147 2894
    {
3148 2895
        if (! isset($definition['sequenceName']) || trim($definition['sequenceName']) === '') {
3149 2896
            throw MappingException::missingSequenceName($this->name);
@@ -3174,11 +2921,9 @@
Loading
3174 2921
     *
3175 2922
     * @psalm-param array<string, mixed> $mapping The version field mapping array.
3176 2923
     *
3177 -
     * @return void
3178 -
     *
3179 2924
     * @throws MappingException
3180 2925
     */
3181 -
    public function setVersionMapping(array &$mapping)
2926 +
    public function setVersionMapping(array &$mapping): void
3182 2927
    {
3183 2928
        $this->isVersioned              = true;
3184 2929
        $this->versionField             = $mapping['fieldName'];
@@ -3197,12 +2942,8 @@
Loading
3197 2942
3198 2943
    /**
3199 2944
     * Sets whether this class is to be versioned for optimistic locking.
3200 -
     *
3201 -
     * @param bool $bool
3202 -
     *
3203 -
     * @return void
3204 2945
     */
3205 -
    public function setVersioned($bool)
2946 +
    public function setVersioned(bool $bool): void
3206 2947
    {
3207 2948
        $this->isVersioned = $bool;
3208 2949
@@ -3214,22 +2955,16 @@
Loading
3214 2955
    /**
3215 2956
     * Sets the name of the field that is to be used for versioning if this class is
3216 2957
     * versioned for optimistic locking.
3217 -
     *
3218 -
     * @param string|null $versionField
3219 -
     *
3220 -
     * @return void
3221 2958
     */
3222 -
    public function setVersionField($versionField)
2959 +
    public function setVersionField(string|null $versionField): void
3223 2960
    {
3224 2961
        $this->versionField = $versionField;
3225 2962
    }
3226 2963
3227 2964
    /**
3228 2965
     * Marks this class as read only, no change tracking is applied to it.
3229 -
     *
3230 -
     * @return void
3231 2966
     */
3232 -
    public function markReadOnly()
2967 +
    public function markReadOnly(): void
3233 2968
    {
3234 2969
        $this->isReadOnly = true;
3235 2970
    }
@@ -3280,12 +3015,10 @@
Loading
3280 3015
    }
3281 3016
3282 3017
    /**
3283 -
     * @param string|null $className
3284 -
     *
3285 3018
     * @return string|null null if the input value is null
3286 3019
     * @psalm-return class-string|null
3287 3020
     */
3288 -
    public function fullyQualifiedClassName($className)
3021 +
    public function fullyQualifiedClassName(string|null $className): string|null
3289 3022
    {
3290 3023
        if (empty($className)) {
3291 3024
            return $className;
@@ -3298,12 +3031,7 @@
Loading
3298 3031
        return $className;
3299 3032
    }
3300 3033
3301 -
    /**
3302 -
     * @param string $name
3303 -
     *
3304 -
     * @return mixed
3305 -
     */
3306 -
    public function getMetadataValue($name)
3034 +
    public function getMetadataValue(string $name): mixed
3307 3035
    {
3308 3036
        if (isset($this->$name)) {
3309 3037
            return $this->$name;
@@ -3317,11 +3045,9 @@
Loading
3317 3045
     *
3318 3046
     * @psalm-param array<string, mixed> $mapping
3319 3047
     *
3320 -
     * @return void
3321 -
     *
3322 3048
     * @throws MappingException
3323 3049
     */
3324 -
    public function mapEmbedded(array $mapping)
3050 +
    public function mapEmbedded(array $mapping): void
3325 3051
    {
3326 3052
        $this->assertFieldNotMapped($mapping['fieldName']);
3327 3053
@@ -3342,12 +3068,8 @@
Loading
3342 3068
3343 3069
    /**
3344 3070
     * Inline the embeddable class
3345 -
     *
3346 -
     * @param string $property
3347 -
     *
3348 -
     * @return void
3349 3071
     */
3350 -
    public function inlineEmbeddable($property, ClassMetadataInfo $embeddable)
3072 +
    public function inlineEmbeddable(string $property, ClassMetadataInfo $embeddable): void
3351 3073
    {
3352 3074
        foreach ($embeddable->fieldMappings as $fieldMapping) {
3353 3075
            $fieldMapping['originalClass'] ??= $embeddable->name;
@@ -3390,11 +3112,9 @@
Loading
3390 3112
    /**
3391 3113
     * Gets the sequence name based on class metadata.
3392 3114
     *
3393 -
     * @return string
3394 -
     *
3395 3115
     * @todo Sequence names should be computed in DBAL depending on the platform
3396 3116
     */
3397 -
    public function getSequenceName(AbstractPlatform $platform)
3117 +
    public function getSequenceName(AbstractPlatform $platform): string
3398 3118
    {
3399 3119
        $sequencePrefix = $this->getSequencePrefix($platform);
3400 3120
        $columnName     = $this->getSingleIdentifierColumnName();
@@ -3405,11 +3125,9 @@
Loading
3405 3125
    /**
3406 3126
     * Gets the sequence name prefix based on class metadata.
3407 3127
     *
3408 -
     * @return string
3409 -
     *
3410 3128
     * @todo Sequence names should be computed in DBAL depending on the platform
3411 3129
     */
3412 -
    public function getSequencePrefix(AbstractPlatform $platform)
3130 +
    public function getSequencePrefix(AbstractPlatform $platform): string
3413 3131
    {
3414 3132
        $tableName      = $this->getTableName();
3415 3133
        $sequencePrefix = $tableName;
Files Coverage
lib/Doctrine/ORM 89.69%
Project Totals (332 files) 89.69%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading