diff --git a/src/Internal/Hydration/ObjectHydrator.php b/src/Internal/Hydration/ObjectHydrator.php index fe780e8b89..ff415af2ac 100644 --- a/src/Internal/Hydration/ObjectHydrator.php +++ b/src/Internal/Hydration/ObjectHydrator.php @@ -171,7 +171,7 @@ private function initRelatedCollection( ): PersistentCollection { $oid = spl_object_id($entity); $relation = $class->associationMappings[$fieldName]; - $value = $class->reflFields[$fieldName]->getValue($entity); + $value = $class->propertyAccessors[$fieldName]->getValue($entity); if ($value === null || is_array($value)) { $value = new ArrayCollection((array) $value); @@ -186,7 +186,7 @@ private function initRelatedCollection( ); $value->setOwner($entity, $relation); - $class->reflFields[$fieldName]->setValue($entity, $value); + $class->propertyAccessors[$fieldName]->setValue($entity, $value); $this->uow->setOriginalEntityProperty($oid, $fieldName, $value); $this->initializedCollections[$oid . $fieldName] = $value; @@ -346,7 +346,7 @@ protected function hydrateRowData(array $row, array &$result): void $parentClass = $this->metadataCache[$this->resultSetMapping()->aliasMap[$parentAlias]]; $relationField = $this->resultSetMapping()->relationMap[$dqlAlias]; $relation = $parentClass->associationMappings[$relationField]; - $reflField = $parentClass->reflFields[$relationField]; + $reflField = $parentClass->propertyAccessors[$relationField]; // Get a reference to the parent object to which the joined element belongs. if ($this->resultSetMapping()->isMixed && isset($this->rootAliases[$parentAlias])) { @@ -446,13 +446,13 @@ protected function hydrateRowData(array $row, array &$result): void if ($relation->inversedBy !== null) { $inverseAssoc = $targetClass->associationMappings[$relation->inversedBy]; if ($inverseAssoc->isToOne()) { - $targetClass->reflFields[$inverseAssoc->fieldName]->setValue($element, $parentObject); + $targetClass->propertyAccessors[$inverseAssoc->fieldName]->setValue($element, $parentObject); $this->uow->setOriginalEntityProperty(spl_object_id($element), $inverseAssoc->fieldName, $parentObject); } } } else { // For sure bidirectional, as there is no inverse side in unidirectional mappings - $targetClass->reflFields[$relation->mappedBy]->setValue($element, $parentObject); + $targetClass->propertyAccessors[$relation->mappedBy]->setValue($element, $parentObject); $this->uow->setOriginalEntityProperty(spl_object_id($element), $relation->mappedBy, $parentObject); } diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index 1d4fbd7ec0..84ed408871 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -569,19 +569,19 @@ public function __construct(public string $name, NamingStrategy|null $namingStra * Gets the ReflectionProperties of the mapped class. * * @return ReflectionProperty[]|null[] An array of ReflectionProperty instances. - * @psalm-return array|LegacyReflectionFields + * @psalm-return array */ - public function getReflectionProperties(): array|LegacyReflectionFields + public function getPropertyAccessors(): array { - return $this->reflFields; + return $this->propertyAccessors; } /** * Gets a ReflectionProperty for a specific field of the mapped class. */ - public function getReflectionProperty(string $name): ReflectionProperty|null + public function getPropertyAccessor(string $name): PropertyAccessor|null { - return $this->reflFields[$name]; + return $this->propertyAccessors[$name]; } /** @@ -595,7 +595,7 @@ public function getSingleIdReflectionProperty(): ReflectionProperty|null throw new BadMethodCallException('Class ' . $this->name . ' has a composite identifier.'); } - return $this->reflFields[$this->identifier[0]]; + return $this->propertyAccessors[$this->identifier[0]]; } /** @@ -612,7 +612,7 @@ public function getIdentifierValues(object $entity): array $id = []; foreach ($this->identifier as $idField) { - $value = $this->reflFields[$idField]->getValue($entity); + $value = $this->propertyAccessors[$idField]->getValue($entity); if ($value !== null) { $id[$idField] = $value; @@ -623,7 +623,7 @@ public function getIdentifierValues(object $entity): array } $id = $this->identifier[0]; - $value = $this->reflFields[$id]->getValue($entity); + $value = $this->propertyAccessors[$id]->getValue($entity); if ($value === null) { return []; @@ -642,7 +642,7 @@ public function getIdentifierValues(object $entity): array public function setIdentifierValues(object $entity, array $id): void { foreach ($id as $idField => $idValue) { - $this->reflFields[$idField]->setValue($entity, $idValue); + $this->propertyAccessors[$idField]->setValue($entity, $idValue); } } @@ -651,7 +651,7 @@ public function setIdentifierValues(object $entity, array $id): void */ public function setFieldValue(object $entity, string $field, mixed $value): void { - $this->reflFields[$field]->setValue($entity, $value); + $this->propertyAccessors[$field]->setValue($entity, $value); } /** @@ -659,7 +659,7 @@ public function setFieldValue(object $entity, string $field, mixed $value): void */ public function getFieldValue(object $entity, string $field): mixed { - return $this->reflFields[$field]->getValue($entity); + return $this->propertyAccessors[$field]->getValue($entity); } /** diff --git a/src/Mapping/ClassMetadataFactory.php b/src/Mapping/ClassMetadataFactory.php index db0a8cf550..d733276486 100644 --- a/src/Mapping/ClassMetadataFactory.php +++ b/src/Mapping/ClassMetadataFactory.php @@ -440,8 +440,8 @@ private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $pare $subClass->addInheritedFieldMapping($subClassMapping); } - foreach ($parentClass->reflFields as $name => $field) { - $subClass->reflFields[$name] = $field; + foreach ($parentClass->propertyAccessors as $name => $field) { + $subClass->propertyAccessors[$name] = $field; } } diff --git a/src/Mapping/PropertyAccessors/EnumPropertyAccessor.php b/src/Mapping/PropertyAccessors/EnumPropertyAccessor.php index 04286062ac..9682b6069f 100644 --- a/src/Mapping/PropertyAccessors/EnumPropertyAccessor.php +++ b/src/Mapping/PropertyAccessors/EnumPropertyAccessor.php @@ -2,7 +2,7 @@ namespace Doctrine\ORM\Mapping\PropertyAccessors; -use ReflectionProperty; +use BackedEnum; class EnumPropertyAccessor implements PropertyAccessor { diff --git a/src/PersistentCollection.php b/src/PersistentCollection.php index d54d3d1b99..291e57a193 100644 --- a/src/PersistentCollection.php +++ b/src/PersistentCollection.php @@ -140,7 +140,7 @@ public function hydrateAdd(mixed $element): void if ($this->backRefFieldName && $this->getMapping()->isOneToMany()) { assert($this->typeClass !== null); // Set back reference to owner - $this->typeClass->reflFields[$this->backRefFieldName]->setValue( + $this->typeClass->propertyAccessors[$this->backRefFieldName]->setValue( $element, $this->owner, ); @@ -166,7 +166,7 @@ public function hydrateSet(mixed $key, mixed $element): void if ($this->backRefFieldName && $this->getMapping()->isOneToMany()) { assert($this->typeClass !== null); // Set back reference to owner - $this->typeClass->reflFields[$this->backRefFieldName]->setValue( + $this->typeClass->propertyAccessors[$this->backRefFieldName]->setValue( $element, $this->owner, ); diff --git a/src/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php index 1bb54ed441..6e47339191 100644 --- a/src/Persisters/Entity/BasicEntityPersister.php +++ b/src/Persisters/Entity/BasicEntityPersister.php @@ -468,7 +468,7 @@ final protected function updateTable( $where[] = $versionColumn; $types[] = $this->class->fieldMappings[$versionField]->type; - $params[] = $this->class->reflFields[$versionField]->getValue($entity); + $params[] = $this->class->propertyAccessors[$versionField]->getValue($entity); switch ($versionFieldType) { case Types::SMALLINT: @@ -779,7 +779,7 @@ public function loadOneToOneEntity(AssociationMapping $assoc, object $sourceEnti // Complete bidirectional association, if necessary if ($targetEntity !== null && $isInverseSingleValued) { - $targetClass->reflFields[$assoc->inversedBy]->setValue($targetEntity, $sourceEntity); + $targetClass->propertyAccessors[$assoc->inversedBy]->setValue($targetEntity, $sourceEntity); } return $targetEntity; @@ -826,7 +826,7 @@ public function loadOneToOneEntity(AssociationMapping $assoc, object $sourceEnti } } else { $computedIdentifier[$targetClass->getFieldForColumn($targetKeyColumn)] = - $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); + $sourceClass->propertyAccessors[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); } } @@ -1043,7 +1043,7 @@ private function getManyToManyStatement( switch (true) { case $sourceClass->containsForeignIdentifier: $field = $sourceClass->getFieldForColumn($sourceKeyColumn); - $value = $sourceClass->reflFields[$field]->getValue($sourceEntity); + $value = $sourceClass->propertyAccessors[$field]->getValue($sourceEntity); if (isset($sourceClass->associationMappings[$field])) { $value = $this->em->getUnitOfWork()->getEntityIdentifier($value); @@ -1054,7 +1054,7 @@ private function getManyToManyStatement( case isset($sourceClass->fieldNames[$sourceKeyColumn]): $field = $sourceClass->fieldNames[$sourceKeyColumn]; - $value = $sourceClass->reflFields[$field]->getValue($sourceEntity); + $value = $sourceClass->propertyAccessors[$field]->getValue($sourceEntity); break; @@ -1451,7 +1451,7 @@ protected function getInsertColumnList(): array { $columns = []; - foreach ($this->class->reflFields as $name => $field) { + foreach ($this->class->propertyAccessors as $name => $field) { if ($this->class->isVersioned && $this->class->versionField === $name) { continue; } @@ -1797,7 +1797,7 @@ private function getOneToManyStatement( foreach ($owningAssoc->targetToSourceKeyColumns as $sourceKeyColumn => $targetKeyColumn) { if ($sourceClass->containsForeignIdentifier) { $field = $sourceClass->getFieldForColumn($sourceKeyColumn); - $value = $sourceClass->reflFields[$field]->getValue($sourceEntity); + $value = $sourceClass->propertyAccessors[$field]->getValue($sourceEntity); if (isset($sourceClass->associationMappings[$field])) { $value = $this->em->getUnitOfWork()->getEntityIdentifier($value); @@ -1815,7 +1815,7 @@ private function getOneToManyStatement( } $field = $sourceClass->fieldNames[$sourceKeyColumn]; - $value = $sourceClass->reflFields[$field]->getValue($sourceEntity); + $value = $sourceClass->propertyAccessors[$field]->getValue($sourceEntity); $criteria[$tableAlias . '.' . $targetKeyColumn] = $value; $parameters[] = [ diff --git a/src/Persisters/Entity/JoinedSubclassPersister.php b/src/Persisters/Entity/JoinedSubclassPersister.php index 76719a2c27..f00e7db9a5 100644 --- a/src/Persisters/Entity/JoinedSubclassPersister.php +++ b/src/Persisters/Entity/JoinedSubclassPersister.php @@ -459,7 +459,7 @@ protected function getInsertColumnList(): array ? $this->class->getIdentifierColumnNames() : []; - foreach ($this->class->reflFields as $name => $field) { + foreach ($this->class->propertyAccessors as $name => $field) { if ( isset($this->class->fieldMappings[$name]->inherited) && ! isset($this->class->fieldMappings[$name]->id) diff --git a/src/Proxy/ProxyFactory.php b/src/Proxy/ProxyFactory.php index 40fe481497..e460217667 100644 --- a/src/Proxy/ProxyFactory.php +++ b/src/Proxy/ProxyFactory.php @@ -232,8 +232,8 @@ private function createLazyInitializer(ClassMetadata $classMetadata, EntityPersi $class = $entityPersister->getClassMetadata(); - foreach ($class->getReflectionProperties() as $property) { - if (! $property || isset($identifier[$property->getName()]) || ! $class->hasField($property->getName()) && ! $class->hasAssociation($property->getName())) { + foreach ($class->getPropertyAccessors() as $name => $property) { + if (! $property || isset($identifier[$name]) || ! $class->hasField($name) && ! $class->hasAssociation($name)) { continue; } @@ -282,7 +282,7 @@ private function getProxyFactory(string $className): Closure $identifierFields = []; foreach ($identifiers as $identifier => $_) { - $identifierFields[$identifier] = $class->getReflectionProperty($identifier); + $identifierFields[$identifier] = $class->getPropertyAccessor($identifier); } $proxyFactory = Closure::bind(static function (array $identifier) use ($initializer, $skippedProperties, $identifierFields, $className): InternalProxy { diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index e26602ef92..e8d92669b3 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -584,7 +584,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void $actualData = []; - foreach ($class->reflFields as $name => $refProp) { + foreach ($class->propertyAccessors as $name => $refProp) { $value = $refProp->getValue($entity); if ($class->isCollectionValuedAssociation($name) && $value !== null) { @@ -704,7 +704,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void $newValue = clone $actualValue; $newValue->setOwner($entity, $assoc); - $class->reflFields[$propName]->setValue($entity, $newValue); + $class->propertyAccessors[$propName]->setValue($entity, $newValue); } } @@ -743,7 +743,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void // Look for changes in associations of the entity foreach ($class->associationMappings as $field => $assoc) { - $val = $class->reflFields[$field]->getValue($entity); + $val = $class->propertyAccessors[$field]->getValue($entity); if ($val === null) { continue; } @@ -979,7 +979,7 @@ public function recomputeSingleEntityChangeSet(ClassMetadata $class, object $ent $actualData = []; - foreach ($class->reflFields as $name => $refProp) { + foreach ($class->propertyAccessors as $name => $refProp) { if ( ( ! $class->isIdentifier($name) || ! $class->isIdGeneratorIdentity()) && ($name !== $class->versionField) @@ -1165,7 +1165,7 @@ private function executeDeletions(): void // is obtained by a new entity because the old one went out of scope. //$this->entityStates[$oid] = self::STATE_NEW; if (! $class->isIdentifierNatural()) { - $class->reflFields[$class->identifier[0]]->setValue($entity, null); + $class->propertyAccessors[$class->identifier[0]]->setValue($entity, null); } if ($invoke !== ListenersInvoker::INVOKE_NONE) { @@ -2027,7 +2027,7 @@ private function cascadeRefresh(object $entity, array &$visited, LockMode|int|nu ); foreach ($associationMappings as $assoc) { - $relatedEntities = $class->reflFields[$assoc->fieldName]->getValue($entity); + $relatedEntities = $class->propertyAccessors[$assoc->fieldName]->getValue($entity); switch (true) { case $relatedEntities instanceof PersistentCollection: @@ -2068,7 +2068,7 @@ private function cascadeDetach(object $entity, array &$visited): void ); foreach ($associationMappings as $assoc) { - $relatedEntities = $class->reflFields[$assoc->fieldName]->getValue($entity); + $relatedEntities = $class->propertyAccessors[$assoc->fieldName]->getValue($entity); switch (true) { case $relatedEntities instanceof PersistentCollection: @@ -2114,7 +2114,7 @@ private function cascadePersist(object $entity, array &$visited): void ); foreach ($associationMappings as $assoc) { - $relatedEntities = $class->reflFields[$assoc->fieldName]->getValue($entity); + $relatedEntities = $class->propertyAccessors[$assoc->fieldName]->getValue($entity); switch (true) { case $relatedEntities instanceof PersistentCollection: @@ -2177,7 +2177,7 @@ private function cascadeRemove(object $entity, array &$visited): void $entitiesToCascade = []; foreach ($associationMappings as $assoc) { - $relatedEntities = $class->reflFields[$assoc->fieldName]->getValue($entity); + $relatedEntities = $class->propertyAccessors[$assoc->fieldName]->getValue($entity); switch (true) { case $relatedEntities instanceof Collection: @@ -2233,7 +2233,7 @@ public function lock(object $entity, LockMode|int $lockMode, DateTimeInterface|i $this->initializeObject($entity); assert($class->versionField !== null); - $entityVersion = $class->reflFields[$class->versionField]->getValue($entity); + $entityVersion = $class->propertyAccessors[$class->versionField]->getValue($entity); // phpcs:ignore SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedNotEqualOperator if ($entityVersion != $lockVersion) { @@ -2404,7 +2404,7 @@ public function createEntity(string $className, array $data, array &$hints = []) foreach ($data as $field => $value) { if (isset($class->fieldMappings[$field])) { - $class->reflFields[$field]->setValue($entity, $value); + $class->propertyAccessors[$field]->setValue($entity, $value); } } @@ -2434,21 +2434,21 @@ public function createEntity(string $className, array $data, array &$hints = []) if (isset($data[$field]) && is_object($data[$field]) && isset($this->entityStates[spl_object_id($data[$field])])) { $this->originalEntityData[$oid][$field] = $data[$field]; - $class->reflFields[$field]->setValue($entity, $data[$field]); - $targetClass->reflFields[$assoc->mappedBy]->setValue($data[$field], $entity); + $class->propertyAccessors[$field]->setValue($entity, $data[$field]); + $targetClass->propertyAccessors[$assoc->mappedBy]->setValue($data[$field], $entity); continue 2; } // Inverse side of x-to-one can never be lazy - $class->reflFields[$field]->setValue($entity, $this->getEntityPersister($assoc->targetEntity)->loadOneToOneEntity($assoc, $entity)); + $class->propertyAccessors[$field]->setValue($entity, $this->getEntityPersister($assoc->targetEntity)->loadOneToOneEntity($assoc, $entity)); continue 2; } // use the entity association if (isset($data[$field]) && is_object($data[$field]) && isset($this->entityStates[spl_object_id($data[$field])])) { - $class->reflFields[$field]->setValue($entity, $data[$field]); + $class->propertyAccessors[$field]->setValue($entity, $data[$field]); $this->originalEntityData[$oid][$field] = $data[$field]; break; @@ -2480,7 +2480,7 @@ public function createEntity(string $className, array $data, array &$hints = []) if (! $associatedId) { // Foreign key is NULL - $class->reflFields[$field]->setValue($entity, null); + $class->propertyAccessors[$field]->setValue($entity, null); $this->originalEntityData[$oid][$field] = null; break; @@ -2546,11 +2546,11 @@ public function createEntity(string $className, array $data, array &$hints = []) } $this->originalEntityData[$oid][$field] = $newValue; - $class->reflFields[$field]->setValue($entity, $newValue); + $class->propertyAccessors[$field]->setValue($entity, $newValue); if ($assoc->inversedBy !== null && $assoc->isOneToOne() && $newValue !== null) { $inverseAssoc = $targetClass->associationMappings[$assoc->inversedBy]; - $targetClass->reflFields[$inverseAssoc->fieldName]->setValue($newValue, $entity); + $targetClass->propertyAccessors[$inverseAssoc->fieldName]->setValue($newValue, $entity); } break; @@ -2566,7 +2566,7 @@ public function createEntity(string $className, array $data, array &$hints = []) if (isset($data[$field]) && $data[$field] instanceof PersistentCollection) { $data[$field]->setOwner($entity, $assoc); - $class->reflFields[$field]->setValue($entity, $data[$field]); + $class->propertyAccessors[$field]->setValue($entity, $data[$field]); $this->originalEntityData[$oid][$field] = $data[$field]; break; @@ -2577,7 +2577,7 @@ public function createEntity(string $className, array $data, array &$hints = []) $pColl->setOwner($entity, $assoc); $pColl->setInitialized(false); - $reflField = $class->reflFields[$field]; + $reflField = $class->propertyAccessors[$field]; $reflField->setValue($entity, $pColl); if ($hints['fetchMode'][$class->name][$field] === ClassMetadata::FETCH_EAGER) { @@ -2657,7 +2657,7 @@ private function eagerLoadCollections(array $collections, ToManyInverseSideMappi $found = $this->getEntityPersister($targetEntity)->loadAll([$mappedBy => $entities], $mapping->orderBy); $targetClass = $this->em->getClassMetadata($targetEntity); - $targetProperty = $targetClass->getReflectionProperty($mappedBy); + $targetProperty = $targetClass->getPropertyAccessor($mappedBy); assert($targetProperty !== null); foreach ($found as $targetValue) { @@ -2679,7 +2679,7 @@ private function eagerLoadCollections(array $collections, ToManyInverseSideMappi $idHash = implode(' ', $id); if ($mapping->indexBy !== null) { - $indexByProperty = $targetClass->getReflectionProperty($mapping->indexBy); + $indexByProperty = $targetClass->getPropertyAccessor($mapping->indexBy); assert($indexByProperty !== null); $collectionBatch[$idHash]->hydrateSet($indexByProperty->getValue($targetValue), $targetValue); } else { @@ -3244,7 +3244,7 @@ final public function assignPostInsertId(object $entity, mixed $generatedId): vo $idValue = $this->convertSingleFieldIdentifierToPHPValue($class, $generatedId); $oid = spl_object_id($entity); - $class->reflFields[$idField]->setValue($entity, $idValue); + $class->propertyAccessors[$idField]->setValue($entity, $idValue); $this->entityIdentifiers[$oid] = [$idField => $idValue]; $this->entityStates[$oid] = self::STATE_MANAGED; diff --git a/tests/Tests/ORM/Functional/EnumTest.php b/tests/Tests/ORM/Functional/EnumTest.php index 75ccac8b50..b5de27ab80 100644 --- a/tests/Tests/ORM/Functional/EnumTest.php +++ b/tests/Tests/ORM/Functional/EnumTest.php @@ -459,7 +459,7 @@ public static function provideCardClasses(): array public function testItAllowsReadingAttributes(): void { $metadata = $this->_em->getClassMetadata(Card::class); - $property = $metadata->getReflectionProperty('suit'); + $property = $metadata->reflFields['suit']; $attributes = $property->getAttributes(); diff --git a/tests/Tests/ORM/Functional/Ticket/DDC168Test.php b/tests/Tests/ORM/Functional/Ticket/DDC168Test.php index 54147ba39c..7e83cfa47b 100644 --- a/tests/Tests/ORM/Functional/Ticket/DDC168Test.php +++ b/tests/Tests/ORM/Functional/Ticket/DDC168Test.php @@ -25,7 +25,7 @@ protected function setUp(): void $this->oldMetadata = $this->_em->getClassMetadata(CompanyEmployee::class); $metadata = clone $this->oldMetadata; - ksort($metadata->reflFields); + ksort($metadata->propertyAccessors); $this->_em->getMetadataFactory()->setMetadataFor(CompanyEmployee::class, $metadata); } diff --git a/tests/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Tests/ORM/Functional/ValueObjectsTest.php index 6656d916ee..25861e45f5 100644 --- a/tests/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Tests/ORM/Functional/ValueObjectsTest.php @@ -45,30 +45,6 @@ protected function setUp(): void ); } - public function testMetadataHasReflectionEmbeddablesAccessible(): void - { - $classMetadata = $this->_em->getClassMetadata(DDC93Person::class); - - if (class_exists(CommonRuntimePublicReflectionProperty::class)) { - self::assertInstanceOf( - CommonRuntimePublicReflectionProperty::class, - $classMetadata->getReflectionProperty('address'), - ); - } elseif (class_exists(RuntimeReflectionProperty::class)) { - self::assertInstanceOf( - RuntimeReflectionProperty::class, - $classMetadata->getReflectionProperty('address'), - ); - } else { - self::assertInstanceOf( - ReflectionProperty::class, - $classMetadata->getReflectionProperty('address'), - ); - } - - self::assertInstanceOf(ReflectionEmbeddedProperty::class, $classMetadata->getReflectionProperty('address.street')); - } - public function testCRUD(): void { $person = new DDC93Person(); diff --git a/tests/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php index 294ac3d53b..2a1cdcd0b0 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php @@ -10,6 +10,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\PropertyAccessors\PropertyAccessor; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmTestCase; use PHPUnit\Framework\Attributes\Group; @@ -26,8 +27,8 @@ public function testEvent(): void $evm->addEventListener(Events::loadClassMetadata, $this); $classMetadata = $metadataFactory->getMetadataFor(LoadEventTestEntity::class); self::assertTrue($classMetadata->hasField('about')); - self::assertArrayHasKey('about', $classMetadata->reflFields); - self::assertInstanceOf(ReflectionProperty::class, $classMetadata->reflFields['about']); + self::assertArrayHasKey('about', $classMetadata->propertyAccessors); + self::assertInstanceOf(PropertyAccessor::class, $classMetadata->propertyAccessors['about']); } public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void diff --git a/tests/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Tests/ORM/Mapping/ClassMetadataTest.php index a7fb88b2e0..b10645b470 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataTest.php @@ -76,7 +76,7 @@ public function testClassMetadataInstanceSerialization(): void $cm->initializeReflection(new RuntimeReflectionService()); // Test initial state - self::assertTrue(count($cm->getReflectionProperties()) === 0); + self::assertTrue(count($cm->getPropertyAccessors()) === 0); self::assertInstanceOf(ReflectionClass::class, $cm->reflClass); self::assertEquals(CmsUser::class, $cm->name); self::assertEquals(CmsUser::class, $cm->rootEntityName); @@ -102,7 +102,7 @@ public function testClassMetadataInstanceSerialization(): void $cm->wakeupReflection(new RuntimeReflectionService()); // Check state - self::assertTrue(count($cm->getReflectionProperties()) > 0); + self::assertTrue(count($cm->getPropertyAccessors()) > 0); self::assertEquals('Doctrine\Tests\Models\CMS', $cm->namespace); self::assertInstanceOf(ReflectionClass::class, $cm->reflClass); self::assertEquals(CmsUser::class, $cm->name); @@ -998,7 +998,7 @@ public function testWakeupReflectionWithEmbeddableAndStaticReflectionService(): $classMetadata->mapField($field); $classMetadata->wakeupReflection(new StaticReflectionService()); - self::assertEquals(['test' => null, 'test.embeddedProperty' => null], $classMetadata->getReflectionProperties()); + self::assertEquals(['test' => null, 'test.embeddedProperty' => null], $classMetadata->getPropertyAccessors()); } public function testGetColumnNamesWithGivenFieldNames(): void