Skip to content

Commit

Permalink
Restore PDOStatement::quote() for backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Sep 22, 2020
1 parent 5d22823 commit 8d548fe
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOConnection.php
Expand Up @@ -5,6 +5,7 @@
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;
Expand Down Expand Up @@ -101,6 +102,14 @@ public function query()
}
}

/**
* {@inheritdoc}
*/
public function quote($input, $type = ParameterType::STRING)
{
return parent::quote($input, $type);
}

/**
* {@inheritdoc}
*/
Expand Down
5 changes: 5 additions & 0 deletions phpcs.xml.dist
Expand Up @@ -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>
Expand Down
10 changes: 10 additions & 0 deletions 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;
Expand Down Expand Up @@ -100,4 +102,12 @@ public function testThrowsWrappedExceptionOnQuery(): void

$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));
}
}

0 comments on commit 8d548fe

Please sign in to comment.