Skip to content

Commit a7023cb

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

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

lib/Doctrine/ORM/Internal/SQLResultCasing.php

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

12+
use function get_class;
1213
use function method_exists;
1314
use function strtolower;
1415
use function strtoupper;
@@ -26,7 +27,7 @@ private function getSQLResultCasing(AbstractPlatform $platform, string $column):
2627
return strtolower($column);
2728
}
2829

29-
if (method_exists(AbstractPlatform::class, 'getSQLResultCasing')) {
30+
if (0 !== strpos(get_class($platform), 'Doctrine\\DBAL\\Platforms\\') && method_exists(AbstractPlatform::class, 'getSQLResultCasing')) {
3031
return $platform->getSQLResultCasing($column);
3132
}
3233

lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
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\MySqlPlatform as LegacyMySqlPlatform;
12+
use Doctrine\DBAL\Platforms\SqlitePlatform;
13+
use Doctrine\DBAL\Platforms\SQLServerPlatform;
1014
use Doctrine\Deprecations\Deprecation;
1115
use Doctrine\ORM\EntityManagerInterface;
1216
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
@@ -621,9 +625,11 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class): void
621625
case ClassMetadata::GENERATOR_TYPE_IDENTITY:
622626
$sequenceName = null;
623627
$fieldName = $class->identifier ? $class->getSingleIdentifierFieldName() : null;
628+
$platform = $this->getTargetPlatform();
624629

625630
// Platforms that do not have native IDENTITY support need a sequence to emulate this behaviour.
626-
if ($this->getTargetPlatform()->usesSequenceEmulatedIdentityColumns()) {
631+
/** @psalm-suppress UndefinedClass, InvalidClass */
632+
if (! $platform instanceof SqlitePlatform && ! $platform instanceof MySQLPlatform && ! $platform instanceof LegacyMySqlPlatform && ! $platform instanceof SQLServerPlatform && $platform->usesSequenceEmulatedIdentityColumns()) {
627633
Deprecation::trigger(
628634
'doctrine/orm',
629635
'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\(\).$/'

phpstan-persistence2.neon

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ parameters:
1515
- '/^Class Doctrine\\DBAL\\Platforms\\SQLAnywherePlatform not found\.$/'
1616
- '/^Call to method \w+\(\) on an unknown class Doctrine\\DBAL\\Platforms\\SQLAnywherePlatform\.$/'
1717

18+
-
19+
message: '/Doctrine\\DBAL\\Platforms\\MyS(ql|QL)Platform/'
20+
path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
1821
-
1922
message: '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getSQLResultCasing\(\)\.$/'
2023
path: lib/Doctrine/ORM/Internal/SQLResultCasing.php

phpstan.neon

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ parameters:
1515
- '/^Class Doctrine\\DBAL\\Platforms\\SQLAnywherePlatform not found\.$/'
1616
- '/^Call to method \w+\(\) on an unknown class Doctrine\\DBAL\\Platforms\\SQLAnywherePlatform\.$/'
1717

18+
-
19+
message: '/Doctrine\\DBAL\\Platforms\\MyS(ql|QL)Platform/'
20+
path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
1821
-
1922
message: '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getSQLResultCasing\(\)\.$/'
2023
path: lib/Doctrine/ORM/Internal/SQLResultCasing.php

0 commit comments

Comments
 (0)