Skip to content

[DBAL 32] add platform get name replace - #516

Merged
TomasVotruba merged 2 commits into
rectorphp:mainfrom
JohJohan:DBAL32
Aug 27, 2026
Merged

[DBAL 32] add platform get name replace#516
TomasVotruba merged 2 commits into
rectorphp:mainfrom
JohJohan:DBAL32

Conversation

@JohJohan

@JohJohan JohJohan commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Adds PlatformGetNameToInstanceofRector for the DBAL 3.2 deprecation of AbstractPlatform::getName() (doctrine/dbal#4755).

String comparisons against getName() become instanceof checks against the concrete platform class:

 use Doctrine\DBAL\Platforms\AbstractPlatform;

 function run(AbstractPlatform $platform): void
 {
-    if ('postgresql' === $platform->getName()) {
+    if ($platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform) {
     }

-    if ($platform->getName() === 'mysql') {
+    if ($platform instanceof \Doctrine\DBAL\Platforms\MySQLPlatform) {
     }
 }

Handles both operand orders and ===/==. Only fires when the receiver is typed as Doctrine\DBAL\Platforms\AbstractPlatform, so unrelated getName() calls are left alone.

Platform map uses the actual getName() return strings: postgresql, mysql, sqlite, oracle, mssql (SQL Server), db2. Unknown strings are skipped.

@TomasVotruba

Copy link
Copy Markdown
Member

Test fail is not related to your PR

@TomasVotruba
TomasVotruba merged commit d406eb0 into rectorphp:main Aug 27, 2026
7 checks passed
@TomasVotruba

Copy link
Copy Markdown
Member

Let's ship it 👍 Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants