Skip to content

Commit 0eedf91

Browse files
Don't call deprecated getSQLResultCasing and usesSequenceEmulatedIdentityColumns when we know the platform
1 parent 6c9b29f commit 0eedf91

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

lib/Doctrine/ORM/Internal/SQLResultCasing.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
use Doctrine\DBAL\Platforms\OraclePlatform;
1010
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
1111

12+
use function get_class;
1213
use function method_exists;
14+
use function strpos;
1315
use function strtolower;
1416
use function strtoupper;
1517

@@ -26,7 +28,7 @@ private function getSQLResultCasing(AbstractPlatform $platform, string $column):
2628
return strtolower($column);
2729
}
2830

29-
if (method_exists(AbstractPlatform::class, 'getSQLResultCasing')) {
31+
if (strpos(get_class($platform), 'Doctrine\\DBAL\\Platforms\\') !== 0 && method_exists(AbstractPlatform::class, 'getSQLResultCasing')) {
3032
return $platform->getSQLResultCasing($column);
3133
}
3234

lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use Doctrine\Common\EventManager;
88
use Doctrine\DBAL\Platforms;
99
use Doctrine\DBAL\Platforms\AbstractPlatform;
10+
use Doctrine\DBAL\Platforms\MySQLPlatform;
11+
use Doctrine\DBAL\Platforms\SqlitePlatform;
12+
use Doctrine\DBAL\Platforms\SQLServerPlatform;
1013
use Doctrine\Deprecations\Deprecation;
1114
use Doctrine\ORM\EntityManagerInterface;
1215
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
@@ -621,9 +624,11 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class): void
621624
case ClassMetadata::GENERATOR_TYPE_IDENTITY:
622625
$sequenceName = null;
623626
$fieldName = $class->identifier ? $class->getSingleIdentifierFieldName() : null;
627+
$platform = $this->getTargetPlatform();
624628

625629
// Platforms that do not have native IDENTITY support need a sequence to emulate this behaviour.
626-
if ($this->getTargetPlatform()->usesSequenceEmulatedIdentityColumns()) {
630+
/** @psalm-suppress UndefinedClass, InvalidClass */
631+
if (! $platform instanceof MySQLPlatform && ! $platform instanceof SqlitePlatform && ! $platform instanceof SQLServerPlatform && $platform->usesSequenceEmulatedIdentityColumns()) {
627632
Deprecation::trigger(
628633
'doctrine/orm',
629634
'https://github.com/doctrine/orm/issues/8850',

phpstan-dbal2.neon

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ parameters:
1010
- '/Call to an undefined method Doctrine\\DBAL\\Connection::createSchemaManager\(\)\./'
1111
# Class name will change in DBAL 3.
1212
- '/^Class Doctrine\\DBAL\\Platforms\\PostgreSQLPlatform not found\.$/'
13+
-
14+
message: '/Doctrine\\DBAL\\Platforms\\MyS(ql|QL)Platform/'
15+
path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
1316

1417
# Forward compatibility for DBAL 3.5
1518
- '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getAlterSchemaSQL\(\).$/'

0 commit comments

Comments
 (0)