StatementExecuteToExecuteQueryOrExecuteStatementRector

Replace Statement::execute() with executeStatement() for prepared data-changing SQL with unused result, executeQuery() otherwise

 $statement = $connection->prepare('UPDATE user SET name = ?');
-$statement->execute();
+$statement->executeStatement();

 $statement = $connection->prepare('SELECT * FROM user');
-$result = $statement->execute();
+$result = $statement->executeQuery();

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Doctrine\Dbal213\Rector\MethodCall\StatementExecuteToExecuteQueryOrExecuteStatementRector;

return RectorConfig::configure()
    ->withRules([
        StatementExecuteToExecuteQueryOrExecuteStatementRector::class,
    ]);
PACKAGE:  doctrine/dbal >=2.13.1 <6.0

Other rules in the doctrine/dbal set