Skip to content

Commit

Permalink
Don't call deprecated getSQLResultCasing when we know the platform
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jun 5, 2023
1 parent 2afe2dc commit 564c434
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Doctrine/ORM/Internal/SQLResultCasing.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\MySqlPlatform as LegacyMySqlPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;

use function method_exists;
use function strtolower;
Expand All @@ -26,6 +30,11 @@ private function getSQLResultCasing(AbstractPlatform $platform, string $column):
return strtolower($column);
}

/** @psalm-suppress UndefinedClass, InvalidClass */
if ($platform instanceof LegacyMySqlPlatform || $platform instanceof MySQLPlatform || $platform instanceof SQLServerPlatform || $platform instanceof SqlitePlatform) {
return $column;
}

if (method_exists(AbstractPlatform::class, 'getSQLResultCasing')) {
return $platform->getSQLResultCasing($column);
}
Expand Down
1 change: 1 addition & 0 deletions phpstan-dbal2.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ parameters:
- '/Call to an undefined method Doctrine\\DBAL\\Connection::createSchemaManager\(\)\./'
# Class name will change in DBAL 3.
- '/^Class Doctrine\\DBAL\\Platforms\\PostgreSQLPlatform not found\.$/'
- '/Doctrine\\DBAL\\Platforms\\MySqlPlatform\w/'

# Forward compatibility for DBAL 3.5
- '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getAlterSchemaSQL\(\).$/'
Expand Down
1 change: 1 addition & 0 deletions phpstan-persistence2.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ parameters:

- '/^Class Doctrine\\DBAL\\Platforms\\SQLAnywherePlatform not found\.$/'
- '/^Call to method \w+\(\) on an unknown class Doctrine\\DBAL\\Platforms\\SQLAnywherePlatform\.$/'
- '/Doctrine\\DBAL\\Platforms\\MySqlPlatform\w/'

-
message: '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getSQLResultCasing\(\)\.$/'
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ parameters:

- '/^Class Doctrine\\DBAL\\Platforms\\SQLAnywherePlatform not found\.$/'
- '/^Call to method \w+\(\) on an unknown class Doctrine\\DBAL\\Platforms\\SQLAnywherePlatform\.$/'
- '/Doctrine\\DBAL\\Platforms\\MySqlPlatform\w/'

-
message: '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getSQLResultCasing\(\)\.$/'
Expand Down

0 comments on commit 564c434

Please sign in to comment.