diff --git a/.doctrine-project.json b/.doctrine-project.json index 242ebaa2a9b..30b037b28b0 100644 --- a/.doctrine-project.json +++ b/.doctrine-project.json @@ -11,6 +11,12 @@ "slug": "latest", "upcoming": true }, + { + "name": "3.7", + "branchName": "3.7.x", + "slug": "3.7", + "upcoming": true + }, { "name": "3.6", "branchName": "3.6.x", diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 74142d9b775..2fe054086f0 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -484,7 +484,7 @@ jobs: services: ibm_db2: - image: "ibmcom/db2:11.5.0.0" + image: "icr.io/db2_community/db2:11.5.8.0" env: DB2INST1_PASSWORD: "Doctrine2018" LICENSE: "accept" @@ -500,22 +500,29 @@ jobs: run: "docker logs -f ${{ job.services.ibm_db2.id }} | sed '/(*) Setup has completed./ q'" - name: "Create temporary tablespace" - run: "docker exec ${{ job.services.ibm_db2.id }} su - db2inst1 -c 'db2 CONNECT TO doctrine && db2 CREATE USER TEMPORARY TABLESPACE doctrine_tbsp PAGESIZE 4 K'" + run: "docker exec ${{ job.services.ibm_db2.id }} su - db2inst1 -c 'db2 -t CONNECT TO doctrine; db2 -t CREATE USER TEMPORARY TABLESPACE doctrine_tbsp PAGESIZE 4 K;'" - name: "Checkout" uses: "actions/checkout@v3" with: fetch-depth: 2 + - name: "Install IBM DB2 CLI driver" + working-directory: /tmp + run: | + wget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz + tar xf linuxx64_odbc_cli.tar.gz + rm linuxx64_odbc_cli.tar.gz + - name: "Install PHP" uses: "shivammathur/setup-php@v2" with: php-version: "${{ matrix.php-version }}" + extensions: "ibm_db2" coverage: "pcov" - ini-values: "zend.assertions=1, extension=ibm_db2.so, ibm_db2.instance_name=db2inst1" - - - name: "Install ibm_db2 extension" - run: "ci/github/ext/install-ibm_db2.sh ${{ matrix.php-version }}" + ini-values: "zend.assertions=1, ibm_db2.instance_name=db2inst1" + env: + IBM_DB2_CONFIGURE_OPTS: "--with-IBM_DB2=/tmp/clidriver" - name: "Install dependencies with Composer" uses: "ramsey/composer-install@v2" diff --git a/ci/github/ext/install-ibm_db2.sh b/ci/github/ext/install-ibm_db2.sh deleted file mode 100755 index 00336dd59a7..00000000000 --- a/ci/github/ext/install-ibm_db2.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -echo "Installing extension" -( - cd /tmp - - wget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz - - tar xf linuxx64_odbc_cli.tar.gz - - pecl download ibm_db2 - tar xf ibm_db2-* - rm ibm_db2-*.tgz - cd ibm_db2-* - phpize - ./configure --with-IBM_DB2=/tmp/clidriver - make -j "$(nproc)" - sudo make install -) diff --git a/docs/en/reference/introduction.rst b/docs/en/reference/introduction.rst index 9f66a2b44d5..ea104dd1252 100644 --- a/docs/en/reference/introduction.rst +++ b/docs/en/reference/introduction.rst @@ -13,10 +13,12 @@ the oci8 extension under the hood. The following database vendors are currently supported: -- MySQL +- DB2 (IBM) +- MariaDB +- MySQL (Oracle) - Oracle -- Microsoft SQL Server - PostgreSQL +- SQL Server (Microsoft) - SQLite The Doctrine DBAL can be used independently of the diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c3f3a86737e..7e6350c790e 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -63,6 +63,10 @@ parameters: message: '~^Parameter #1 \$driverOptions of method Doctrine\\DBAL\\Tests\\Functional\\Driver\\Mysqli\\ConnectionTest\:\:getConnection\(\) expects array, .* given\.$~' path: tests/Functional/Driver/Mysqli/ConnectionTest.php + - + message: '~^Parameter #1 \$mode of method Doctrine\\DBAL\\Result\:\:fetch(?:All)?\(\) expects 2\|3\|7, 1 given\.$~' + path: tests/Functional/LegacyAPITest.php + # DriverManagerTest::testDatabaseUrl() should be refactored as it's too dynamic. - message: '~^Offset string does not exist on array{.+}\.$~' diff --git a/psalm.xml.dist b/psalm.xml.dist index e7d763547ac..193131f5e0b 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -31,6 +31,14 @@ + + + + + + + @@ -173,6 +182,7 @@ + diff --git a/src/Connection.php b/src/Connection.php index 338b4665400..6e75bc3911c 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -1383,22 +1383,36 @@ public function executeUpdate(string $sql, array $params = [], array $types = [] /** * BC layer for a wide-spread use-case of old DBAL APIs * - * @deprecated This API is deprecated and will be removed after 2022 + * @deprecated Use {@see executeQuery()} instead */ public function query(string $sql): Result { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/4163', + '%s is deprecated, please use executeQuery() instead.', + __METHOD__, + ); + return $this->executeQuery($sql); } /** * BC layer for a wide-spread use-case of old DBAL APIs * - * @deprecated This API is deprecated and will be removed after 2022 + * @deprecated please use {@see executeStatement()} instead * * @return int|numeric-string */ public function exec(string $sql): int|string { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/4163', + '%s is deprecated, please use executeStatement() instead.', + __METHOD__, + ); + return $this->executeStatement($sql); } } diff --git a/src/Driver/AbstractMySQLDriver.php b/src/Driver/AbstractMySQLDriver.php index 91e9a6e451a..a70afdaf744 100644 --- a/src/Driver/AbstractMySQLDriver.php +++ b/src/Driver/AbstractMySQLDriver.php @@ -6,13 +6,15 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter; -use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; +use Doctrine\DBAL\Platforms\Exception\InvalidPlatformVersion; +use Doctrine\DBAL\Platforms\MariaDB1052Platform; use Doctrine\DBAL\Platforms\MariaDBPlatform; use Doctrine\DBAL\Platforms\MySQL80Platform; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\ServerVersionProvider; +use function preg_match; use function stripos; use function version_compare; @@ -24,12 +26,16 @@ abstract class AbstractMySQLDriver implements Driver /** * {@inheritdoc} * - * @throws Exception + * @throws InvalidPlatformVersion */ public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractMySQLPlatform { $version = $versionProvider->getServerVersion(); - if (stripos($version, 'MariaDB') !== false) { + if (stripos($version, 'mariadb') !== false) { + if (version_compare($this->getMariaDbMysqlVersionNumber($version), '10.5.2', '>=')) { + return new MariaDB1052Platform(); + } + return new MariaDBPlatform(); } @@ -44,4 +50,30 @@ public function getExceptionConverter(): ExceptionConverter { return new ExceptionConverter(); } + + /** + * Detect MariaDB server version, including hack for some mariadb distributions + * that starts with the prefix '5.5.5-' + * + * @param string $versionString Version string as returned by mariadb server, i.e. '5.5.5-Mariadb-10.0.8-xenial' + * + * @throws InvalidPlatformVersion + */ + private function getMariaDbMysqlVersionNumber(string $versionString): string + { + if ( + preg_match( + '/^(?:5\.5\.5-)?(mariadb-)?(?P\d+)\.(?P\d+)\.(?P\d+)/i', + $versionString, + $versionParts, + ) === 0 + ) { + throw InvalidPlatformVersion::new( + $versionString, + '^(?:5\.5\.5-)?(mariadb-)?..', + ); + } + + return $versionParts['major'] . '.' . $versionParts['minor'] . '.' . $versionParts['patch']; + } } diff --git a/src/FetchMode.php b/src/FetchMode.php index eb050a5bb9f..0d8dd2e1b2b 100644 --- a/src/FetchMode.php +++ b/src/FetchMode.php @@ -6,6 +6,8 @@ /** * Legacy Class that keeps BC for using the legacy APIs fetch()/fetchAll(). + * + * @deprecated Use the dedicated fetch*() methods for the desired fetch mode instead. */ class FetchMode { diff --git a/src/Platforms/MariaDB1052Platform.php b/src/Platforms/MariaDB1052Platform.php new file mode 100644 index 00000000000..2e6c4a5b61f --- /dev/null +++ b/src/Platforms/MariaDB1052Platform.php @@ -0,0 +1,40 @@ +getQuotedName($this)]; + } +} diff --git a/src/Portability/Converter.php b/src/Portability/Converter.php index c645a58dcd3..ae117720281 100644 --- a/src/Portability/Converter.php +++ b/src/Portability/Converter.php @@ -12,8 +12,14 @@ use function is_string; use function rtrim; +use const CASE_LOWER; +use const CASE_UPPER; + final class Converter { + public const CASE_LOWER = CASE_LOWER; + public const CASE_UPPER = CASE_UPPER; + private readonly Closure $convertNumeric; private readonly Closure $convertAssociative; private readonly Closure $convertOne; @@ -22,10 +28,12 @@ final class Converter private readonly Closure $convertFirstColumn; /** - * @param bool $convertEmptyStringToNull Whether each empty string should be converted to NULL - * @param bool $rightTrimString Whether each string should right-trimmed - * @param int|null $case Convert the case of the column names - * (one of {@see CASE_LOWER} and {@see CASE_UPPER}) + * @param bool $convertEmptyStringToNull Whether each empty string should + * be converted to NULL + * @param bool $rightTrimString Whether each string should right-trimmed + * @param self::CASE_LOWER|self::CASE_UPPER|null $case Convert the case of the column names + * (one of {@see self::CASE_LOWER} and + * {@see self::CASE_UPPER}) */ public function __construct(bool $convertEmptyStringToNull, bool $rightTrimString, ?int $case) { @@ -168,8 +176,8 @@ private function createConvertValue(bool $convertEmptyStringToNull, bool $rightT /** * Creates a function that will convert each array-row retrieved from the database * - * @param Closure|null $function The function that will convert each value - * @param int|null $case Column name case + * @param Closure|null $function The function that will convert each value + * @param self::CASE_LOWER|self::CASE_UPPER|null $case Column name case * * @return Closure|null The resulting function or NULL if no conversion is needed */ diff --git a/src/Portability/OptimizeFlags.php b/src/Portability/OptimizeFlags.php index 511d896df67..c985d4bfda6 100644 --- a/src/Portability/OptimizeFlags.php +++ b/src/Portability/OptimizeFlags.php @@ -17,7 +17,7 @@ final class OptimizeFlags * Platform-specific portability flags that need to be excluded from the user-provided mode * since the platform already operates in this mode to avoid unnecessary conversion overhead. * - * @var array + * @var array */ private static array $platforms = [ DB2Platform::class => 0, diff --git a/src/Result.php b/src/Result.php index d532531f586..e87fac10c7c 100644 --- a/src/Result.php +++ b/src/Result.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\Exception as DriverException; use Doctrine\DBAL\Driver\Result as DriverResult; use Doctrine\DBAL\Exception\NoKeyValue; +use Doctrine\Deprecations\Deprecation; use LogicException; use Traversable; @@ -266,12 +267,21 @@ private function ensureHasKeyValue(): void /** * BC layer for a wide-spread use-case of old DBAL APIs * - * @deprecated This API is deprecated and will be removed after 2022 + * @deprecated Use {@see fetchNumeric()}, {@see fetchAssociative()} or {@see fetchOne()} instead. + * + * @psalm-param FetchMode::* $mode * * @throws Exception */ public function fetch(int $mode = FetchMode::ASSOCIATIVE): mixed { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/4007', + '%s is deprecated, please use fetchNumeric(), fetchAssociative() or fetchOne() instead.', + __METHOD__, + ); + if (func_num_args() > 1) { throw new LogicException('Only invocations with one argument are still supported by this legacy API.'); } @@ -294,7 +304,9 @@ public function fetch(int $mode = FetchMode::ASSOCIATIVE): mixed /** * BC layer for a wide-spread use-case of old DBAL APIs * - * @deprecated This API is deprecated and will be removed after 2022 + * @deprecated Use {@see fetchAllNumeric()}, {@see fetchAllAssociative()} or {@see fetchFirstColumn()} instead. + * + * @psalm-param FetchMode::* $mode * * @return list * @@ -302,6 +314,13 @@ public function fetch(int $mode = FetchMode::ASSOCIATIVE): mixed */ public function fetchAll(int $mode = FetchMode::ASSOCIATIVE): array { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/4007', + '%s is deprecated, please use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead.', + __METHOD__, + ); + if (func_num_args() > 1) { throw new LogicException('Only invocations with one argument are still supported by this legacy API.'); } diff --git a/src/Schema/PostgreSQLSchemaManager.php b/src/Schema/PostgreSQLSchemaManager.php index eca84420130..6eb342bd0f1 100644 --- a/src/Schema/PostgreSQLSchemaManager.php +++ b/src/Schema/PostgreSQLSchemaManager.php @@ -448,6 +448,7 @@ protected function selectTableColumns(string $databaseName, ?string $tableName = LEFT JOIN pg_depend d ON d.objid = c.oid AND d.deptype = 'e' + AND d.classid = (SELECT oid FROM pg_class WHERE relname = 'pg_class') SQL; $conditions = array_merge([ diff --git a/tests/Driver/AbstractMySQLDriverTest.php b/tests/Driver/AbstractMySQLDriverTest.php index 1c52183f4e4..a3c7ffbe381 100644 --- a/tests/Driver/AbstractMySQLDriverTest.php +++ b/tests/Driver/AbstractMySQLDriverTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Driver\API\ExceptionConverter; use Doctrine\DBAL\Driver\API\MySQL; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Platforms\MariaDB1052Platform; use Doctrine\DBAL\Platforms\MariaDBPlatform; use Doctrine\DBAL\Platforms\MySQL80Platform; use Doctrine\DBAL\Platforms\MySQLPlatform; @@ -54,6 +55,7 @@ public static function platformVersionProvider(): array ['5.5.5-MariaDB-10.2.8+maria~xenial-log', MariaDBPlatform::class], ['10.2.8-MariaDB-10.2.8+maria~xenial-log', MariaDBPlatform::class], ['10.2.8-MariaDB-1~lenny-log', MariaDBPlatform::class], + ['10.5.2-MariaDB-1~lenny-log', MariaDB1052Platform::class], ]; } } diff --git a/tests/Functional/LegacyAPITest.php b/tests/Functional/LegacyAPITest.php index 1d85f4f2d79..4edf7ad6e70 100644 --- a/tests/Functional/LegacyAPITest.php +++ b/tests/Functional/LegacyAPITest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Tests\FunctionalTestCase; +use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use LogicException; use function array_change_key_case; @@ -16,6 +17,8 @@ class LegacyAPITest extends FunctionalTestCase { + use VerifyDeprecations; + protected function setUp(): void { $table = new Table('legacy_table'); @@ -41,7 +44,10 @@ public function testFetchWithAssociativeMode(): void $sql = 'SELECT test_int FROM legacy_table WHERE test_int = 1'; $stmt = $this->connection->executeQuery($sql); - $row = array_change_key_case($stmt->fetch(FetchMode::ASSOCIATIVE), CASE_LOWER); + + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/4007'); + + $row = array_change_key_case($stmt->fetch(FetchMode::ASSOCIATIVE), CASE_LOWER); self::assertEquals(1, $row['test_int']); } @@ -50,7 +56,10 @@ public function testFetchWithNumericMode(): void $sql = 'SELECT test_int FROM legacy_table WHERE test_int = 1'; $stmt = $this->connection->executeQuery($sql); - $row = $stmt->fetch(FetchMode::NUMERIC); + + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/4007'); + + $row = $stmt->fetch(FetchMode::NUMERIC); self::assertEquals(1, $row[0]); } @@ -59,7 +68,10 @@ public function testFetchWithColumnMode(): void $sql = 'SELECT test_int FROM legacy_table WHERE test_int = 1'; $stmt = $this->connection->executeQuery($sql); - $row = $stmt->fetch(FetchMode::COLUMN); + + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/4007'); + + $row = $stmt->fetch(FetchMode::COLUMN); self::assertEquals(1, $row); } @@ -91,6 +103,8 @@ public function testFetchAllWithAssociativeModes(): void $stmt = $this->connection->executeQuery($sql); + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/4007'); + $rows = $stmt->fetchAll(FetchMode::ASSOCIATIVE); $rows = array_map(static function (array $row): array { return array_change_key_case($row, CASE_LOWER); @@ -104,6 +118,9 @@ public function testFetchAllWithNumericModes(): void $sql = 'SELECT test_int FROM legacy_table WHERE test_int = 1'; $stmt = $this->connection->executeQuery($sql); + + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/4007'); + $rows = $stmt->fetchAll(FetchMode::NUMERIC); self::assertEquals([[0 => 1]], $rows); } @@ -113,6 +130,9 @@ public function testFetchAllWithColumnMode(): void $sql = 'SELECT test_int FROM legacy_table WHERE test_int = 1'; $stmt = $this->connection->executeQuery($sql); + + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/4007'); + $rows = $stmt->fetchAll(FetchMode::COLUMN); self::assertEquals([1], $rows); } @@ -150,12 +170,17 @@ public function testExecuteUpdate(): void $sql = 'SELECT test_string FROM legacy_table'; $stmt = $this->connection->executeQuery($sql); + + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/4007'); + $rows = $stmt->fetchAll(FetchMode::COLUMN); self::assertEquals(['foo', 'bar'], $rows); } public function testQuery(): void { + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/4163'); + $stmt = $this->connection->query('SELECT test_string FROM legacy_table WHERE test_int = 1'); self::assertEquals('foo', $stmt->fetchOne()); @@ -168,6 +193,8 @@ public function testExec(): void 'test_string' => 'bar', ]); + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/4163'); + $count = $this->connection->exec('DELETE FROM legacy_table WHERE test_int > 1'); self::assertEquals(1, $count); diff --git a/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php b/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php index a516cdb2ce8..4aca1f2a425 100644 --- a/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php +++ b/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php @@ -21,7 +21,9 @@ use function array_map; use function array_pop; use function count; +use function sprintf; use function strtolower; +use function version_compare; class PostgreSQLSchemaManagerTest extends SchemaManagerFunctionalTestCase { @@ -484,6 +486,67 @@ public function testAlterTableAutoIncrementIntToBigInt(string $from, string $to, self::assertTrue($tableFinal->getColumn('id')->getAutoincrement()); } + public function testListTableColumnsOidConflictWithNonTableObject(): void + { + if (version_compare($this->connection->getServerVersion(), '12.0', '<')) { + self::markTestSkipped('Manually setting the Oid is not supported in Postgres 11 and earlier'); + } + + $table = 'test_list_table_columns_oid_conflicts'; + $this->connection->executeStatement(sprintf('CREATE TABLE IF NOT EXISTS %s(id INT NOT NULL)', $table)); + $beforeColumns = $this->schemaManager->listTableColumns($table); + self::assertArrayHasKey('id', $beforeColumns); + + $this->connection->executeStatement('CREATE EXTENSION IF NOT EXISTS pg_prewarm'); + $originalTableOid = $this->connection->fetchOne( + 'SELECT oid FROM pg_class WHERE pg_class.relname = ?', + [$table], + ); + + $getConflictingOidSql = <<<'SQL' +SELECT objid +FROM pg_depend +JOIN pg_extension as ex on ex.oid = pg_depend.refobjid +WHERE ex.extname = 'pg_prewarm' +ORDER BY objid +LIMIT 1 +SQL; + $conflictingOid = $this->connection->fetchOne($getConflictingOidSql); + + $this->connection->executeStatement( + 'UPDATE pg_attribute SET attrelid = ? WHERE attrelid = ?', + [$conflictingOid, $originalTableOid], + ); + $this->connection->executeStatement( + 'UPDATE pg_description SET objoid = ? WHERE objoid = ?', + [$conflictingOid, $originalTableOid], + ); + $this->connection->executeStatement( + 'UPDATE pg_class SET oid = ? WHERE oid = ?', + [$conflictingOid, $originalTableOid], + ); + + $afterColumns = $this->schemaManager->listTableColumns($table); + + // revert to the database to original state prior to asserting result + $this->connection->executeStatement( + 'UPDATE pg_attribute SET attrelid = ? WHERE attrelid = ?', + [$originalTableOid, $conflictingOid], + ); + $this->connection->executeStatement( + 'UPDATE pg_description SET objoid = ? WHERE objoid = ?', + [$originalTableOid, $conflictingOid], + ); + $this->connection->executeStatement( + 'UPDATE pg_class SET oid = ? WHERE oid = ?', + [$originalTableOid, $conflictingOid], + ); + $this->connection->executeStatement(sprintf('DROP TABLE IF EXISTS %s', $table)); + $this->connection->executeStatement('DROP EXTENSION IF EXISTS pg_prewarm'); + + self::assertArrayHasKey('id', $afterColumns); + } + /** @return iterable */ public static function autoIncrementTypeMigrations(): iterable { diff --git a/tests/Platforms/MariaDB1052PlatformTest.php b/tests/Platforms/MariaDB1052PlatformTest.php new file mode 100644 index 00000000000..e41fe003de8 --- /dev/null +++ b/tests/Platforms/MariaDB1052PlatformTest.php @@ -0,0 +1,54 @@ +method('getServerVersion') ->willReturn('1.2.3'); - $connection = new Connection($driverConnection, new Converter(false, false, 0)); + $connection = new Connection($driverConnection, new Converter(false, false, Converter::CASE_LOWER)); self::assertSame('1.2.3', $connection->getServerVersion()); } @@ -32,7 +32,7 @@ public function testGetNativeConnection(): void $driverConnection->method('getNativeConnection') ->willReturn($nativeConnection); - $connection = new Connection($driverConnection, new Converter(false, false, 0)); + $connection = new Connection($driverConnection, new Converter(false, false, Converter::CASE_LOWER)); self::assertSame($nativeConnection, $connection->getNativeConnection()); } diff --git a/tests/Portability/ConverterTest.php b/tests/Portability/ConverterTest.php index 4192d8b725f..8d57d3bbda6 100644 --- a/tests/Portability/ConverterTest.php +++ b/tests/Portability/ConverterTest.php @@ -7,8 +7,6 @@ use Doctrine\DBAL\Portability\Converter; use PHPUnit\Framework\TestCase; -use const CASE_LOWER; - class ConverterTest extends TestCase { /** @@ -67,8 +65,9 @@ public static function convertNumericProvider(): iterable } /** - * @param array|false $row - * @param array|false $expected + * @param array|false $row + * @param Converter::CASE_LOWER|Converter::CASE_UPPER|null $case + * @param array|false $expected * * @dataProvider convertAssociativeProvider */ @@ -142,7 +141,7 @@ public static function convertAssociativeProvider(): iterable $row, false, false, - CASE_LOWER, + Converter::CASE_LOWER, [ 'foo' => '', 'bar' => 'X ', @@ -153,7 +152,7 @@ public static function convertAssociativeProvider(): iterable $row, false, true, - CASE_LOWER, + Converter::CASE_LOWER, [ 'foo' => '', 'bar' => 'X', @@ -164,7 +163,7 @@ public static function convertAssociativeProvider(): iterable $row, true, false, - CASE_LOWER, + Converter::CASE_LOWER, [ 'foo' => null, 'bar' => 'X ', @@ -175,7 +174,7 @@ public static function convertAssociativeProvider(): iterable $row, true, true, - CASE_LOWER, + Converter::CASE_LOWER, [ 'foo' => null, 'bar' => 'X', @@ -281,8 +280,9 @@ public static function convertAllNumericProvider(): iterable } /** - * @param list> $row - * @param list> $expected + * @param list> $row + * @param Converter::CASE_LOWER|Converter::CASE_UPPER|null $case + * @param list> $expected * * @dataProvider convertAllAssociativeProvider */ @@ -386,7 +386,7 @@ public static function convertAllAssociativeProvider(): iterable $data, false, false, - CASE_LOWER, + Converter::CASE_LOWER, [ [ 'foo' => 'X ', @@ -403,7 +403,7 @@ public static function convertAllAssociativeProvider(): iterable $data, false, true, - CASE_LOWER, + Converter::CASE_LOWER, [ [ 'foo' => 'X', @@ -420,7 +420,7 @@ public static function convertAllAssociativeProvider(): iterable $data, true, false, - CASE_LOWER, + Converter::CASE_LOWER, [ [ 'foo' => 'X ', @@ -437,7 +437,7 @@ public static function convertAllAssociativeProvider(): iterable $data, true, true, - CASE_LOWER, + Converter::CASE_LOWER, [ [ 'foo' => 'X', @@ -504,6 +504,7 @@ public static function convertFirstColumnProvider(): iterable ]; } + /** @param Converter::CASE_LOWER|Converter::CASE_UPPER|null $case */ private function createConverter(bool $convertEmptyStringToNull, bool $rightTrimString, ?int $case): Converter { return new Converter($convertEmptyStringToNull, $rightTrimString, $case);