Skip to content

Commit cc8c7a8

Browse files
eltharinfabpot
authored andcommitted
[DoctrineBridge] Fix deprecation warning with ORM 3 when guessing field lengths
1 parent 936d276 commit cc8c7a8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Form/DoctrineOrmTypeGuesser.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\DBAL\Types\Types;
1515
use Doctrine\ORM\Mapping\ClassMetadataInfo;
16+
use Doctrine\ORM\Mapping\FieldMapping;
1617
use Doctrine\ORM\Mapping\JoinColumnMapping;
1718
use Doctrine\ORM\Mapping\MappingException as LegacyMappingException;
1819
use Doctrine\Persistence\ManagerRegistry;
@@ -141,8 +142,10 @@ public function guessMaxLength(string $class, string $property)
141142
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
142143
$mapping = $ret[0]->getFieldMapping($property);
143144

144-
if (isset($mapping['length'])) {
145-
return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE);
145+
$length = $mapping instanceof FieldMapping ? $mapping->length : ($mapping['length'] ?? null);
146+
147+
if (null !== $length) {
148+
return new ValueGuess($length, Guess::HIGH_CONFIDENCE);
146149
}
147150

148151
if (\in_array($ret[0]->getTypeOfField($property), [Types::DECIMAL, Types::FLOAT])) {

0 commit comments

Comments
 (0)