From 98d77043d81e79502e1dd99bd4da16bf34aaecbf Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 29 Dec 2021 16:03:10 +0100 Subject: [PATCH] Fix type errors in AnnotationDriver (#9274) --- .../ORM/Cache/DefaultCacheFactory.php | 2 + .../ORM/Mapping/AssociationOverrides.php | 4 +- .../ORM/Mapping/AttributeOverrides.php | 4 +- .../ORM/Mapping/ClassMetadataFactory.php | 15 +- .../ORM/Mapping/ClassMetadataInfo.php | 21 +- lib/Doctrine/ORM/Mapping/DiscriminatorMap.php | 10 +- .../ORM/Mapping/Driver/AnnotationDriver.php | 155 +++--- lib/Doctrine/ORM/Mapping/Entity.php | 9 +- lib/Doctrine/ORM/Mapping/MappedSuperclass.php | 9 +- lib/Doctrine/ORM/Mapping/MappingException.php | 2 +- lib/Doctrine/ORM/Mapping/Table.php | 8 +- lib/Doctrine/ORM/Mapping/UniqueConstraint.php | 8 +- phpstan-baseline.neon | 450 +----------------- psalm-baseline.xml | 246 ++-------- .../Tests/ORM/Tools/EntityGeneratorTest.php | 75 ++- 15 files changed, 231 insertions(+), 787 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index 9511cc8f007..7b2a1bf79ea 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -25,6 +25,7 @@ use InvalidArgumentException; use LogicException; +use function assert; use function sprintf; use const DIRECTORY_SEPARATOR; @@ -91,6 +92,7 @@ public function setTimestampRegion(TimestampRegion $region) */ public function buildCachedEntityPersister(EntityManagerInterface $em, EntityPersister $persister, ClassMetadata $metadata) { + assert($metadata->cache !== null); $region = $this->getRegion($metadata->cache); $usage = $metadata->cache['usage']; diff --git a/lib/Doctrine/ORM/Mapping/AssociationOverrides.php b/lib/Doctrine/ORM/Mapping/AssociationOverrides.php index 9105a375990..211009d27c9 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationOverrides.php +++ b/lib/Doctrine/ORM/Mapping/AssociationOverrides.php @@ -21,12 +21,12 @@ final class AssociationOverrides implements Annotation /** * Mapping overrides of relationship properties. * - * @var array<\Doctrine\ORM\Mapping\AssociationOverride> + * @var array */ public $overrides = []; /** - * @param array|AssociationOverride $overrides + * @param array|AssociationOverride $overrides */ public function __construct($overrides) { diff --git a/lib/Doctrine/ORM/Mapping/AttributeOverrides.php b/lib/Doctrine/ORM/Mapping/AttributeOverrides.php index 272cc459e8d..2fec6fb0ca4 100644 --- a/lib/Doctrine/ORM/Mapping/AttributeOverrides.php +++ b/lib/Doctrine/ORM/Mapping/AttributeOverrides.php @@ -21,12 +21,12 @@ final class AttributeOverrides implements Annotation /** * One or more field or property mapping overrides. * - * @var array<\Doctrine\ORM\Mapping\AttributeOverride> + * @var array */ public $overrides = []; /** - * @param array|AttributeOverride $overrides + * @param array|AttributeOverride $overrides */ public function __construct($overrides) { diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 15c3b0c58c6..c4cb36431f2 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -45,9 +45,7 @@ * metadata mapping information of a class which describes how a class should be mapped * to a relational database. * - * @method ClassMetadata[] getAllMetadata() - * @method ClassMetadata[] getLoadedMetadata() - * @method ClassMetadata getMetadataFor($className) + * @extends AbstractClassMetadataFactory */ class ClassMetadataFactory extends AbstractClassMetadataFactory { @@ -90,14 +88,16 @@ protected function initialize() protected function onNotFoundMetadata($className) { if (! $this->evm->hasListeners(Events::onClassMetadataNotFound)) { - return; + return null; } $eventArgs = new OnClassMetadataNotFoundEventArgs($className, $this->em); $this->evm->dispatchEvent(Events::onClassMetadataNotFound, $eventArgs); + $classMetadata = $eventArgs->getFoundMetadata(); + assert($classMetadata instanceof ClassMetadata); - return $eventArgs->getFoundMetadata(); + return $classMetadata; } /** @@ -642,6 +642,9 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class): void } } + /** + * @psalm-return ClassMetadata::GENERATOR_TYPE_SEQUENCE|ClassMetadata::GENERATOR_TYPE_IDENTITY + */ private function determineIdGeneratorStrategy(AbstractPlatform $platform): int { if ( @@ -736,7 +739,7 @@ protected function getDriver() */ protected function isEntity(ClassMetadataInterface $class) { - return isset($class->isMappedSuperclass) && $class->isMappedSuperclass === false; + return ! $class->isMappedSuperclass; } private function getTargetPlatform(): Platforms\AbstractPlatform diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 18e777d09f0..3dc6555e556 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -15,6 +15,7 @@ use Doctrine\Instantiator\Instantiator; use Doctrine\Instantiator\InstantiatorInterface; use Doctrine\ORM\Cache\Exception\NonCacheableEntityAssociation; +use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Id\AbstractIdGenerator; use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\Persistence\Mapping\ReflectionService; @@ -300,7 +301,7 @@ class ClassMetadataInfo implements ClassMetadata * (Optional). * * @var string|null - * @psalm-var ?class-string + * @psalm-var ?class-string */ public $customRepositoryClassName; @@ -395,7 +396,7 @@ class ClassMetadataInfo implements ClassMetadata * READ-ONLY: The inheritance mapping type used by the class. * * @var int - * @psalm-var self::$INHERITANCE_TYPE_* + * @psalm-var self::INHERITANCE_TYPE_* */ public $inheritanceType = self::INHERITANCE_TYPE_NONE; @@ -403,6 +404,7 @@ class ClassMetadataInfo implements ClassMetadata * READ-ONLY: The Id generator type used by the class. * * @var int + * @psalm-var self::GENERATOR_TYPE_* */ public $generatorType = self::GENERATOR_TYPE_NONE; @@ -668,8 +670,8 @@ class ClassMetadataInfo implements ClassMetadata */ public $versionField; - /** @var mixed[] */ - public $cache = null; + /** @var mixed[]|null */ + public $cache; /** * The ReflectionClass instance of the mapped class. @@ -2150,6 +2152,7 @@ public function getIdentifierColumnNames() * Sets the type of Id generator to use for the mapped class. * * @param int $generatorType + * @psalm-param self::GENERATOR_TYPE_* $generatorType * * @return void */ @@ -2376,6 +2379,7 @@ public function setParentClasses(array $classNames) * Sets the inheritance type used by the class and its subclasses. * * @param int $type + * @psalm-param self::INHERITANCE_TYPE_* $type * * @return void * @@ -2921,8 +2925,8 @@ protected function _storeAssociationMapping(array $assocMapping) /** * Registers a custom repository class for the entity class. * - * @param string $repositoryClassName The class name of the custom mapper. - * @psalm-param class-string $repositoryClassName + * @param string|null $repositoryClassName The class name of the custom mapper. + * @psalm-param class-string|null $repositoryClassName * * @return void */ @@ -3589,9 +3593,10 @@ public function getAssociationsByTargetClass($targetClass) /** * @param string|null $className - * @psalm-param ?class-string $className + * @psalm-param string|class-string|null $className * * @return string|null null if the input value is null + * @psalm-return class-string|null */ public function fullyQualifiedClassName($className) { @@ -3599,7 +3604,7 @@ public function fullyQualifiedClassName($className) return $className; } - if ($className !== null && strpos($className, '\\') === false && $this->namespace) { + if (strpos($className, '\\') === false && $this->namespace) { return $this->namespace . '\\' . $className; } diff --git a/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php b/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php index 8a4bf6ed5ee..5e822daa613 100644 --- a/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php +++ b/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php @@ -15,10 +15,16 @@ #[Attribute(Attribute::TARGET_CLASS)] final class DiscriminatorMap implements Annotation { - /** @var array */ + /** + * @var array + * @psalm-var array + */ public $value; - /** @param array $value */ + /** + * @param array $value + * @psalm-param array $value + */ public function __construct(array $value) { $this->value = $value; diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index 832f3901382..ab426d2ef18 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Events; use Doctrine\ORM\Mapping; use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder; +use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\MappingException; use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\Persistence\Mapping\Driver\AnnotationDriver as AbstractAnnotationDriver; @@ -16,6 +17,7 @@ use ReflectionProperty; use UnexpectedValueException; +use function assert; use function class_exists; use function constant; use function count; @@ -43,29 +45,25 @@ class AnnotationDriver extends AbstractAnnotationDriver */ public function loadMetadataForClass($className, ClassMetadata $metadata) { - $class = $metadata->getReflectionClass(); - - if (! $class) { + assert($metadata instanceof Mapping\ClassMetadata); + $class = $metadata->getReflectionClass() // this happens when running annotation driver in combination with // static reflection services. This is not the nicest fix - $class = new ReflectionClass($metadata->name); - } + ?? new ReflectionClass($metadata->name); $classAnnotations = $this->reader->getClassAnnotations($class); - - if ($classAnnotations) { - foreach ($classAnnotations as $key => $annot) { - if (! is_numeric($key)) { - continue; - } - - $classAnnotations[get_class($annot)] = $annot; + foreach ($classAnnotations as $key => $annot) { + if (! is_numeric($key)) { + continue; } + + $classAnnotations[get_class($annot)] = $annot; } // Evaluate Entity annotation if (isset($classAnnotations[Mapping\Entity::class])) { $entityAnnot = $classAnnotations[Mapping\Entity::class]; + assert($entityAnnot instanceof Mapping\Entity); if ($entityAnnot->repositoryClass !== null) { $metadata->setCustomRepositoryClass($entityAnnot->repositoryClass); } @@ -75,6 +73,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) } } elseif (isset($classAnnotations[Mapping\MappedSuperclass::class])) { $mappedSuperclassAnnot = $classAnnotations[Mapping\MappedSuperclass::class]; + assert($mappedSuperclassAnnot instanceof Mapping\MappedSuperclass); $metadata->setCustomRepositoryClass($mappedSuperclassAnnot->repositoryClass); $metadata->isMappedSuperclass = true; @@ -86,87 +85,84 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) // Evaluate Table annotation if (isset($classAnnotations[Mapping\Table::class])) { - $tableAnnot = $classAnnotations[Mapping\Table::class]; + $tableAnnot = $classAnnotations[Mapping\Table::class]; + assert($tableAnnot instanceof Mapping\Table); $primaryTable = [ 'name' => $tableAnnot->name, 'schema' => $tableAnnot->schema, ]; - if ($tableAnnot->indexes !== null) { - foreach ($tableAnnot->indexes as $indexAnnot) { - $index = []; + foreach ($tableAnnot->indexes ?? [] as $indexAnnot) { + $index = []; - if (! empty($indexAnnot->columns)) { - $index['columns'] = $indexAnnot->columns; - } + if (! empty($indexAnnot->columns)) { + $index['columns'] = $indexAnnot->columns; + } - if (! empty($indexAnnot->fields)) { - $index['fields'] = $indexAnnot->fields; - } + if (! empty($indexAnnot->fields)) { + $index['fields'] = $indexAnnot->fields; + } - if ( - isset($index['columns'], $index['fields']) - || ( - ! isset($index['columns']) - && ! isset($index['fields']) - ) - ) { - throw MappingException::invalidIndexConfiguration( - $className, - (string) ($indexAnnot->name ?? count($primaryTable['indexes'])) - ); - } + if ( + isset($index['columns'], $index['fields']) + || ( + ! isset($index['columns']) + && ! isset($index['fields']) + ) + ) { + throw MappingException::invalidIndexConfiguration( + $className, + (string) ($indexAnnot->name ?? count($primaryTable['indexes'])) + ); + } - if (! empty($indexAnnot->flags)) { - $index['flags'] = $indexAnnot->flags; - } + if (! empty($indexAnnot->flags)) { + $index['flags'] = $indexAnnot->flags; + } - if (! empty($indexAnnot->options)) { - $index['options'] = $indexAnnot->options; - } + if (! empty($indexAnnot->options)) { + $index['options'] = $indexAnnot->options; + } - if (! empty($indexAnnot->name)) { - $primaryTable['indexes'][$indexAnnot->name] = $index; - } else { - $primaryTable['indexes'][] = $index; - } + if (! empty($indexAnnot->name)) { + $primaryTable['indexes'][$indexAnnot->name] = $index; + } else { + $primaryTable['indexes'][] = $index; } } - if ($tableAnnot->uniqueConstraints !== null) { - foreach ($tableAnnot->uniqueConstraints as $uniqueConstraintAnnot) { - $uniqueConstraint = []; + foreach ($tableAnnot->uniqueConstraints ?? [] as $uniqueConstraintAnnot) { + $uniqueConstraint = []; - if (! empty($uniqueConstraintAnnot->columns)) { - $uniqueConstraint['columns'] = $uniqueConstraintAnnot->columns; - } + if (! empty($uniqueConstraintAnnot->columns)) { + $uniqueConstraint['columns'] = $uniqueConstraintAnnot->columns; + } - if (! empty($uniqueConstraintAnnot->fields)) { - $uniqueConstraint['fields'] = $uniqueConstraintAnnot->fields; - } + if (! empty($uniqueConstraintAnnot->fields)) { + $uniqueConstraint['fields'] = $uniqueConstraintAnnot->fields; + } - if ( - isset($uniqueConstraint['columns'], $uniqueConstraint['fields']) - || ( - ! isset($uniqueConstraint['columns']) - && ! isset($uniqueConstraint['fields']) - ) - ) { - throw MappingException::invalidUniqueConstraintConfiguration( - $className, - (string) ($uniqueConstraintAnnot->name ?? count($primaryTable['uniqueConstraints'])) - ); - } + if ( + isset($uniqueConstraint['columns'], $uniqueConstraint['fields']) + || ( + ! isset($uniqueConstraint['columns']) + && ! isset($uniqueConstraint['fields']) + ) + ) { + throw MappingException::invalidUniqueConstraintConfiguration( + $className, + (string) ($uniqueConstraintAnnot->name ?? count($primaryTable['uniqueConstraints'])) + ); + } - if (! empty($uniqueConstraintAnnot->options)) { - $uniqueConstraint['options'] = $uniqueConstraintAnnot->options; - } + if (! empty($uniqueConstraintAnnot->options)) { + $uniqueConstraint['options'] = $uniqueConstraintAnnot->options; + } - if (! empty($uniqueConstraintAnnot->name)) { - $primaryTable['uniqueConstraints'][$uniqueConstraintAnnot->name] = $uniqueConstraint; - } else { - $primaryTable['uniqueConstraints'][] = $uniqueConstraint; - } + if (! empty($uniqueConstraintAnnot->name)) { + $primaryTable['uniqueConstraints'][$uniqueConstraintAnnot->name] = $uniqueConstraint; + } else { + $primaryTable['uniqueConstraints'][] = $uniqueConstraint; } } @@ -269,15 +265,17 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) // Evaluate InheritanceType annotation if (isset($classAnnotations[Mapping\InheritanceType::class])) { $inheritanceTypeAnnot = $classAnnotations[Mapping\InheritanceType::class]; + assert($inheritanceTypeAnnot instanceof Mapping\InheritanceType); $metadata->setInheritanceType( constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value) ); - if ($metadata->inheritanceType !== Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) { + if ($metadata->inheritanceType !== ClassMetadataInfo::INHERITANCE_TYPE_NONE) { // Evaluate DiscriminatorColumn annotation if (isset($classAnnotations[Mapping\DiscriminatorColumn::class])) { $discrColumnAnnot = $classAnnotations[Mapping\DiscriminatorColumn::class]; + assert($discrColumnAnnot instanceof Mapping\DiscriminatorColumn); $metadata->setDiscriminatorColumn( [ @@ -294,6 +292,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) // Evaluate DiscriminatorMap annotation if (isset($classAnnotations[Mapping\DiscriminatorMap::class])) { $discrMapAnnot = $classAnnotations[Mapping\DiscriminatorMap::class]; + assert($discrMapAnnot instanceof Mapping\DiscriminatorMap); $metadata->setDiscriminatorMap($discrMapAnnot->value); } } @@ -302,6 +301,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) // Evaluate DoctrineChangeTrackingPolicy annotation if (isset($classAnnotations[Mapping\ChangeTrackingPolicy::class])) { $changeTrackingAnnot = $classAnnotations[Mapping\ChangeTrackingPolicy::class]; + assert($changeTrackingAnnot instanceof Mapping\ChangeTrackingPolicy); $metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' . $changeTrackingAnnot->value)); } @@ -405,6 +405,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) // Evaluate AssociationOverrides annotation if (isset($classAnnotations[Mapping\AssociationOverrides::class])) { $associationOverridesAnnot = $classAnnotations[Mapping\AssociationOverrides::class]; + assert($associationOverridesAnnot instanceof Mapping\AssociationOverrides); foreach ($associationOverridesAnnot->overrides as $associationOverride) { $override = []; @@ -457,6 +458,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) // Evaluate AttributeOverrides annotation if (isset($classAnnotations[Mapping\AttributeOverrides::class])) { $attributeOverridesAnnot = $classAnnotations[Mapping\AttributeOverrides::class]; + assert($attributeOverridesAnnot instanceof Mapping\AttributeOverrides); foreach ($attributeOverridesAnnot->overrides as $attributeOverrideAnnot) { $attributeOverride = $this->columnToArray($attributeOverrideAnnot->name, $attributeOverrideAnnot->column); @@ -468,6 +470,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) // Evaluate EntityListeners annotation if (isset($classAnnotations[Mapping\EntityListeners::class])) { $entityListenersAnnot = $classAnnotations[Mapping\EntityListeners::class]; + assert($entityListenersAnnot instanceof Mapping\EntityListeners); foreach ($entityListenersAnnot->value as $item) { $listenerClassName = $metadata->fullyQualifiedClassName($item); diff --git a/lib/Doctrine/ORM/Mapping/Entity.php b/lib/Doctrine/ORM/Mapping/Entity.php index 839b494aabb..9a77efdc3b4 100644 --- a/lib/Doctrine/ORM/Mapping/Entity.php +++ b/lib/Doctrine/ORM/Mapping/Entity.php @@ -6,6 +6,7 @@ use Attribute; use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; +use Doctrine\ORM\EntityRepository; /** * @Annotation @@ -15,12 +16,18 @@ #[Attribute(Attribute::TARGET_CLASS)] final class Entity implements Annotation { - /** @var string|null */ + /** + * @var string|null + * @psalm-var class-string|null + */ public $repositoryClass; /** @var bool */ public $readOnly = false; + /** + * @psalm-param class-string|null $repositoryClass + */ public function __construct(?string $repositoryClass = null, bool $readOnly = false) { $this->repositoryClass = $repositoryClass; diff --git a/lib/Doctrine/ORM/Mapping/MappedSuperclass.php b/lib/Doctrine/ORM/Mapping/MappedSuperclass.php index 0346268692c..d4e53fa77bd 100644 --- a/lib/Doctrine/ORM/Mapping/MappedSuperclass.php +++ b/lib/Doctrine/ORM/Mapping/MappedSuperclass.php @@ -6,6 +6,7 @@ use Attribute; use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; +use Doctrine\ORM\EntityRepository; /** * @Annotation @@ -15,9 +16,15 @@ #[Attribute(Attribute::TARGET_CLASS)] final class MappedSuperclass implements Annotation { - /** @var string|null */ + /** + * @var string|null + * @psalm-var class-string|null + */ public $repositoryClass; + /** + * @psalm-param class-string|null $repositoryClass + */ public function __construct(?string $repositoryClass = null) { $this->repositoryClass = $repositoryClass; diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 1338f39d6ae..6c2182d2503 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -53,7 +53,7 @@ public static function identifierRequired($entityName) /** * @param string $entityName - * @param string $type + * @param int $type * * @return MappingException */ diff --git a/lib/Doctrine/ORM/Mapping/Table.php b/lib/Doctrine/ORM/Mapping/Table.php index aabdf50fe3f..7dd6cb273cf 100644 --- a/lib/Doctrine/ORM/Mapping/Table.php +++ b/lib/Doctrine/ORM/Mapping/Table.php @@ -15,16 +15,16 @@ #[Attribute(Attribute::TARGET_CLASS)] final class Table implements Annotation { - /** @var string */ + /** @var string|null */ public $name; - /** @var string */ + /** @var string|null */ public $schema; - /** @var array<\Doctrine\ORM\Mapping\Index> */ + /** @var array<\Doctrine\ORM\Mapping\Index>|null */ public $indexes; - /** @var array<\Doctrine\ORM\Mapping\UniqueConstraint> */ + /** @var array<\Doctrine\ORM\Mapping\UniqueConstraint>|null */ public $uniqueConstraints; /** @var array */ diff --git a/lib/Doctrine/ORM/Mapping/UniqueConstraint.php b/lib/Doctrine/ORM/Mapping/UniqueConstraint.php index 1981fd66ac5..37d515d8215 100644 --- a/lib/Doctrine/ORM/Mapping/UniqueConstraint.php +++ b/lib/Doctrine/ORM/Mapping/UniqueConstraint.php @@ -15,16 +15,16 @@ #[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)] final class UniqueConstraint implements Annotation { - /** @var string */ + /** @var string|null */ public $name; - /** @var array */ + /** @var array|null */ public $columns; - /** @var array */ + /** @var array|null */ public $fields; - /** @var array */ + /** @var array|null */ public $options; /** diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a0b848e0c9d..33d984500b0 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -245,184 +245,9 @@ parameters: count: 1 path: lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$cache\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$changeTrackingPolicy\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$containsForeignIdentifier\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$customRepositoryClassName\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$discriminatorColumn\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$discriminatorMap\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$embeddedClasses\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$entityListeners\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$generatorType\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$identifier\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$inheritanceType\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$isMappedSuperclass\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$isVersioned\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$lifecycleCallbacks\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$name\\.$#" - count: 4 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$table\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$versionField\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:inlineEmbeddable\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:isInheritanceTypeNone\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:isInheritanceTypeSingleTable\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:isRootEntity\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setChangeTrackingPolicy\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setCustomGeneratorDefinition\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setCustomRepositoryClass\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setDiscriminatorColumn\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setDiscriminatorMap\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setIdGeneratorType\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setIdentifier\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setInheritanceType\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setLifecycleCallbacks\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setParentClasses\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setPrimaryTable\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setVersionField\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:setVersioned\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - message: "#^If condition is always true\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:onNotFoundMetadata\\(\\) should return Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\|null but empty return statement found\\.$#" - count: 1 + count: 2 path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - @@ -435,111 +260,11 @@ parameters: count: 1 path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - message: "#^Parameter \\#1 \\$class of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addDefaultDiscriminatorMap\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#1 \\$class of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:completeIdGeneratorMapping\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#1 \\$class of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:inheritIdGeneratorMapping\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#1 \\$class of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:validateRuntimeMetadata\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#1 \\$subClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedEmbeddedClasses\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#1 \\$subClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedFields\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#1 \\$subClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedIndexes\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#1 \\$subClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedNamedNativeQueries\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#1 \\$subClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedNamedQueries\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#1 \\$subClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedRelations\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#1 \\$subClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedSqlResultSetMappings\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - message: "#^Parameter \\#2 \\$class of method Doctrine\\\\ORM\\\\Mapping\\\\QuoteStrategy\\:\\:getSequenceName\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo given\\.$#" count: 2 path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - message: "#^Parameter \\#2 \\$parent of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:inheritIdGeneratorMapping\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#2 \\$parentClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedEmbeddedClasses\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#2 \\$parentClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedFields\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#2 \\$parentClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedIndexes\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#2 \\$parentClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedNamedNativeQueries\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#2 \\$parentClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedNamedQueries\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#2 \\$parentClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedRelations\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#2 \\$parentClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addInheritedSqlResultSetMappings\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - - message: "#^Parameter \\#2 \\$parentClass of method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\:\\:addNestedEmbeddedClasses\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - message: "#^Call to an undefined method ReflectionProperty\\:\\:getType\\(\\)\\.$#" count: 3 @@ -565,36 +290,11 @@ parameters: count: 1 path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php - - - message: "#^Parameter \\#2 \\$type of static method Doctrine\\\\ORM\\\\Mapping\\\\MappingException\\:\\:invalidInheritanceType\\(\\) expects string, int given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php - - message: "#^Array \\(array\\\\) does not accept key string\\.$#" count: 1 path: lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:\\$inheritanceType\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:\\$isEmbeddedClass\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:\\$isMappedSuperclass\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:\\$name\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:mapEmbedded\\(\\)\\.$#" count: 1 @@ -621,137 +321,7 @@ parameters: path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addEntityListener\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addLifecycleCallback\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addNamedNativeQuery\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addNamedQuery\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addSqlResultSetMapping\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:enableCache\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:fullyQualifiedClassName\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:getAssociationCacheDefaults\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:isInheritedAssociation\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:isInheritedEmbeddedClass\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:isInheritedField\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:mapField\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:markReadOnly\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setAssociationOverride\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setAttributeOverride\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setChangeTrackingPolicy\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setCustomGeneratorDefinition\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setCustomRepositoryClass\\(\\)\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setDiscriminatorColumn\\(\\)\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setDiscriminatorMap\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setIdGeneratorType\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setInheritanceType\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setPrimaryTable\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setSequenceGeneratorDefinition\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setVersionMapping\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Negated boolean expression is always false\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Parameter \\#1 \\$metadata of static method Doctrine\\\\ORM\\\\Mapping\\\\Builder\\\\EntityListenerBuilder\\:\\:bindEntityListener\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\ given\\.$#" + message: "#^Expression on left side of \\?\\? is not nullable\\.$#" count: 1 path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -2163,13 +1733,13 @@ parameters: - message: "#^If condition is always true\\.$#" - count: 1 + count: 2 path: lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php - - message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|3\\|4\\|5\\|6\\|7, int given\\.$#" + message: "#^Left side of && is always true\\.$#" count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php + path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - message: "#^Offset 'indexes' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#" @@ -2206,11 +1776,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - - message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|3\\|4\\|5\\|6\\|7, int given\\.$#" - count: 2 - path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - message: "#^Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo\\\\:\\:\\$lifecycleCallbacks \\(array\\\\>\\) in isset\\(\\) is not nullable\\.$#" count: 1 @@ -2221,11 +1786,6 @@ parameters: count: 2 path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - - message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|3\\|4\\|5\\|6\\|7, int given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php - - message: "#^Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo\\\\:\\:\\$lifecycleCallbacks \\(array\\\\>\\) in isset\\(\\) is not nullable\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e214b4b3b9a..6af8e189614 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -91,6 +91,9 @@ + + $em->getMetadataFactory() + $fieldMapping['columnName'] @@ -412,6 +415,9 @@ is_object($entity) is_object($entity) + + ClassMetadataFactory + $entity $entity @@ -638,9 +644,6 @@ array_keys($discrMap) - - $this->class->inheritanceType - $class @@ -671,9 +674,6 @@ - - $className - $class @@ -701,30 +701,10 @@ - - $class - $class - $class - $class - $class - $class - $class - $class - $class - $class - $class - $class - $class + $class $class - $parent - $parent - $parent - $parent - $parent - $parent - $parent - $parent + $nonSuperclassParents new $definition['class']() @@ -748,39 +728,6 @@ $driver $evm - - $class->cache - $class->changeTrackingPolicy - $class->containsForeignIdentifier - $class->discriminatorMap - $class->embeddedClasses - $class->entityListeners - $class->entityListeners - $class->isMappedSuperclass - $class->isMappedSuperclass - $class->name - $class->name - $class->name - $parent->cache - $parent->changeTrackingPolicy - $parent->containsForeignIdentifier - $parent->customGeneratorDefinition - $parent->customRepositoryClassName - $parent->discriminatorColumn - $parent->discriminatorMap - $parent->entityListeners - $parent->generatorType - $parent->identifier - $parent->inheritanceType - $parent->isMappedSuperclass - $parent->isVersioned - $parent->lifecycleCallbacks - $parent->namedNativeQueries - $parent->namedQueries - $parent->sqlResultSetMappings - $parent->table - $parent->versionField - $subClass->table[$indexType][$indexName] @@ -805,31 +752,8 @@ $subClass->table - - inlineEmbeddable - isInheritanceTypeNone - isInheritanceTypeSingleTable - isRootEntity - setChangeTrackingPolicy - setCustomGeneratorDefinition - setCustomRepositoryClass - setDiscriminatorColumn - setDiscriminatorMap - setIdGeneratorType - setIdentifier - setInheritanceType - setLifecycleCallbacks - setParentClasses - setPrimaryTable - setVersionField - setVersioned - - - $class - $subclass - self::GENERATOR_TYPE_UUID @@ -846,25 +770,25 @@ ! $this->table $this->table - + protected function _validateAndCompleteAssociationMapping(array $mapping) protected function _validateAndCompleteManyToManyMapping(array $mapping) protected function _validateAndCompleteOneToOneMapping(array $mapping) - public $inheritanceType = self::INHERITANCE_TYPE_NONE; ReflectionProperty ReflectionProperty getReflectionClass - + $definition + $this->subClasses - - $type - - + $cache + $className + $className + $this->namespace . '\\' . $className $joinColumn @@ -873,16 +797,14 @@ static function ($joinColumn) { - - $inheritanceType - _validateAndCompleteAssociationMapping _validateAndCompleteManyToManyMapping _validateAndCompleteOneToOneMapping - + array{usage: int, region: string|null} + class-string|null $this->reflClass @@ -905,9 +827,6 @@ $queryMapping['resultClass'] $reflService->getAccessibleProperty($mapping['originalClass'], $mapping['originalField']) - - null - $embeddable->reflClass->name $this->reflClass->name @@ -944,12 +863,11 @@ $table $tableGeneratorDefinition - + $this->entityListeners $this->fieldMappings $this->fullyQualifiedClassName($repositoryClassName) $this->sqlResultSetMappings - $this->subClasses $this->table $this->table $this->table @@ -960,8 +878,7 @@ array_values - - $className !== null + $mapping !== false $mapping !== false @@ -1019,64 +936,36 @@ - - $metadata - - - ! $class - $class + + addNamedNativeQuery + addNamedQuery + + + new ReflectionClass($metadata->name) $mapping - - $metadata->inheritanceType - $metadata->isEmbeddedClass - $metadata->isMappedSuperclass - $metadata->isMappedSuperclass - $metadata->name - $entityAnnotationClasses + + $listenerClassName + $primaryTable['indexes'] $primaryTable['uniqueConstraints'] - - addEntityListener - addLifecycleCallback - addNamedNativeQuery - addNamedQuery - addSqlResultSetMapping - enableCache - fullyQualifiedClassName - getAssociationCacheDefaults - isInheritedAssociation - isInheritedEmbeddedClass - isInheritedField + + $metadata->getReflectionClass() + + mapEmbedded - mapField mapManyToMany mapManyToOne mapOneToMany mapOneToOne - markReadOnly - setAssociationOverride - setAttributeOverride - setChangeTrackingPolicy - setCustomGeneratorDefinition - setCustomRepositoryClass - setCustomRepositoryClass - setDiscriminatorColumn - setDiscriminatorColumn - setDiscriminatorMap - setIdGeneratorType - setInheritanceType - setPrimaryTable - setSequenceGeneratorDefinition - setVersionMapping @@ -1452,14 +1341,6 @@ $name - - - $indexes - $name - $schema - $uniqueConstraints - - $className @@ -1468,14 +1349,6 @@ strrpos($className, '\\') - - - $columns - $fields - $name - $options - - mixed @@ -1705,7 +1578,8 @@ $value === null - + + $em->getMetadataFactory() $hints @@ -1722,9 +1596,6 @@ [$params, $types] [$sqlParams, $sqlTypes] - - $eagerEntity->inheritanceType - loadAll @@ -1808,8 +1679,10 @@ $classMetadata $classMetadata - + $classMetadata->getReflectionProperties() + $em->getMetadataFactory() + $em->getMetadataFactory() $metadata->isEmbeddedClass @@ -2793,9 +2666,6 @@ $resultAlias $resultAlias - - $targetEntity->inheritanceType - $aggExpression->pathExpression $whereClause->conditionalExpression @@ -3290,9 +3160,6 @@ $metadata->entityListeners - - $metadata->inheritanceType - getAllClassNames @@ -3371,11 +3238,6 @@ $visibility - - $metadata->inheritanceType - $metadata->inheritanceType - $metadata->inheritanceType - setFieldVisibility @@ -3457,29 +3319,25 @@ - + $metadata->changeTrackingPolicy - $metadata->generatorType AbstractExporter - - $metadata->inheritanceType - $_extension - + + $metadata->inheritanceType + $metadata->inheritanceType $metadata->table $metadata->table - + $metadata->changeTrackingPolicy - $metadata->generatorType - $metadata->generatorType AbstractExporter @@ -3488,9 +3346,6 @@ $m1 $m2 - - $metadata->inheritanceType - $_extension @@ -3504,16 +3359,17 @@ $field['associationKey'] isset($field['associationKey']) && $field['associationKey'] - + + $metadata->inheritanceType + $metadata->inheritanceType $sequenceDefinition isset($metadata->lifecycleCallbacks) - + $array $metadata->changeTrackingPolicy - $metadata->generatorType AbstractExporter @@ -3524,9 +3380,6 @@ $array - - $metadata->inheritanceType - array<string, mixed>&array{entityListeners: array<class-string, array<string, array{string}>>} @@ -3668,6 +3521,9 @@ $association['type'] === ClassMetadata::ONE_TO_MANY is_object($object) + + $em->getMetadataFactory() + object @@ -3753,9 +3609,7 @@ unwrap unwrap - - $class->cache !== null - $this->hasCache && $class->cache !== null + is_array($entity) diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php index 7f9ca70f7ec..bd47fcbb183 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php @@ -7,8 +7,8 @@ use DateTime; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; -use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\Tools\EntityGenerator; use Doctrine\Persistence\Mapping\RuntimeReflectionService; @@ -84,11 +84,11 @@ public function tearDown(): void } /** - * @param ClassMetadataInfo[] $embeddedClasses + * @param ClassMetadata[] $embeddedClasses */ - public function generateBookEntityFixture(array $embeddedClasses = []): ClassMetadataInfo + public function generateBookEntityFixture(array $embeddedClasses = []): ClassMetadata { - $metadata = new ClassMetadataInfo($this->namespace . '\EntityGeneratorBook'); + $metadata = new ClassMetadata($this->namespace . '\EntityGeneratorBook'); $metadata->namespace = $this->namespace; $metadata->customRepositoryClassName = $this->namespace . '\EntityGeneratorBookRepository'; @@ -101,14 +101,11 @@ public function generateBookEntityFixture(array $embeddedClasses = []): ClassMet $metadata->mapOneToOne( ['fieldName' => 'author', 'targetEntity' => EntityGeneratorAuthor::class, 'mappedBy' => 'book'] ); - $joinColumns = [ - ['name' => 'author_id', 'referencedColumnName' => 'id'], - ]; $metadata->mapManyToMany( [ 'fieldName' => 'comments', 'targetEntity' => EntityGeneratorComment::class, - 'fetch' => ClassMetadataInfo::FETCH_EXTRA_LAZY, + 'fetch' => ClassMetadata::FETCH_EXTRA_LAZY, 'joinTable' => [ 'name' => 'book_comment', 'joinColumns' => [['name' => 'book_id', 'referencedColumnName' => 'id']], @@ -118,7 +115,7 @@ public function generateBookEntityFixture(array $embeddedClasses = []): ClassMet ); $metadata->addLifecycleCallback('loading', 'postLoad'); $metadata->addLifecycleCallback('willBeRemoved', 'preRemove'); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); + $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); foreach ($embeddedClasses as $fieldName => $embeddedClass) { $this->mapNestedEmbedded($fieldName, $metadata, $embeddedClass); @@ -130,14 +127,14 @@ public function generateBookEntityFixture(array $embeddedClasses = []): ClassMet return $metadata; } - private function generateEntityTypeFixture(array $field): ClassMetadataInfo + private function generateEntityTypeFixture(array $field): ClassMetadata { - $metadata = new ClassMetadataInfo($this->namespace . '\EntityType'); + $metadata = new ClassMetadata($this->namespace . '\EntityType'); $metadata->namespace = $this->namespace; $metadata->table['name'] = 'entity_type'; $metadata->mapField(['fieldName' => 'id', 'type' => 'integer', 'id' => true]); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); + $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); $name = $field['fieldName']; $type = $field['dbType']; @@ -148,9 +145,9 @@ private function generateEntityTypeFixture(array $field): ClassMetadataInfo return $metadata; } - private function generateIsbnEmbeddableFixture(array $embeddedClasses = [], $columnPrefix = null): ClassMetadataInfo + private function generateIsbnEmbeddableFixture(array $embeddedClasses = [], $columnPrefix = null): ClassMetadata { - $metadata = new ClassMetadataInfo($this->namespace . '\EntityGeneratorIsbn'); + $metadata = new ClassMetadata($this->namespace . '\EntityGeneratorIsbn'); $metadata->namespace = $this->namespace; $metadata->isEmbeddedClass = true; $metadata->mapField(['fieldName' => 'prefix', 'type' => 'integer']); @@ -168,9 +165,9 @@ private function generateIsbnEmbeddableFixture(array $embeddedClasses = [], $col return $metadata; } - private function generateTestEmbeddableFixture(): ClassMetadataInfo + private function generateTestEmbeddableFixture(): ClassMetadata { - $metadata = new ClassMetadataInfo($this->namespace . '\EntityGeneratorTestEmbeddable'); + $metadata = new ClassMetadata($this->namespace . '\EntityGeneratorTestEmbeddable'); $metadata->namespace = $this->namespace; $metadata->isEmbeddedClass = true; $metadata->mapField(['fieldName' => 'field1', 'type' => 'integer']); @@ -188,8 +185,8 @@ private function generateTestEmbeddableFixture(): ClassMetadataInfo */ private function mapEmbedded( string $fieldName, - ClassMetadataInfo $classMetadata, - ClassMetadataInfo $embeddableMetadata, + ClassMetadata $classMetadata, + ClassMetadata $embeddableMetadata, $columnPrefix = false ): void { $classMetadata->mapEmbedded( @@ -199,8 +196,8 @@ private function mapEmbedded( private function mapNestedEmbedded( string $fieldName, - ClassMetadataInfo $classMetadata, - ClassMetadataInfo $embeddableMetadata + ClassMetadata $classMetadata, + ClassMetadata $embeddableMetadata ): void { foreach ($embeddableMetadata->embeddedClasses as $property => $embeddableClass) { $classMetadata->mapEmbedded( @@ -217,7 +214,7 @@ private function mapNestedEmbedded( } } - private function loadEntityClass(ClassMetadataInfo $metadata): void + private function loadEntityClass(ClassMetadata $metadata): void { $className = basename(str_replace('\\', '/', $metadata->name)); $path = $this->tmpDir . '/' . $this->namespace . '/' . $className . '.php'; @@ -230,7 +227,7 @@ private function loadEntityClass(ClassMetadataInfo $metadata): void /** * @return mixed An instance of the given metadata's class. */ - public function newInstance(ClassMetadataInfo $metadata) + public function newInstance(ClassMetadata $metadata) { $this->loadEntityClass($metadata); @@ -481,7 +478,7 @@ public function testLoadMetadata(): void $reflectionService = new RuntimeReflectionService(); - $cm = new ClassMetadataInfo($metadata->name); + $cm = new ClassMetadata($metadata->name); $cm->initializeReflection($reflectionService); $driver = $this->createAnnotationDriver(); @@ -496,11 +493,11 @@ public function testLoadMetadata(): void self::assertEquals($cm->embeddedClasses, $metadata->embeddedClasses); self::assertEquals($cm->isEmbeddedClass, $metadata->isEmbeddedClass); - self::assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $cm->associationMappings['comments']['fetch']); + self::assertEquals(ClassMetadata::FETCH_EXTRA_LAZY, $cm->associationMappings['comments']['fetch']); - $isbn = $this->newInstance($embeddedMetadata); + $this->newInstance($embeddedMetadata); - $cm = new ClassMetadataInfo($embeddedMetadata->name); + $cm = new ClassMetadata($embeddedMetadata->name); $cm->initializeReflection($reflectionService); $driver->loadMetadataForClass($cm->name, $cm); @@ -523,7 +520,7 @@ public function testLoadPrefixedMetadata(): void $reflectionService = new RuntimeReflectionService(); - $cm = new ClassMetadataInfo($metadata->name); + $cm = new ClassMetadata($metadata->name); $cm->initializeReflection($reflectionService); $driver->loadMetadataForClass($cm->name, $cm); @@ -535,9 +532,9 @@ public function testLoadPrefixedMetadata(): void self::assertEquals($cm->idGenerator, $metadata->idGenerator); self::assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); - $isbn = $this->newInstance($embeddedMetadata); + $this->newInstance($embeddedMetadata); - $cm = new ClassMetadataInfo($embeddedMetadata->name); + $cm = new ClassMetadata($embeddedMetadata->name); $cm->initializeReflection($reflectionService); $driver->loadMetadataForClass($cm->name, $cm); @@ -552,7 +549,7 @@ public function testLoadPrefixedMetadata(): void */ public function testMappedSuperclassAnnotationGeneration(): void { - $metadata = new ClassMetadataInfo($this->namespace . '\EntityGeneratorBook'); + $metadata = new ClassMetadata($this->namespace . '\EntityGeneratorBook'); $metadata->namespace = $this->namespace; $metadata->isMappedSuperclass = true; @@ -561,7 +558,7 @@ public function testMappedSuperclassAnnotationGeneration(): void $this->newInstance($metadata); // force instantiation (causes autoloading to kick in) $driver = new AnnotationDriver(new AnnotationReader(), []); - $cm = new ClassMetadataInfo($metadata->name); + $cm = new ClassMetadata($metadata->name); $cm->initializeReflection(new RuntimeReflectionService()); $driver->loadMetadataForClass($cm->name, $cm); @@ -590,10 +587,10 @@ public function testParseTokensInEntityFile($php, $classes): void */ public function testGenerateEntityWithSequenceGenerator(): void { - $metadata = new ClassMetadataInfo($this->namespace . '\DDC1784Entity'); + $metadata = new ClassMetadata($this->namespace . '\DDC1784Entity'); $metadata->namespace = $this->namespace; $metadata->mapField(['fieldName' => 'id', 'type' => 'integer', 'id' => true]); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); + $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_SEQUENCE); $metadata->setSequenceGeneratorDefinition( [ 'sequenceName' => 'DDC1784_ID_SEQ', @@ -626,10 +623,10 @@ public function testGenerateEntityWithSequenceGenerator(): void */ public function testGenerateEntityWithMultipleInverseJoinColumns(): void { - $metadata = new ClassMetadataInfo($this->namespace . '\DDC2079Entity'); + $metadata = new ClassMetadata($this->namespace . '\DDC2079Entity'); $metadata->namespace = $this->namespace; $metadata->mapField(['fieldName' => 'id', 'type' => 'integer', 'id' => true]); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); + $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_SEQUENCE); $metadata->mapManyToMany( [ 'fieldName' => 'centroCustos', @@ -683,7 +680,7 @@ public function testGenerateEntityWithMultipleInverseJoinColumns(): void */ public function testGetInheritanceTypeString(): void { - $reflection = new ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadataInfo'); + $reflection = new ReflectionClass(ClassMetadata::class); $method = new ReflectionMethod($this->generator, 'getInheritanceTypeString'); $constants = $reflection->getConstants(); $pattern = '/^INHERITANCE_TYPE_/'; @@ -741,7 +738,7 @@ public function testGetChangeTrackingPolicyString(): void */ public function testGetIdGeneratorTypeString(): void { - $reflection = new ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadataInfo'); + $reflection = new ReflectionClass(ClassMetadata::class); $method = new ReflectionMethod($this->generator, 'getIdGeneratorTypeString'); $constants = $reflection->getConstants(); $pattern = '/^GENERATOR_TYPE_/'; @@ -1231,11 +1228,11 @@ private function assertPhpDocParamType(string $type, ReflectionMethod $method): */ public function testOptionsAreGeneratedProperly(string $expectedAnnotation, array $fieldConfiguration): void { - $metadata = new ClassMetadataInfo($this->namespace . '\GH6703Options'); + $metadata = new ClassMetadata($this->namespace . '\GH6703Options'); $metadata->namespace = $this->namespace; $metadata->mapField(['fieldName' => 'id', 'type' => 'integer', 'id' => true]); $metadata->mapField(['fieldName' => 'test'] + $fieldConfiguration); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); + $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_SEQUENCE); $this->generator->writeEntityClass($metadata, $this->tmpDir); $filename = $this->tmpDir . DIRECTORY_SEPARATOR . $this->namespace . DIRECTORY_SEPARATOR . 'GH6703Options.php';