Skip to content

Commit 0d97a44

Browse files
committed
Fix DBAL deprecation
1 parent d3e1440 commit 0d97a44

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

phpstan-dbal3.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ parameters:
3838
message: '~^Call to static method quoted\(\) on an unknown class Doctrine\\DBAL\\Schema\\Name\\Identifier\.$~'
3939
path: src/Tools/SchemaTool.php
4040

41+
-
42+
message: '~^Call to an undefined method Doctrine\\DBAL\\Schema\\Table\:\:getObjectName\(\)\.$~'
43+
path: src/Mapping/Driver/DatabaseDriver.php
44+
4145
-
4246
message: '~^Call to an undefined method Doctrine\\DBAL\\Schema\\ForeignKeyConstraint::get.*\.$~'
4347
identifier: method.notFound

src/Mapping/Driver/DatabaseDriver.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,14 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata
252252
];
253253
}
254254
} else {
255-
$associationMapping['mappedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current(self::getReferencingColumnNames($myFk)), true);
255+
$associationMapping['mappedBy'] = $this->getFieldNameForColumn(
256+
// @phpstan-ignore function.alreadyNarrowedType (DBAL 3 compatibility)
257+
method_exists(Table::class, 'getObjectName')
258+
? $manyTable->getObjectName()->toString()
259+
: $manyTable->getName(), // DBAL < 4.4
260+
current(self::getReferencingColumnNames($myFk)),
261+
true,
262+
);
256263
}
257264

258265
$metadata->mapManyToMany($associationMapping);

0 commit comments

Comments
 (0)