Skip to content

Commit 3764307

Browse files
Merge branch '5.4' into 6.0
* 5.4: [DoctrineBridge] Remove dead code [Lock] Remove unused variable [DoctrineBridge] Replace string with FQCN resolution in EntityType Add missing `@return $this` annotations [Notifier] Add missing types to SmscTransport
2 parents 9f72be3 + 5ddbffc commit 3764307

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

Form/Type/EntityType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ public function configureOptions(OptionsResolver $resolver)
3232
$queryBuilder = $queryBuilder($options['em']->getRepository($options['class']));
3333

3434
if (null !== $queryBuilder && !$queryBuilder instanceof QueryBuilder) {
35-
throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ORM\QueryBuilder');
35+
throw new UnexpectedTypeException($queryBuilder, QueryBuilder::class);
3636
}
3737
}
3838

3939
return $queryBuilder;
4040
};
4141

4242
$resolver->setNormalizer('query_builder', $queryBuilderNormalizer);
43-
$resolver->setAllowedTypes('query_builder', ['null', 'callable', 'Doctrine\ORM\QueryBuilder']);
43+
$resolver->setAllowedTypes('query_builder', ['null', 'callable', QueryBuilder::class]);
4444
}
4545

4646
/**

PropertyInfo/DoctrineExtractor.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
namespace Symfony\Bridge\Doctrine\PropertyInfo;
1313

14+
use Doctrine\Common\Collections\Collection;
1415
use Doctrine\DBAL\Types\Types;
1516
use Doctrine\ORM\EntityManagerInterface;
1617
use Doctrine\ORM\Mapping\ClassMetadata;
1718
use Doctrine\ORM\Mapping\ClassMetadataInfo;
1819
use Doctrine\ORM\Mapping\Embedded;
1920
use Doctrine\ORM\Mapping\MappingException as OrmMappingException;
20-
use Doctrine\Persistence\Mapping\ClassMetadataFactory;
2121
use Doctrine\Persistence\Mapping\MappingException;
2222
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
2323
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
@@ -32,7 +32,6 @@
3232
class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeExtractorInterface, PropertyAccessExtractorInterface
3333
{
3434
private EntityManagerInterface $entityManager;
35-
private ClassMetadataFactory $classMetadataFactory;
3635

3736
public function __construct(EntityManagerInterface $entityManager)
3837
{
@@ -92,7 +91,7 @@ public function getTypes(string $class, string $property, array $context = []):
9291

9392
if (isset($associationMapping['indexBy'])) {
9493
/** @var ClassMetadataInfo $subMetadata */
95-
$subMetadata = $this->entityManager ? $this->entityManager->getClassMetadata($associationMapping['targetEntity']) : $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
94+
$subMetadata = $this->entityManager->getClassMetadata($associationMapping['targetEntity']);
9695

9796
// Check if indexBy value is a property
9897
$fieldName = $associationMapping['indexBy'];
@@ -105,7 +104,7 @@ public function getTypes(string $class, string $property, array $context = []):
105104

106105
/** @var ClassMetadataInfo $subMetadata */
107106
$indexProperty = $subMetadata->getSingleAssociationReferencedJoinColumnName($fieldName);
108-
$subMetadata = $this->entityManager ? $this->entityManager->getClassMetadata($associationMapping['targetEntity']) : $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
107+
$subMetadata = $this->entityManager->getClassMetadata($associationMapping['targetEntity']);
109108

110109
//Not a property, maybe a column name?
111110
if (null === ($typeOfField = $subMetadata->getTypeOfField($indexProperty))) {
@@ -124,7 +123,7 @@ public function getTypes(string $class, string $property, array $context = []):
124123
return [new Type(
125124
Type::BUILTIN_TYPE_OBJECT,
126125
false,
127-
'Doctrine\Common\Collections\Collection',
126+
Collection::class,
128127
true,
129128
new Type($collectionKeyType),
130129
new Type(Type::BUILTIN_TYPE_OBJECT, false, $class)
@@ -209,8 +208,8 @@ public function isWritable(string $class, string $property, array $context = [])
209208
private function getMetadata(string $class): ?ClassMetadata
210209
{
211210
try {
212-
return $this->entityManager ? $this->entityManager->getClassMetadata($class) : $this->classMetadataFactory->getMetadataFor($class);
213-
} catch (MappingException | OrmMappingException $exception) {
211+
return $this->entityManager->getClassMetadata($class);
212+
} catch (MappingException|OrmMappingException $exception) {
214213
return null;
215214
}
216215
}

0 commit comments

Comments
 (0)