Repository: doctrine/dbal (php)

Issue:
BC Break after removing method \Doctrine\DBAL\Driver\PDOConnection::quote
The problem appeared in releases 2.10.3 [commit](https://github.com/doctrine/dbal/pull/3287/commits/85bc13deb0abbbf3a99347ab9b757c8c1a1ebd96)

The problem is that now, with strict mode enabled, nothing but string cannot be passed to \Doctrine\DBAL\Driver\PDOConnection::quote. These changes break backward compatibility and should not have been recorded as minor changes.



Pull request description:
Restore PDOStatement::quote() for backward compatibility
Fixes #4281.

Patch:
diff --git a/lib/Doctrine/DBAL/Driver/PDOConnection.php b/lib/Doctrine/DBAL/Driver/PDOConnection.php
index 43b8280ef..8409952cb 100644
--- a/lib/Doctrine/DBAL/Driver/PDOConnection.php
+++ b/lib/Doctrine/DBAL/Driver/PDOConnection.php
@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Driver;
 use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
 use Doctrine\DBAL\Driver\PDO\Exception;
 use Doctrine\DBAL\Driver\PDO\Statement;
+use Doctrine\DBAL\ParameterType;
 use PDO;
 use PDOException;
 use PDOStatement;
@@ -101,6 +102,14 @@ class PDOConnection extends PDO implements ConnectionInterface, ServerInfoAwareC
         }
     }
 
+    /**
+     * {@inheritdoc}
+     */
+    public function quote($value, $type = ParameterType::STRING)
+    {
+        return parent::quote($value, $type);
+    }
+
     /**
      * {@inheritdoc}
      */
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index c82ca439e..8c6b82da6 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -110,6 +110,11 @@
         <exclude-pattern>lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php</exclude-pattern>
     </rule>
 
+    <!-- The override opts out the caller from the strict mode for backward compatibility -->
+    <rule ref="Generic.CodeAnalysis.UselessOverridingMethod.Found">
+        <exclude-pattern>lib/Doctrine/DBAL/Driver/PDOConnection.php</exclude-pattern>
+    </rule>
+
     <!-- See https://github.com/slevomat/coding-standard/issues/770 -->
     <rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
         <exclude-pattern>lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php</exclude-pattern>


Test patch:
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php
index f54cb07b0..c9f748fbc 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php
@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace Doctrine\Tests\DBAL\Functional\Driver\PDO;
 
 use Doctrine\DBAL\Driver\PDO\Connection;
@@ -100,4 +102,12 @@ class ConnectionTest extends DbalFunctionalTestCase
 
         $this->driverConnection->query('foo');
     }
+
+    /**
+     * This test ensures backward compatibility with DBAL 2.x and should be removed in 3.0.
+     */
+    public function testQuoteInteger(): void
+    {
+        self::assertSame("'1'", $this->connection->getWrappedConnection()->quote(1));
+    }
 }