From b0bfa5e259383fd6c51f043b3361d9ba41132a92 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 28 Jun 2020 08:42:25 -0700 Subject: [PATCH 01/19] Use relative names in inline {@link} annotations where possible --- .../DBAL/Driver/AbstractDB2Driver.php | 2 +- .../DBAL/Driver/AbstractMySQLDriver.php | 2 +- .../DBAL/Driver/AbstractOracleDriver.php | 2 +- .../DBAL/Driver/AbstractPostgreSQLDriver.php | 2 +- .../DBAL/Driver/AbstractSQLAnywhereDriver.php | 2 +- .../DBAL/Driver/AbstractSQLServerDriver.php | 2 +- .../DBAL/Driver/AbstractSQLiteDriver.php | 2 +- .../DBAL/Driver/ExceptionConverterDriver.php | 2 +- lib/Doctrine/DBAL/Driver/ResultStatement.php | 20 +++++++++---------- lib/Doctrine/DBAL/Driver/Statement.php | 4 ++-- .../DBAL/Platforms/AbstractPlatform.php | 3 +-- .../DBAL/Platforms/PostgreSqlPlatform.php | 5 ++--- lib/Doctrine/DBAL/Query/QueryBuilder.php | 2 +- lib/Doctrine/DBAL/SQLParserUtils.php | 2 +- lib/Doctrine/DBAL/Sharding/ShardManager.php | 2 +- lib/Doctrine/DBAL/Types/Type.php | 2 +- 16 files changed, 27 insertions(+), 29 deletions(-) diff --git a/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php b/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php index c6e0565343a..45e29827fdb 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php @@ -8,7 +8,7 @@ use Doctrine\DBAL\Schema\DB2SchemaManager; /** - * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for IBM DB2 based drivers. + * Abstract base implementation of the {@link Driver} interface for IBM DB2 based drivers. */ abstract class AbstractDB2Driver implements Driver { diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index 2fa71494ad2..e31ea3a3ebd 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -18,7 +18,7 @@ use function version_compare; /** - * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for MySQL based drivers. + * Abstract base implementation of the {@link Driver} interface for MySQL based drivers. */ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver { diff --git a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php index dcbaaf097f7..f0429fcbf86 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php @@ -10,7 +10,7 @@ use Doctrine\DBAL\Schema\OracleSchemaManager; /** - * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for Oracle based drivers. + * Abstract base implementation of the {@link Driver} interface for Oracle based drivers. */ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver { diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index 8a02dc225b9..46443a567be 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -19,7 +19,7 @@ use function version_compare; /** - * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for PostgreSQL based drivers. + * Abstract base implementation of the {@link Driver} interface for PostgreSQL based drivers. */ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver { diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php index 2379ae8f5cc..4f5c6a1e4e4 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php @@ -17,7 +17,7 @@ use function version_compare; /** - * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for SAP Sybase SQL Anywhere based drivers. + * Abstract base implementation of the {@link Driver} interface for SAP Sybase SQL Anywhere based drivers. */ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver { diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php index 9cbf25b4b57..57a4189188f 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php @@ -16,7 +16,7 @@ use function version_compare; /** - * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for Microsoft SQL Server based drivers. + * Abstract base implementation of the {@link Driver} interface for Microsoft SQL Server based drivers. */ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDriver { diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php index 13c4a83e909..7ba260b99dd 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php @@ -10,7 +10,7 @@ use function strpos; /** - * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for SQLite based drivers. + * Abstract base implementation of the {@link Driver} interface for SQLite based drivers. */ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver { diff --git a/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php b/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php index 9b79e240c4e..998e1606104 100644 --- a/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php +++ b/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php @@ -11,7 +11,7 @@ interface ExceptionConverterDriver * Converts a given DBAL driver exception into a standardized DBAL driver exception. * * It evaluates the vendor specific error code and SQLSTATE and transforms - * it into a unified {@link Doctrine\DBAL\Exception\DriverException} subclass. + * it into a unified {@link DriverException} subclass. * * @param string $message The DBAL exception message to use. * @param DriverException $exception The DBAL driver exception to convert. diff --git a/lib/Doctrine/DBAL/Driver/ResultStatement.php b/lib/Doctrine/DBAL/Driver/ResultStatement.php index 1e6df0269b8..c05db94fef2 100644 --- a/lib/Doctrine/DBAL/Driver/ResultStatement.php +++ b/lib/Doctrine/DBAL/Driver/ResultStatement.php @@ -29,7 +29,7 @@ public function columnCount(); /** * Sets the fetch mode to use while iterating this statement. * - * @param int $fetchMode The fetch mode must be one of the {@link \Doctrine\DBAL\FetchMode} constants. + * @param int $fetchMode The fetch mode must be one of the {@link FetchMode} constants. * @param mixed $arg2 * @param mixed $arg3 * @@ -41,8 +41,8 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null); * Returns the next row of a result set. * * @param int|null $fetchMode Controls how the next row will be returned to the caller. - * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants, - * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}. + * The value must be one of the {@link FetchMode} constants, + * defaulting to {@link FetchMode::MIXED}. * @param int $cursorOrientation For a ResultStatement object representing a scrollable cursor, * this value determines which row will be returned to the caller. * This value must be one of the \PDO::FETCH_ORI_* constants, @@ -68,19 +68,19 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX * Returns an array containing all of the result set rows. * * @param int|null $fetchMode Controls how the next row will be returned to the caller. - * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants, - * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}. + * The value must be one of the {@link FetchMode} constants, + * defaulting to {@link FetchMode::MIXED}. * @param int|null $fetchArgument This argument has a different meaning depending on the value of the $fetchMode parameter: - * * {@link \Doctrine\DBAL\FetchMode::COLUMN}: + * * {@link FetchMode::COLUMN}: * Returns the indicated 0-indexed column. - * * {@link \Doctrine\DBAL\FetchMode::CUSTOM_OBJECT}: + * * {@link FetchMode::CUSTOM_OBJECT}: * Returns instances of the specified class, mapping the columns of each row * to named properties in the class. - * * \PDO::FETCH_FUNC: Returns the results of calling the specified function, using each row's + * * {@link PDO::FETCH_FUNC}: Returns the results of calling the specified function, using each row's * columns as parameters in the call. * @param mixed[]|null $ctorArgs Controls how the next row will be returned to the caller. - * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants, - * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}. + * The value must be one of the {@link FetchMode} constants, + * defaulting to {@link FetchMode::MIXED}. * * @return mixed[] */ diff --git a/lib/Doctrine/DBAL/Driver/Statement.php b/lib/Doctrine/DBAL/Driver/Statement.php index 6b1e162f529..3e483428980 100644 --- a/lib/Doctrine/DBAL/Driver/Statement.php +++ b/lib/Doctrine/DBAL/Driver/Statement.php @@ -23,7 +23,7 @@ interface Statement extends ResultStatement * this will be a parameter name of the form :name. For a prepared statement * using question mark placeholders, this will be the 1-indexed position of the parameter. * @param mixed $value The value to bind to the parameter. - * @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType} + * @param int $type Explicit data type for the parameter using the {@link ParameterType} * constants. * * @return bool TRUE on success or FALSE on failure. @@ -48,7 +48,7 @@ public function bindValue($param, $value, $type = ParameterType::STRING); * this will be a parameter name of the form :name. For a prepared statement using * question mark placeholders, this will be the 1-indexed position of the parameter. * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. - * @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType} + * @param int $type Explicit data type for the parameter using the {@link ParameterType} * constants. To return an INOUT parameter from a stored procedure, use the bitwise * OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter. * @param int|null $length You must specify maxlength when using an OUT bind diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index bb4a3a569e8..b40e5219412 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -3232,8 +3232,7 @@ public function supportsSchemas() * Whether this platform can emulate schemas. * * Platforms that either support or emulate schemas don't automatically - * filter a schema for the namespaced elements in {@link - * AbstractManager#createSchema}. + * filter a schema for the namespaced elements in {@link AbstractManager::createSchema()}. * * @return bool */ diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php index 7c62d5f8c66..613f426da1d 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -642,9 +642,8 @@ public function getAlterTableSQL(TableDiff $diff) * Checks whether a given column diff is a logically unchanged binary type column. * * Used to determine whether a column alteration for a binary type column can be skipped. - * Doctrine's {@link \Doctrine\DBAL\Types\BinaryType} and {@link \Doctrine\DBAL\Types\BlobType} - * are mapped to the same database column type on this platform as this platform - * does not have a native VARBINARY/BINARY column type. Therefore the {@link \Doctrine\DBAL\Schema\Comparator} + * Doctrine's {@link BinaryType} and {@link BlobType} are mapped to the same database column type on this platform + * as this platform does not have a native VARBINARY/BINARY column type. Therefore the comparator * might detect differences for binary type columns which do not have to be propagated * to database as there actually is no difference at database level. * diff --git a/lib/Doctrine/DBAL/Query/QueryBuilder.php b/lib/Doctrine/DBAL/Query/QueryBuilder.php index 669c1dba7c1..1dca7dbe959 100644 --- a/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -265,7 +265,7 @@ public function getSQL() * * @param string|int $key The parameter position or name. * @param mixed $value The parameter value. - * @param string|int|null $type One of the {@link \Doctrine\DBAL\ParameterType} constants. + * @param string|int|null $type One of the {@link ParameterType} constants. * * @return $this This QueryBuilder instance. */ diff --git a/lib/Doctrine/DBAL/SQLParserUtils.php b/lib/Doctrine/DBAL/SQLParserUtils.php index 7bfe71e4d97..ff9d9a1b4b9 100644 --- a/lib/Doctrine/DBAL/SQLParserUtils.php +++ b/lib/Doctrine/DBAL/SQLParserUtils.php @@ -186,7 +186,7 @@ public static function expandListParameters($query, $params, $types) array_slice($types, 0, $needle), $count ? // array needles are at {@link \Doctrine\DBAL\ParameterType} constants - // + {@link Doctrine\DBAL\Connection::ARRAY_PARAM_OFFSET} + // + {@link \Doctrine\DBAL\Connection::ARRAY_PARAM_OFFSET} array_fill(0, $count, $types[$needle] - Connection::ARRAY_PARAM_OFFSET) : [], array_slice($types, $needle + 1) diff --git a/lib/Doctrine/DBAL/Sharding/ShardManager.php b/lib/Doctrine/DBAL/Sharding/ShardManager.php index 7b37bb2c7e1..e988fdcf95a 100644 --- a/lib/Doctrine/DBAL/Sharding/ShardManager.php +++ b/lib/Doctrine/DBAL/Sharding/ShardManager.php @@ -62,7 +62,7 @@ public function getShards(); * Queries all shards in undefined order and return the results appended to * each other. Restore the previous distribution value after execution. * - * Using {@link \Doctrine\DBAL\Connection::fetchAll} to retrieve rows internally. + * Using {@link Connection::fetchAll()} to retrieve rows internally. * * @param string $sql * @param mixed[] $params diff --git a/lib/Doctrine/DBAL/Types/Type.php b/lib/Doctrine/DBAL/Types/Type.php index 18c893dbcaf..4a0d80ffe55 100644 --- a/lib/Doctrine/DBAL/Types/Type.php +++ b/lib/Doctrine/DBAL/Types/Type.php @@ -277,7 +277,7 @@ public static function overrideType($name, $className) * Gets the (preferred) binding type for values of this type that * can be used when binding parameters to prepared statements. * - * This method should return one of the {@link \Doctrine\DBAL\ParameterType} constants. + * This method should return one of the {@link ParameterType} constants. * * @return int */ From b6a19efc12ca89f65ff2b6c2c97faba84eb21c07 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 28 Jun 2020 10:07:06 -0700 Subject: [PATCH 02/19] Rework detection of loaded PHP extensions in tests --- .../Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php | 8 +++----- .../DBAL/Driver/Mysqli/MysqliConnectionTest.php | 8 +++----- .../Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php | 8 +++----- .../Tests/DBAL/Driver/OCI8/OCI8StatementTest.php | 13 +++---------- .../Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php | 8 +++----- .../SQLAnywhere/SQLAnywhereConnectionTest.php | 8 +++----- .../DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php | 8 +++----- .../DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php | 8 +++----- .../Functional/Driver/IBMDB2/DB2StatementTest.php | 8 +++----- .../Functional/Driver/Mysqli/ConnectionTest.php | 8 +++----- .../DBAL/Functional/Driver/Mysqli/DriverTest.php | 8 +++----- .../DBAL/Functional/Driver/OCI8/DriverTest.php | 8 +++----- .../Functional/Driver/OCI8/OCI8ConnectionTest.php | 8 +++----- .../DBAL/Functional/Driver/OCI8/StatementTest.php | 8 +++----- .../DBAL/Functional/Driver/PDOConnectionTest.php | 8 +++----- .../DBAL/Functional/Driver/PDOMySql/DriverTest.php | 8 +++----- .../DBAL/Functional/Driver/PDOOracle/DriverTest.php | 8 +++----- .../DBAL/Functional/Driver/PDOPgSql/DriverTest.php | 8 +++----- .../Functional/Driver/PDOPgsqlConnectionTest.php | 8 +++----- .../DBAL/Functional/Driver/PDOSqlite/DriverTest.php | 8 +++----- .../DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php | 8 +++----- .../Driver/SQLAnywhere/ConnectionTest.php | 8 +++----- .../Functional/Driver/SQLAnywhere/DriverTest.php | 8 +++----- .../Functional/Driver/SQLAnywhere/StatementTest.php | 8 +++----- .../DBAL/Functional/Driver/SQLSrv/DriverTest.php | 8 +++----- .../DBAL/Functional/Driver/SQLSrv/StatementTest.php | 8 +++----- .../Tests/DBAL/Functional/PDOStatementTest.php | 8 +++----- 27 files changed, 81 insertions(+), 140 deletions(-) diff --git a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php index cf2db940b33..2f07209b1bc 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php @@ -5,8 +5,10 @@ use Doctrine\DBAL\Driver\IBMDB2\DB2Connection; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; -use function extension_loaded; +/** + * @requires extension ibm_db2 + */ class DB2ConnectionTest extends DbalTestCase { /** @@ -18,10 +20,6 @@ class DB2ConnectionTest extends DbalTestCase protected function setUp() : void { - if (! extension_loaded('ibm_db2')) { - $this->markTestSkipped('ibm_db2 is not installed.'); - } - parent::setUp(); $this->connectionMock = $this->getMockBuilder(DB2Connection::class) diff --git a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php index 5e4b43aff8c..517332f71c1 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php @@ -7,10 +7,12 @@ use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\Tests\DbalFunctionalTestCase; use PHPUnit\Framework\MockObject\MockObject; -use function extension_loaded; use function restore_error_handler; use function set_error_handler; +/** + * @requires extension mysqli + */ class MysqliConnectionTest extends DbalFunctionalTestCase { /** @@ -22,10 +24,6 @@ class MysqliConnectionTest extends DbalFunctionalTestCase protected function setUp() : void { - if (! extension_loaded('mysqli')) { - $this->markTestSkipped('mysqli is not installed.'); - } - parent::setUp(); if (! $this->connection->getDatabasePlatform() instanceof MySqlPlatform) { diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php index 4c3868f4a95..d953613a5a4 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php @@ -5,8 +5,10 @@ use Doctrine\DBAL\Driver\OCI8\OCI8Connection; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; -use function extension_loaded; +/** + * @requires extension oci8 + */ class OCI8ConnectionTest extends DbalTestCase { /** @@ -18,10 +20,6 @@ class OCI8ConnectionTest extends DbalTestCase protected function setUp() : void { - if (! extension_loaded('oci8')) { - $this->markTestSkipped('oci8 is not installed.'); - } - parent::setUp(); $this->connectionMock = $this->getMockBuilder(OCI8Connection::class) diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php index f90f86d6eb3..8141b61348f 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php @@ -7,19 +7,12 @@ use Doctrine\DBAL\Driver\OCI8\OCI8Statement; use Doctrine\Tests\DbalTestCase; use ReflectionProperty; -use function extension_loaded; +/** + * @requires extension oci8 + */ class OCI8StatementTest extends DbalTestCase { - protected function setUp() : void - { - if (! extension_loaded('oci8')) { - $this->markTestSkipped('oci8 is not installed.'); - } - - parent::setUp(); - } - /** * This scenario shows that when the first parameter is not null * it properly sets $hasZeroIndex to 1 and calls bindValue starting at 1. diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php index 9ed9a06aa5b..c8c3b92b017 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php @@ -5,8 +5,10 @@ use Doctrine\DBAL\Driver\PDOException; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; -use function extension_loaded; +/** + * @requires extension pdo + */ class PDOExceptionTest extends DbalTestCase { public const ERROR_CODE = 666; @@ -31,10 +33,6 @@ class PDOExceptionTest extends DbalTestCase protected function setUp() : void { - if (! extension_loaded('PDO')) { - $this->markTestSkipped('PDO is not installed.'); - } - parent::setUp(); $this->wrappedException = new \PDOException(self::MESSAGE, self::SQLSTATE); diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php index effeb483362..72e5e25ec4f 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php @@ -5,8 +5,10 @@ use Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereConnection; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; -use function extension_loaded; +/** + * @requires extension sqlanywhere + */ class SQLAnywhereConnectionTest extends DbalTestCase { /** @@ -18,10 +20,6 @@ class SQLAnywhereConnectionTest extends DbalTestCase protected function setUp() : void { - if (! extension_loaded('sqlanywhere')) { - $this->markTestSkipped('sqlanywhere is not installed.'); - } - parent::setUp(); $this->connectionMock = $this->getMockBuilder(SQLAnywhereConnection::class) diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php index 8d457d8eb23..ecac3f60d91 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php @@ -5,7 +5,6 @@ use Doctrine\DBAL\Driver\SQLSrv\SQLSrvConnection; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; -use function extension_loaded; class SQLSrvConnectionTest extends DbalTestCase { @@ -16,12 +15,11 @@ class SQLSrvConnectionTest extends DbalTestCase */ private $connectionMock; + /** + * @requires extension sqlsrv + */ protected function setUp() : void { - if (! extension_loaded('sqlsrv')) { - $this->markTestSkipped('sqlsrv is not installed.'); - } - parent::setUp(); $this->connectionMock = $this->getMockBuilder(SQLSrvConnection::class) diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php index b029cabba31..9f66e1a577f 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php @@ -5,16 +5,14 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; -use function extension_loaded; +/** + * @requires extension ibm_db2 + */ class DB2DriverTest extends AbstractDriverTest { protected function setUp() : void { - if (! extension_loaded('ibm_db2')) { - $this->markTestSkipped('ibm_db2 is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof DB2Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php index c839d20d916..b17e39b7576 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php @@ -7,16 +7,14 @@ use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; use Doctrine\Tests\DbalFunctionalTestCase; use PHPUnit\Framework\Error\Notice; -use function extension_loaded; +/** + * @requires extension ibm_db2 + */ class DB2StatementTest extends DbalFunctionalTestCase { protected function setUp() : void { - if (! extension_loaded('ibm_db2')) { - $this->markTestSkipped('ibm_db2 is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof DB2Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php index a104b5a0b7c..1c30241adda 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php @@ -7,17 +7,15 @@ use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\TestUtil; -use function extension_loaded; use const MYSQLI_OPT_CONNECT_TIMEOUT; +/** + * @requires extension mysqli + */ class ConnectionTest extends DbalFunctionalTestCase { protected function setUp() : void { - if (! extension_loaded('mysqli')) { - $this->markTestSkipped('mysqli is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php index 549535be6ee..58b74e3f5a7 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php @@ -5,16 +5,14 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\Mysqli\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; -use function extension_loaded; +/** + * @requires extension mysqli + */ class DriverTest extends AbstractDriverTest { protected function setUp() : void { - if (! extension_loaded('mysqli')) { - $this->markTestSkipped('mysqli is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php index bf587cab186..28ac0698004 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php @@ -5,16 +5,14 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\OCI8\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; -use function extension_loaded; +/** + * @requires extension oci8 + */ class DriverTest extends AbstractDriverTest { protected function setUp() : void { - if (! extension_loaded('oci8')) { - $this->markTestSkipped('oci8 is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php index d6184316fac..f5b0cc95e9d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php @@ -6,8 +6,10 @@ use Doctrine\DBAL\Driver\OCI8\OCI8Connection; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; -use function extension_loaded; +/** + * @requires extension oci8 + */ class OCI8ConnectionTest extends DbalFunctionalTestCase { /** @var OCI8Connection */ @@ -15,10 +17,6 @@ class OCI8ConnectionTest extends DbalFunctionalTestCase protected function setUp() : void { - if (! extension_loaded('oci8')) { - $this->markTestSkipped('oci8 is not installed.'); - } - parent::setUp(); if (! $this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php index 70f829e7b71..9cf08f942e2 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php @@ -4,16 +4,14 @@ use Doctrine\DBAL\Driver\OCI8\Driver; use Doctrine\Tests\DbalFunctionalTestCase; -use function extension_loaded; +/** + * @requires extension oci8 + */ class StatementTest extends DbalFunctionalTestCase { protected function setUp() : void { - if (! extension_loaded('oci8')) { - $this->markTestSkipped('oci8 is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php index 6dfb1b85c3d..7d22a091ed7 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php @@ -9,10 +9,12 @@ use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSRVDriver; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; -use function extension_loaded; use function get_class; use function sprintf; +/** + * @requires extension pdo + */ class PDOConnectionTest extends DbalFunctionalTestCase { /** @@ -24,10 +26,6 @@ class PDOConnectionTest extends DbalFunctionalTestCase protected function setUp() : void { - if (! extension_loaded('PDO')) { - $this->markTestSkipped('PDO is not installed.'); - } - parent::setUp(); $this->driverConnection = $this->connection->getWrappedConnection(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php index 641f515c7ec..aede96dfa32 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php @@ -5,16 +5,14 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\PDOMySql\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; -use function extension_loaded; +/** + * @requires extension pdo_mysql + */ class DriverTest extends AbstractDriverTest { protected function setUp() : void { - if (! extension_loaded('pdo_mysql')) { - $this->markTestSkipped('pdo_mysql is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php index f33c6669865..84588f0a778 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php @@ -5,16 +5,14 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\PDOOracle\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; -use function extension_loaded; +/** + * @requires extension pdo_oci + */ class DriverTest extends AbstractDriverTest { protected function setUp() : void { - if (! extension_loaded('PDO_OCI')) { - $this->markTestSkipped('PDO_OCI is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php index 638e855c970..c7131b7b3c6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php @@ -8,18 +8,16 @@ use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use Doctrine\Tests\TestUtil; use function array_key_exists; -use function extension_loaded; use function microtime; use function sprintf; +/** + * @requires extension pdo_pgsql + */ class DriverTest extends AbstractDriverTest { protected function setUp() : void { - if (! extension_loaded('pdo_pgsql')) { - $this->markTestSkipped('pdo_pgsql is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php index 8336a3900d1..f7575c694aa 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php @@ -6,16 +6,14 @@ use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\Tests\DbalFunctionalTestCase; -use function extension_loaded; +/** + * @requires extension pdo_pgsql + */ class PDOPgsqlConnectionTest extends DbalFunctionalTestCase { protected function setUp() : void { - if (! extension_loaded('pdo_pgsql')) { - $this->markTestSkipped('pdo_pgsql is not loaded.'); - } - parent::setUp(); if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php index 295831b8bf4..2548b463a8d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php @@ -5,16 +5,14 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\PDOSqlite\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; -use function extension_loaded; +/** + * @requires extension pdo_sqlite + */ class DriverTest extends AbstractDriverTest { protected function setUp() : void { - if (! extension_loaded('pdo_sqlite')) { - $this->markTestSkipped('pdo_sqlite is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php index 2725e3eb301..de156ec8b5c 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php @@ -8,16 +8,14 @@ use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use Doctrine\Tests\TestUtil; use PDO; -use function extension_loaded; +/** + * @requires extension pdo_sqlsrv + */ class DriverTest extends AbstractDriverTest { protected function setUp() : void { - if (! extension_loaded('pdo_sqlsrv')) { - $this->markTestSkipped('pdo_sqlsrv is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php index 4de7b7cde03..bb27cb80b27 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php @@ -5,16 +5,14 @@ use Doctrine\DBAL\Driver\SQLAnywhere\Driver; use Doctrine\DBAL\DriverManager; use Doctrine\Tests\DbalFunctionalTestCase; -use function extension_loaded; +/** + * @requires extension sqlanywhere + */ class ConnectionTest extends DbalFunctionalTestCase { protected function setUp() : void { - if (! extension_loaded('sqlanywhere')) { - $this->markTestSkipped('sqlanywhere is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php index 960acfc003c..1f239286891 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php @@ -6,16 +6,14 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\SQLAnywhere\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; -use function extension_loaded; +/** + * @requires extension sqlanywhere + */ class DriverTest extends AbstractDriverTest { protected function setUp() : void { - if (! extension_loaded('sqlanywhere')) { - $this->markTestSkipped('sqlanywhere is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php index c09eb0a5d56..aa718d6149a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php @@ -5,16 +5,14 @@ use Doctrine\DBAL\Driver\SQLAnywhere\Driver; use Doctrine\DBAL\DriverManager; use Doctrine\Tests\DbalFunctionalTestCase; -use function extension_loaded; +/** + * @requires extension sqlanywhere + */ class StatementTest extends DbalFunctionalTestCase { protected function setUp() : void { - if (! extension_loaded('sqlanywhere')) { - $this->markTestSkipped('sqlanywhere is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php index de8b37cb683..2dcc90f034c 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php @@ -5,16 +5,14 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\SQLSrv\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; -use function extension_loaded; +/** + * @requires extension sqlsrv + */ class DriverTest extends AbstractDriverTest { protected function setUp() : void { - if (! extension_loaded('sqlsrv')) { - $this->markTestSkipped('sqlsrv is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php index 29df5aea958..b6a7864e6f1 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php @@ -5,16 +5,14 @@ use Doctrine\DBAL\Driver\SQLSrv\Driver; use Doctrine\DBAL\Driver\SQLSrv\SQLSrvException; use Doctrine\Tests\DbalFunctionalTestCase; -use function extension_loaded; +/** + * @requires extension sqlsrv + */ class StatementTest extends DbalFunctionalTestCase { protected function setUp() : void { - if (! extension_loaded('sqlsrv')) { - self::markTestSkipped('sqlsrv is not installed.'); - } - parent::setUp(); if ($this->connection->getDriver() instanceof Driver) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php index 2ea5fa49284..51f1da91157 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php @@ -6,16 +6,14 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; -use function extension_loaded; +/** + * @requires extension pdo + */ class PDOStatementTest extends DbalFunctionalTestCase { protected function setUp() : void { - if (! extension_loaded('pdo')) { - $this->markTestSkipped('PDO is not installed'); - } - parent::setUp(); if (! $this->connection->getWrappedConnection() instanceof PDOConnection) { From 4dc7b9ed84dea1a659e38c47c916c063152a80f3 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 28 Jun 2020 10:09:01 -0700 Subject: [PATCH 03/19] Remove an always skipped test for unsupported driver --- .../Schema/SqliteSchemaManagerTest.php | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php index b4008191230..74c79393737 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php @@ -9,11 +9,7 @@ use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; -use SQLite3; -use function array_map; use function dirname; -use function extension_loaded; -use function version_compare; class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase { @@ -159,34 +155,6 @@ public function testListTableWithBinary() : void self::assertFalse($table->getColumn('column_binary')->getFixed()); } - public function testNonDefaultPKOrder() : void - { - if (! extension_loaded('sqlite3')) { - $this->markTestSkipped('This test requires the SQLite3 extension.'); - } - - $version = SQLite3::version(); - if (version_compare($version['versionString'], '3.7.16', '<')) { - $this->markTestSkipped('This version of sqlite doesn\'t return the order of the Primary Key.'); - } - - $this->connection->exec(<<schemaManager->listTableIndexes('non_default_pk_order'); - - self::assertCount(1, $tableIndexes); - - self::assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.'); - self::assertEquals(['other_id', 'id'], array_map('strtolower', $tableIndexes['primary']->getColumns())); - } - /** * @group DBAL-1779 */ From 0231c36cb8ea6f3dc3efa9f713e82fa8b90f0864 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 29 Jun 2020 09:52:11 -0700 Subject: [PATCH 04/19] Restore the PortWithoutHost exception parent class --- .../AbstractSQLServerDriver/Exception/PortWithoutHost.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php index ea8dcc461e5..c6dbf34bbd1 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php @@ -4,14 +4,14 @@ namespace Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception; -use Doctrine\DBAL\Driver\AbstractException; +use Doctrine\DBAL\Driver\AbstractDriverException; /** * @internal * * @psalm-immutable */ -final class PortWithoutHost extends AbstractException +final class PortWithoutHost extends AbstractDriverException { public static function new(): self { From e48d65df95cd9ef4865e01bcf690601cd6b84365 Mon Sep 17 00:00:00 2001 From: Semih Serhat Karakaya Date: Thu, 25 Jun 2020 06:04:23 -0700 Subject: [PATCH 05/19] respect to platform restrictions when creating an identfier name for oracle --- .../DBAL/Platforms/OraclePlatform.php | 20 +++++++++-- .../Platform/PlatformRestrictionsTest.php | 33 +++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/Doctrine/Tests/DBAL/Functional/Platform/PlatformRestrictionsTest.php diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index 1c21e219010..2f7d789584a 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -586,6 +586,22 @@ private function normalizeIdentifier($name) return $identifier->isQuoted() ? $identifier : new Identifier(strtoupper($name)); } + /** + * Adds suffix to identifier, + * + * if the new string exceeds max identifier length, + * keeps $suffix, cuts from $identifier as much as the part exceeding. + */ + private function addSuffix(string $identifier, string $suffix) : string + { + $maxPossibleLengthWithoutSuffix = $this->getMaxIdentifierLength() - strlen($suffix); + if (strlen($identifier) > $maxPossibleLengthWithoutSuffix) { + $identifier = substr($identifier, 0, $maxPossibleLengthWithoutSuffix); + } + + return $identifier . $suffix; + } + /** * Returns the autoincrement primary key identifier name for the given table identifier. * @@ -598,7 +614,7 @@ private function normalizeIdentifier($name) */ private function getAutoincrementIdentifierName(Identifier $table) { - $identifierName = $table->getName() . '_AI_PK'; + $identifierName = $this->addSuffix($table->getName(), '_AI_PK'); return $table->isQuoted() ? $this->quoteSingleIdentifier($identifierName) @@ -966,7 +982,7 @@ public function getIdentitySequenceName($tableName, $columnName) $table = new Identifier($tableName); // No usage of column name to preserve BC compatibility with <2.5 - $identitySequenceName = $table->getName() . '_SEQ'; + $identitySequenceName = $this->addSuffix($table->getName(), '_SEQ'); if ($table->isQuoted()) { $identitySequenceName = '"' . $identitySequenceName . '"'; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/PlatformRestrictionsTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/PlatformRestrictionsTest.php new file mode 100644 index 00000000000..5f6deefe3ba --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/PlatformRestrictionsTest.php @@ -0,0 +1,33 @@ +connection->getDatabasePlatform(); + $tableName = str_repeat('x', $platform->getMaxIdentifierLength()); + $columnName = str_repeat('y', $platform->getMaxIdentifierLength()); + $table = new Table($tableName); + $table->addColumn($columnName, 'integer', ['autoincrement' => true]); + $table->setPrimaryKey([$columnName]); + $this->connection->getSchemaManager()->dropAndCreateTable($table); + $createdTable = $this->connection->getSchemaManager()->listTableDetails($tableName); + + $this->assertTrue($createdTable->hasColumn($columnName)); + $this->assertTrue($createdTable->hasPrimaryKey()); + } +} From 20ec5d824a3091d38eeda159bd38c8a124bd1d95 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 29 Jun 2020 10:27:31 -0700 Subject: [PATCH 06/19] Deprecate AbstractPlatform::fixSchemaElementName() --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Platforms/AbstractPlatform.php | 2 ++ lib/Doctrine/DBAL/Platforms/OraclePlatform.php | 2 ++ 3 files changed, 8 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 10eb5e062d5..d8cf618481d 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## `AbstractPlatform::fixSchemaElementName()` is deprecated. + +The method is not used anywhere except for tests. + ##`ServerInfoAwareConnection::requiresQueryForServerVersion()` is deprecated. The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been deprecated as an implementation detail which is the same for almost all supported drivers. diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index 38d934550d3..007bd723a42 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -3478,6 +3478,8 @@ public function getSQLResultCasing($column) * Makes any fixes to a name of a schema element (table, sequence, ...) that are required * by restrictions of the platform, like a maximum length. * + * @deprecated + * * @param string $schemaElementName * * @return string diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index b0cdce3f03f..ddf07adc1e2 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -1075,6 +1075,8 @@ public function getTimeFormatString() /** * {@inheritDoc} + * + * @deprecated */ public function fixSchemaElementName($schemaElementName) { From dacd4baacb9e5c53ed175daffc24022b61894ad2 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 29 Jun 2020 10:34:19 -0700 Subject: [PATCH 07/19] Fix base class alias in PDOSqlsrv\Connection --- lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index a05f5898b22..8e36d2f1501 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; -use Doctrine\DBAL\Driver\PDO\Connection as BaseStatement; +use Doctrine\DBAL\Driver\PDO\Connection as BaseConnection; use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\ParameterType; use PDO; @@ -14,7 +14,7 @@ /** * Sqlsrv Connection implementation. */ -class Connection extends BaseStatement +class Connection extends BaseConnection { /** * {@inheritdoc} From 54b04e3380c1719a2bf89ffc36c1bf4da77f6a27 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 29 Jun 2020 13:31:52 -0700 Subject: [PATCH 08/19] Fix reference to the class recommended instead of PDOException --- lib/Doctrine/DBAL/Driver/PDOException.php | 2 ++ phpcs.xml.dist | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/Doctrine/DBAL/Driver/PDOException.php b/lib/Doctrine/DBAL/Driver/PDOException.php index e82bcbcfc6b..b2c01eb4430 100644 --- a/lib/Doctrine/DBAL/Driver/PDOException.php +++ b/lib/Doctrine/DBAL/Driver/PDOException.php @@ -2,6 +2,8 @@ namespace Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\PDO\Exception; + /** * @deprecated Use {@link Exception} instead * diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 534b91cec44..768e383c47d 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -103,6 +103,7 @@ lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php + lib/Doctrine/DBAL/Driver/PDOException.php From af7644edf7e418935b3042fecc106a6557e8dc48 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 1 Jul 2020 16:20:56 -0700 Subject: [PATCH 09/19] DBALException::invalidPlatformType() is unused as of v2.7.0 --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/DBALException.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index d8cf618481d..848662992de 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## `DBALException` factory method deprecations + +1. `DBALException::invalidPlatformType()` is deprecated as unused as of v2.7.0. + ## `AbstractPlatform::fixSchemaElementName()` is deprecated. The method is not used anywhere except for tests. diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php index 9a85c110bb8..65f6298b5fe 100644 --- a/lib/Doctrine/DBAL/DBALException.php +++ b/lib/Doctrine/DBAL/DBALException.php @@ -38,6 +38,9 @@ public static function notSupported($method) return new self(sprintf("Operation '%s' is not supported by platform.", $method)); } + /** + * @deprecated Use {@link invalidPlatformType()} instead. + */ public static function invalidPlatformSpecified(): self { return new self( From 0fe1dc4ba0cc8c62fabb9055e645d6ed325d9d61 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 1 Jul 2020 16:24:51 -0700 Subject: [PATCH 10/19] The usage of user-provided PDO instance is deprecated as of v2.10.0 --- UPGRADE.md | 1 + lib/Doctrine/DBAL/DBALException.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 848662992de..9898e669d57 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -3,6 +3,7 @@ ## `DBALException` factory method deprecations 1. `DBALException::invalidPlatformType()` is deprecated as unused as of v2.7.0. +2. `DBALException::invalidPdoInstance()` as passing a PDO instance via configuration is deprecated. ## `AbstractPlatform::fixSchemaElementName()` is deprecated. diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php index 65f6298b5fe..18ca800f330 100644 --- a/lib/Doctrine/DBAL/DBALException.php +++ b/lib/Doctrine/DBAL/DBALException.php @@ -93,6 +93,8 @@ public static function invalidPlatformVersionSpecified($version, $expectedFormat } /** + * @deprecated Passing a PDO instance in connection parameters is deprecated. + * * @return DBALException */ public static function invalidPdoInstance() From ad96ce289bdc10a110fdab58dee2f34bf83a0a07 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 2 Jul 2020 11:58:06 -0700 Subject: [PATCH 11/19] Deprecate driver exception conversion APIs --- UPGRADE.md | 10 ++++++---- lib/Doctrine/DBAL/DBALException.php | 4 ++++ lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php | 5 +++-- 8 files changed, 23 insertions(+), 6 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 9898e669d57..ad04122bd99 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,11 @@ # Upgrade to 2.11 +## Deprecations in driver-level exception handling + +1. The `ExceptionConverterDriver` interface and the usage of the `convertException()` method on the `Driver` objects are deprecated. +2. The `driverException()` and `driverExceptionDuringQuery()` factory methods of the `DBALException` class are deprecated. +3. Relying on the wrapper layer handling non-driver exceptions is deprecated. + ## `DBALException` factory method deprecations 1. `DBALException::invalidPlatformType()` is deprecated as unused as of v2.7.0. @@ -21,10 +27,6 @@ The driver and wrapper statement objects can be only created by the correspondin The wrapper connection will automatically handle the lost connection if the driver supports reporting it. -## The `ExceptionConverterDriver` interface is deprecated - -All drivers will have to implement the exception conversion API. - ## `DriverException::getErrorCode()` is deprecated The `DriverException::getErrorCode()` is deprecated as redundant and inconsistently supported by drivers. Use `::getCode()` or `::getSQLState()` instead. diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php index 18ca800f330..c7ad96be0fd 100644 --- a/lib/Doctrine/DBAL/DBALException.php +++ b/lib/Doctrine/DBAL/DBALException.php @@ -139,6 +139,8 @@ public static function unknownDriver($unknownDriverName, array $knownDrivers) } /** + * @deprecated + * * @param string $sql * @param mixed[] $params * @@ -157,6 +159,8 @@ public static function driverExceptionDuringQuery(Driver $driver, Throwable $dri } /** + * @deprecated + * * @return self */ public static function driverException(Driver $driver, Throwable $driverEx) diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index c54da20fd75..7fd77aa5c51 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -39,6 +39,8 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, /** * {@inheritdoc} * + * @deprecated + * * @link https://dev.mysql.com/doc/refman/8.0/en/client-error-reference.html * @link https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html */ diff --git a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php index b3b58e58db6..be5826659d5 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php @@ -26,6 +26,8 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver { /** * {@inheritdoc} + * + * @deprecated */ public function convertException($message, DeprecatedDriverException $exception) { diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index bf0ac0d2a5f..2653746eb9b 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -38,6 +38,8 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri /** * {@inheritdoc} * + * @deprecated + * * @link http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html */ public function convertException($message, DeprecatedDriverException $exception) diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php index 52ecd4bcef2..668f765e1ca 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php @@ -37,6 +37,8 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr /** * {@inheritdoc} * + * @deprecated + * * @link http://dcx.sybase.com/index.html#sa160/en/saerrors/sqlerror.html */ public function convertException($message, DeprecatedDriverException $exception) diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php index f0cf8433e3d..2e7f640541b 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php @@ -30,6 +30,8 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver /** * {@inheritdoc} * + * @deprecated + * * @link http://www.sqlite.org/c3ref/c_abort.html */ public function convertException($message, DeprecatedDriverException $exception) diff --git a/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php b/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php index 7137fcf3aa2..19428cf94b1 100644 --- a/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php +++ b/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php @@ -2,14 +2,13 @@ namespace Doctrine\DBAL\Driver; -use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as TheDriverException; use Doctrine\DBAL\Exception\DriverException; /** * Contract for a driver that is capable of converting DBAL driver exceptions into standardized DBAL driver exceptions. * - * @deprecated All implementors of the {@link Driver} interface will have to implement this API. + * @deprecated */ interface ExceptionConverterDriver { @@ -19,6 +18,8 @@ interface ExceptionConverterDriver * It evaluates the vendor specific error code and SQLSTATE and transforms * it into a unified {@link DriverException} subclass. * + * @deprecated + * * @param string $message The DBAL exception message to use. * @param TheDriverException $exception The DBAL driver exception to convert. * From 3b44f5594e943be32e53ce8ca79ae168be8559ca Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 2 Jul 2020 18:48:07 -0700 Subject: [PATCH 12/19] Mark connection constructors internal --- UPGRADE.md | 6 ++++-- lib/Doctrine/DBAL/Connection.php | 2 ++ lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php | 2 ++ .../DBAL/Connections/PrimaryReadReplicaConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php | 2 ++ lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php | 2 ++ lib/Doctrine/DBAL/Driver/PDOConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php | 2 ++ .../DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php | 2 ++ lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php | 2 ++ 12 files changed, 26 insertions(+), 2 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index ad04122bd99..df5f752f7c4 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -19,9 +19,11 @@ The method is not used anywhere except for tests. The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been deprecated as an implementation detail which is the same for almost all supported drivers. -## Statement constructors are marked internal +## Connection and Statement constructors are marked internal -The driver and wrapper statement objects can be only created by the corresponding connection objects. +1. Driver connection objects can be only created by the corresponding drivers. +2. Wrapper connection objects can be only created by the driver manager. +3. The driver and wrapper connection objects can be only created by the corresponding connection objects. ## The `PingableConnection` interface is deprecated diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 33a38ab9dcc..29eda274608 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -168,6 +168,8 @@ class Connection implements DriverConnection /** * Initializes a new instance of the Connection class. * + * @internal The connection can be only instantiated by the driver manager. + * * @param mixed[] $params The connection parameters. * @param Driver $driver The driver to use. * @param Configuration|null $config The configuration, optional. diff --git a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php index 39b0c6165d5..156753457d6 100644 --- a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php +++ b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php @@ -20,6 +20,8 @@ class MasterSlaveConnection extends PrimaryReadReplicaConnection /** * Creates Primary Replica Connection. * + * @internal The connection can be only instantiated by the driver manager. + * * @param mixed[] $params * * @throws InvalidArgumentException diff --git a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php index cb78b69c451..86aad20d14b 100644 --- a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php +++ b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php @@ -90,6 +90,8 @@ class PrimaryReadReplicaConnection extends Connection /** * Creates Primary Replica Connection. * + * @internal The connection can be only instantiated by the driver manager. + * * @param mixed[] $params * * @throws InvalidArgumentException diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php index 655bbb39d4c..8beef436b2e 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php @@ -40,6 +40,8 @@ class DB2Connection implements ConnectionInterface, ServerInfoAwareConnection private $conn = null; /** + * @internal The connection can be only instantiated by its driver. + * * @param mixed[] $params * @param string $username * @param string $password diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index 2e8dd185013..de009d4ed32 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -46,6 +46,8 @@ class MysqliConnection implements ConnectionInterface, PingableConnection, Serve private $conn; /** + * @internal The connection can be only instantiated by its driver. + * * @param mixed[] $params * @param string $username * @param string $password diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index 2ee1e365fc3..7a56b6e1a56 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -41,6 +41,8 @@ class OCI8Connection implements ConnectionInterface, ServerInfoAwareConnection /** * Creates a Connection to an Oracle Database using oci8 extension. * + * @internal The connection can be only instantiated by its driver. + * * @param string $username * @param string $password * @param string $db diff --git a/lib/Doctrine/DBAL/Driver/PDOConnection.php b/lib/Doctrine/DBAL/Driver/PDOConnection.php index 9e124e528bc..4f72e820b77 100644 --- a/lib/Doctrine/DBAL/Driver/PDOConnection.php +++ b/lib/Doctrine/DBAL/Driver/PDOConnection.php @@ -22,6 +22,8 @@ class PDOConnection extends PDO implements ConnectionInterface, ServerInfoAwareConnection { /** + * @internal The connection can be only instantiated by its driver. + * * @param string $dsn * @param string|null $user * @param string|null $password diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index 8e36d2f1501..d0262dcf6a7 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -17,6 +17,8 @@ class Connection extends BaseConnection { /** + * @internal The connection can be only instantiated by its driver. + * * {@inheritdoc} */ public function __construct($dsn, $user = null, $password = null, ?array $options = null) diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php index b56fd61ff2d..cee7447129d 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php @@ -36,6 +36,8 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection /** * Connects to database with given connection string. * + * @internal The connection can be only instantiated by its driver. + * * @param string $dsn The connection string. * @param bool $persistent Whether or not to establish a persistent connection. * diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php index 10095cde411..de783309883 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php @@ -39,6 +39,8 @@ class SQLSrvConnection implements ConnectionInterface, ServerInfoAwareConnection protected $lastInsertId; /** + * @internal The connection can be only instantiated by its driver. + * * @param string $serverName * @param mixed[] $connectionOptions * diff --git a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php index 8c20139ac42..db81e381c85 100644 --- a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php +++ b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php @@ -65,6 +65,8 @@ class PoolingShardConnection extends Connection /** * {@inheritDoc} * + * @internal The connection can be only instantiated by the driver manager. + * * @throws InvalidArgumentException */ public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null) From f5714c57449744b6c248986d1196eff303ffb1bd Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 2 Jul 2020 18:48:53 -0700 Subject: [PATCH 13/19] Mark LastInsertId internal --- UPGRADE.md | 2 ++ lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index df5f752f7c4..41c0bd1b026 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -25,6 +25,8 @@ The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been 2. Wrapper connection objects can be only created by the driver manager. 3. The driver and wrapper connection objects can be only created by the corresponding connection objects. +Additionally, the `SQLSrv\LastInsertId` class has been marked internal. + ## The `PingableConnection` interface is deprecated The wrapper connection will automatically handle the lost connection if the driver supports reporting it. diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php b/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php index 94c19f6effc..9406c425a1f 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php @@ -4,6 +4,8 @@ /** * Last Id Data Container. + * + * @internal */ class LastInsertId { From 67d6bb0395d3e3e1aadfd23f5658a2a846266dfd Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 2 Jul 2020 18:30:55 -0700 Subject: [PATCH 14/19] Deprecate classes in Driver\PDO* namespaces --- UPGRADE.md | 12 +++++ lib/Doctrine/DBAL/Driver/PDO/MySQL/Driver.php | 9 ++++ lib/Doctrine/DBAL/Driver/PDO/OCI/Driver.php | 9 ++++ lib/Doctrine/DBAL/Driver/PDO/PgSQL/Driver.php | 9 ++++ .../DBAL/Driver/PDO/SQLSrv/Connection.php | 9 ++++ .../DBAL/Driver/PDO/SQLSrv/Driver.php | 9 ++++ .../DBAL/Driver/PDO/SQLSrv/Statement.php | 9 ++++ .../DBAL/Driver/PDO/SQLite/Driver.php | 9 ++++ lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php | 6 ++- lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php | 6 ++- lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php | 13 ++--- lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php | 6 ++- .../DBAL/Driver/PDOSqlsrv/Connection.php | 9 ++-- lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php | 5 +- .../DBAL/Driver/PDOSqlsrv/Statement.php | 9 ++-- lib/Doctrine/DBAL/DriverManager.php | 47 +++++++++---------- tests/Doctrine/Tests/DBAL/ConnectionTest.php | 2 +- .../Tests/DBAL/Driver/PDOMySql/DriverTest.php | 2 +- .../DBAL/Driver/PDOOracle/DriverTest.php | 2 +- .../Tests/DBAL/Driver/PDOPgSql/DriverTest.php | 2 +- .../DBAL/Driver/PDOSqlite/DriverTest.php | 2 +- .../DBAL/Driver/PDOSqlsrv/DriverTest.php | 2 +- .../Doctrine/Tests/DBAL/DriverManagerTest.php | 16 +++---- .../Tests/DBAL/Functional/BlobTest.php | 4 +- .../Tests/DBAL/Functional/DataAccessTest.php | 4 +- .../Functional/Driver/PDO/ConnectionTest.php | 10 ++-- .../Functional/Driver/PDOMySql/DriverTest.php | 2 +- .../Driver/PDOOracle/DriverTest.php | 2 +- .../Functional/Driver/PDOPgSql/DriverTest.php | 2 +- .../Driver/PDOSqlite/DriverTest.php | 2 +- .../Driver/PDOSqlsrv/DriverTest.php | 2 +- .../Tests/DBAL/Functional/StatementTest.php | 10 ++-- .../DBAL/Functional/TypeConversionTest.php | 4 +- .../DBAL/Functional/Types/BinaryTest.php | 4 +- 34 files changed, 166 insertions(+), 84 deletions(-) create mode 100644 lib/Doctrine/DBAL/Driver/PDO/MySQL/Driver.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/OCI/Driver.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/PgSQL/Driver.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/SQLSrv/Connection.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/SQLSrv/Driver.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/SQLSrv/Statement.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/SQLite/Driver.php diff --git a/UPGRADE.md b/UPGRADE.md index 41c0bd1b026..45b4e26383b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,17 @@ # Upgrade to 2.11 +## PDO-related classes outside of the PDO namespace are deprecated + +The following outside of the PDO namespace have been deprecated in favor of their counterparts in the PDO namespace: + +- `PDOMySql\Driver` → `PDO\MySQL\Driver` +- `PDOOracle\Driver` → `PDO\OCI\Driver` +- `PDOPgSql\Driver` → `PDO\PgSQL\Driver` +- `PDOSqlite\Driver` → `PDO\SQLite\Driver` +- `PDOSqlsrv\Driver` → `PDO\SQLSrv\Driver` +- `PDOSqlsrv\Connection` → `PDO\SQLSrv\Connection` +- `PDOSqlsrv\Statement` → `PDO\SQLSrv\Statement` + ## Deprecations in driver-level exception handling 1. The `ExceptionConverterDriver` interface and the usage of the `convertException()` method on the `Driver` objects are deprecated. diff --git a/lib/Doctrine/DBAL/Driver/PDO/MySQL/Driver.php b/lib/Doctrine/DBAL/Driver/PDO/MySQL/Driver.php new file mode 100644 index 00000000000..a42cb7d608f --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/PDO/MySQL/Driver.php @@ -0,0 +1,9 @@ +constructPdoDsn($params), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php index 88aa01a5434..2ea597d16f1 100644 --- a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractOracleDriver; -use Doctrine\DBAL\Driver\PDO\Connection; +use Doctrine\DBAL\Driver\PDO; use PDOException; /** @@ -14,6 +14,8 @@ * stuff. PDO Oracle is not maintained by Oracle or anyone in the PHP community, * which leads us to the recommendation to use the "oci8" driver to connect * to Oracle instead. + * + * @deprecated Use {@link PDO\OCI\Driver} instead. */ class Driver extends AbstractOracleDriver { @@ -23,7 +25,7 @@ class Driver extends AbstractOracleDriver public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { try { - return new Connection( + return new PDO\Connection( $this->constructPdoDsn($params), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php index e3f15ab610f..d7a19181c4e 100644 --- a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php @@ -4,14 +4,15 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver; -use Doctrine\DBAL\Driver\PDO\Connection; -use PDO; +use Doctrine\DBAL\Driver\PDO; use PDOException; use function defined; /** * Driver that connects through pdo_pgsql. + * + * @deprecated Use {@link PDO\PgSQL\Driver} instead. */ class Driver extends AbstractPostgreSQLDriver { @@ -21,7 +22,7 @@ class Driver extends AbstractPostgreSQLDriver public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { try { - $pdo = new Connection( + $pdo = new PDO\Connection( $this->_constructPdoDsn($params), $username, $password, @@ -30,11 +31,11 @@ public function connect(array $params, $username = null, $password = null, array if ( defined('PDO::PGSQL_ATTR_DISABLE_PREPARES') - && (! isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES]) - || $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES] === true + && (! isset($driverOptions[\PDO::PGSQL_ATTR_DISABLE_PREPARES]) + || $driverOptions[\PDO::PGSQL_ATTR_DISABLE_PREPARES] === true ) ) { - $pdo->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true); + $pdo->setAttribute(\PDO::PGSQL_ATTR_DISABLE_PREPARES, true); } /* defining client_encoding via SET NAMES to avoid inconsistent DSN support diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php index 304043b9cdd..0c3b3900059 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractSQLiteDriver; -use Doctrine\DBAL\Driver\PDO\Connection; +use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\Platforms\SqlitePlatform; use PDOException; @@ -12,6 +12,8 @@ /** * The PDO Sqlite driver. + * + * @deprecated Use {@link PDO\SQLite\Driver} instead. */ class Driver extends AbstractSQLiteDriver { @@ -36,7 +38,7 @@ public function connect(array $params, $username = null, $password = null, array } try { - $pdo = new Connection( + $pdo = new PDO\Connection( $this->_constructPdoDsn($params), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index d0262dcf6a7..1fdb545dd40 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -2,10 +2,9 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; -use Doctrine\DBAL\Driver\PDO\Connection as BaseConnection; +use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\ParameterType; -use PDO; use function is_string; use function strpos; @@ -13,8 +12,10 @@ /** * Sqlsrv Connection implementation. + * + * @deprecated Use {@link PDO\SQLSrv\Connection} instead. */ -class Connection extends BaseConnection +class Connection extends PDO\Connection { /** * @internal The connection can be only instantiated by its driver. @@ -24,7 +25,7 @@ class Connection extends BaseConnection public function __construct($dsn, $user = null, $password = null, ?array $options = null) { parent::__construct($dsn, $user, $password, $options); - $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, [Statement::class, []]); + $this->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [PDO\SQLSrv\Statement::class, []]); } /** diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php index bd0fd6a665c..d8f22505561 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php @@ -4,12 +4,15 @@ use Doctrine\DBAL\Driver\AbstractSQLServerDriver; use Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception\PortWithoutHost; +use Doctrine\DBAL\Driver\PDO; use function is_int; use function sprintf; /** * The PDO-based Sqlsrv driver. + * + * @deprecated Use {@link PDO\SQLSrv\Driver} instead. */ class Driver extends AbstractSQLServerDriver { @@ -28,7 +31,7 @@ public function connect(array $params, $username = null, $password = null, array } } - return new Connection( + return new PDO\SQLSrv\Connection( $this->_constructPdoDsn($params, $dsnOptions), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php index 7091eb375a3..3ce8ef8d60f 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php @@ -2,14 +2,15 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; -use Doctrine\DBAL\Driver\PDO\Statement as BaseStatement; +use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\ParameterType; -use PDO; /** * PDO SQL Server Statement + * + * @deprecated Use {@link PDO\SQLSrv\Statement} instead. */ -class Statement extends BaseStatement +class Statement extends PDO\Statement { /** * {@inheritdoc} @@ -20,7 +21,7 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l ($type === ParameterType::LARGE_OBJECT || $type === ParameterType::BINARY) && $driverOptions === null ) { - $driverOptions = PDO::SQLSRV_ENCODING_BINARY; + $driverOptions = \PDO::SQLSRV_ENCODING_BINARY; } return parent::bindParam($column, $variable, $type, $length, $driverOptions); diff --git a/lib/Doctrine/DBAL/DriverManager.php b/lib/Doctrine/DBAL/DriverManager.php index 691e7d42ca6..ed02e3a5b9e 100644 --- a/lib/Doctrine/DBAL/DriverManager.php +++ b/lib/Doctrine/DBAL/DriverManager.php @@ -3,18 +3,13 @@ namespace Doctrine\DBAL; use Doctrine\Common\EventManager; -use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver as DrizzlePDOMySQLDriver; -use Doctrine\DBAL\Driver\IBMDB2\Driver as IBMDB2Driver; -use Doctrine\DBAL\Driver\Mysqli\Driver as MySQLiDriver; -use Doctrine\DBAL\Driver\OCI8\Driver as OCI8Driver; -use Doctrine\DBAL\Driver\PDOMySql\Driver as PDOMySQLDriver; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOCIDriver; -use Doctrine\DBAL\Driver\PDOPgSql\Driver as PDOPgSQLDriver; -use Doctrine\DBAL\Driver\PDOSqlite\Driver as PDOSQLiteDriver; -use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSrvDriver; -use Doctrine\DBAL\Driver\SQLAnywhere\Driver as SQLAnywhereDriver; -use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; -use PDO; +use Doctrine\DBAL\Driver\DrizzlePDOMySql; +use Doctrine\DBAL\Driver\IBMDB2; +use Doctrine\DBAL\Driver\Mysqli; +use Doctrine\DBAL\Driver\OCI8; +use Doctrine\DBAL\Driver\PDO; +use Doctrine\DBAL\Driver\SQLAnywhere; +use Doctrine\DBAL\Driver\SQLSrv; use function array_keys; use function array_map; @@ -45,17 +40,17 @@ final class DriverManager * @var string[] */ private static $_driverMap = [ - 'pdo_mysql' => PDOMySQLDriver::class, - 'pdo_sqlite' => PDOSQLiteDriver::class, - 'pdo_pgsql' => PDOPgSQLDriver::class, - 'pdo_oci' => PDOOCIDriver::class, - 'oci8' => OCI8Driver::class, - 'ibm_db2' => IBMDB2Driver::class, - 'pdo_sqlsrv' => PDOSQLSrvDriver::class, - 'mysqli' => MySQLiDriver::class, - 'drizzle_pdo_mysql' => DrizzlePDOMySQLDriver::class, - 'sqlanywhere' => SQLAnywhereDriver::class, - 'sqlsrv' => SQLSrvDriver::class, + 'pdo_mysql' => PDO\MySQL\Driver::class, + 'pdo_sqlite' => PDO\SQLite\Driver::class, + 'pdo_pgsql' => PDO\PgSQL\Driver::class, + 'pdo_oci' => PDO\OCI\Driver::class, + 'oci8' => OCI8\Driver::class, + 'ibm_db2' => IBMDB2\Driver::class, + 'pdo_sqlsrv' => PDO\SQLSrv\Driver::class, + 'mysqli' => Mysqli\Driver::class, + 'drizzle_pdo_mysql' => DrizzlePDOMySql\Driver::class, + 'sqlanywhere' => SQLAnywhere\Driver::class, + 'sqlsrv' => SQLSrv\Driver::class, ]; /** @@ -177,13 +172,13 @@ public static function getConnection( } // check for existing pdo object - if (isset($params['pdo']) && ! $params['pdo'] instanceof PDO) { + if (isset($params['pdo']) && ! $params['pdo'] instanceof \PDO) { throw DBALException::invalidPdoInstance(); } if (isset($params['pdo'])) { - $params['pdo']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $params['driver'] = 'pdo_' . $params['pdo']->getAttribute(PDO::ATTR_DRIVER_NAME); + $params['pdo']->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $params['driver'] = 'pdo_' . $params['pdo']->getAttribute(\PDO::ATTR_DRIVER_NAME); } else { self::_checkParams($params); } diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index 2cba7534710..a0007208bd5 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -135,7 +135,7 @@ public function testGetPassword(): void public function testGetDriver(): void { - self::assertInstanceOf(\Doctrine\DBAL\Driver\PDOMySql\Driver::class, $this->connection->getDriver()); + self::assertInstanceOf(Driver\PDO\MySQL\Driver::class, $this->connection->getDriver()); } public function testGetEventManager(): void diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php index e67a0673402..9eef41ed4f5 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Driver\PDOMySql; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOMySql\Driver; +use Doctrine\DBAL\Driver\PDO\MySQL\Driver; use Doctrine\Tests\DBAL\Driver\AbstractMySQLDriverTest; class DriverTest extends AbstractMySQLDriverTest diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php index ae647cbe0cd..3042d6633ec 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Driver\PDOOracle; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOOracle\Driver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver; use Doctrine\Tests\DBAL\Driver\AbstractOracleDriverTest; class DriverTest extends AbstractOracleDriverTest diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php index 1607207cc47..0e25298e9eb 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\PDO\Connection; -use Doctrine\DBAL\Driver\PDOPgSql\Driver; +use Doctrine\DBAL\Driver\PDO\PgSQL\Driver; use Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest; use Doctrine\Tests\TestUtil; use PDO; diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php index b360a46cba6..004bb00f50a 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Driver\PDOSqlite; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOSqlite\Driver; +use Doctrine\DBAL\Driver\PDO\SQLite\Driver; use Doctrine\Tests\DBAL\Driver\AbstractSQLiteDriverTest; class DriverTest extends AbstractSQLiteDriverTest diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php index e3ee50ff293..c83dd1cfb1b 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Driver\PDOSqlsrv; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOSqlsrv\Driver; +use Doctrine\DBAL\Driver\PDO\SQLSrv\Driver; use Doctrine\Tests\DBAL\Driver\AbstractSQLServerDriverTest; class DriverTest extends AbstractSQLServerDriverTest diff --git a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php index c88190f99f0..67b7a1f7f33 100644 --- a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php @@ -7,8 +7,8 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver as DrizzlePDOMySqlDriver; -use Doctrine\DBAL\Driver\PDOMySql\Driver as PDOMySQLDriver; -use Doctrine\DBAL\Driver\PDOSqlite\Driver as PDOSqliteDriver; +use Doctrine\DBAL\Driver\PDO\MySQL\Driver as PDOMySQLDriver; +use Doctrine\DBAL\Driver\PDO\SQLite\Driver as PDOSQLiteDriver; use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -277,42 +277,42 @@ public function databaseUrls(): iterable 'sqlite://localhost/foo/dbname.sqlite', [ 'path' => 'foo/dbname.sqlite', - 'driver' => PDOSqliteDriver::class, + 'driver' => PDOSQLiteDriver::class, ], ], 'sqlite absolute URL with host' => [ 'sqlite://localhost//tmp/dbname.sqlite', [ 'path' => '/tmp/dbname.sqlite', - 'driver' => PDOSqliteDriver::class, + 'driver' => PDOSQLiteDriver::class, ], ], 'sqlite relative URL without host' => [ 'sqlite:///foo/dbname.sqlite', [ 'path' => 'foo/dbname.sqlite', - 'driver' => PDOSqliteDriver::class, + 'driver' => PDOSQLiteDriver::class, ], ], 'sqlite absolute URL without host' => [ 'sqlite:////tmp/dbname.sqlite', [ 'path' => '/tmp/dbname.sqlite', - 'driver' => PDOSqliteDriver::class, + 'driver' => PDOSQLiteDriver::class, ], ], 'sqlite memory' => [ 'sqlite:///:memory:', [ 'memory' => true, - 'driver' => PDOSqliteDriver::class, + 'driver' => PDOSQLiteDriver::class, ], ], 'sqlite memory with host' => [ 'sqlite://localhost/:memory:', [ 'memory' => true, - 'driver' => PDOSqliteDriver::class, + 'driver' => PDOSQLiteDriver::class, ], ], 'params parsed from URL override individual params' => [ diff --git a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php index 20ea0870476..1683e666018 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional; use Doctrine\DBAL\Driver\OCI8\Driver as OCI8Driver; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\Table; @@ -23,7 +23,7 @@ protected function setUp(): void { parent::setUp(); - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDO\OCI\Driver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported // see http://php.net/manual/en/pdo.lobs.php#example-1035 $this->markTestSkipped('DBAL doesn\'t support storing LOBs represented as streams using PDO_OCI'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index 785d0ac33d2..0861608d888 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -9,7 +9,7 @@ use Doctrine\DBAL\Driver\Mysqli\Driver as MySQLiDriver; use Doctrine\DBAL\Driver\OCI8\Driver as Oci8Driver; use Doctrine\DBAL\Driver\PDO\Connection as PDOConnection; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver as PDOOCIDriver; use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; @@ -945,7 +945,7 @@ private function beforeFetchClassTest(): void $this->markTestSkipped('Mysqli driver dont support this feature.'); } - if (! $driver instanceof PDOOracleDriver) { + if (! $driver instanceof PDOOCIDriver) { return; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php index 602e4b541ce..c7a7507b75a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php @@ -4,9 +4,9 @@ use Doctrine\DBAL\Driver\PDO\Connection; use Doctrine\DBAL\Driver\PDO\Exception; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; -use Doctrine\DBAL\Driver\PDOPgSql\Driver as PDOPgSQLDriver; -use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSRVDriver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver as PDOOCIDriver; +use Doctrine\DBAL\Driver\PDO\PgSQL\Driver as PDOPgSQLDriver; +use Doctrine\DBAL\Driver\PDO\SQLSrv\Driver as PDOSQLSrvDriver; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; @@ -73,7 +73,7 @@ public function testThrowsWrappedExceptionOnPrepare(): void { $driver = $this->connection->getDriver(); - if ($driver instanceof PDOSQLSRVDriver) { + if ($driver instanceof PDOSQLSrvDriver) { $this->markTestSkipped('pdo_sqlsrv does not allow setting PDO::ATTR_EMULATE_PREPARES at connection level.'); } @@ -81,7 +81,7 @@ public function testThrowsWrappedExceptionOnPrepare(): void // even though emulated prepared statements are disabled, // so an exception is thrown only eventually. if ( - $driver instanceof PDOOracleDriver + $driver instanceof PDOOCIDriver || $driver instanceof PDOPgSQLDriver ) { self::markTestSkipped(sprintf( diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php index ebe6461c20a..0689c31abc8 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\PDOMySql; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOMySql\Driver; +use Doctrine\DBAL\Driver\PDO\MySQL\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use function extension_loaded; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php index 0aa54ac92e0..d246c58ef0b 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\PDOOracle; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOOracle\Driver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use function extension_loaded; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php index 3dc08b7e6e7..5cea99378f7 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOPgSql\Driver; +use Doctrine\DBAL\Driver\PDO\PgSQL\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use Doctrine\Tests\TestUtil; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php index d659815cac6..46672e88794 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\PDOSqlite; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOSqlite\Driver; +use Doctrine\DBAL\Driver\PDO\SQLite\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use function extension_loaded; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php index 5e52b5ca204..96f76ac4fdf 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\PDO\Connection; -use Doctrine\DBAL\Driver\PDOSqlsrv\Driver; +use Doctrine\DBAL\Driver\PDO\SQLSrv\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use Doctrine\Tests\TestUtil; use PDO; diff --git a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php index bf3f4abab67..ac028f323cf 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL\Functional; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver as PDOOCIDriver; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; @@ -27,7 +27,7 @@ protected function setUp(): void public function testStatementIsReusableAfterClosingCursor(): void { - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDOOCIDriver) { $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=77181'); } @@ -52,7 +52,7 @@ public function testStatementIsReusableAfterClosingCursor(): void public function testReuseStatementWithLongerResults(): void { - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDOOCIDriver) { $this->markTestIncomplete('PDO_OCI doesn\'t support fetching blobs via PDOStatement::fetchAll()'); } @@ -89,7 +89,7 @@ public function testReuseStatementWithLongerResults(): void public function testFetchLongBlob(): void { - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDOOCIDriver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported // see http://php.net/manual/en/pdo.lobs.php#example-1035 $this->markTestSkipped('DBAL doesn\'t support storing LOBs represented as streams using PDO_OCI'); @@ -154,7 +154,7 @@ public function testIncompletelyFetchedStatementDoesNotBlockConnection(): void public function testReuseStatementAfterClosingCursor(): void { - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDOOCIDriver) { $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=77181'); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php index b987905569e..512bb9f1bc7 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional; use DateTime; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver as PDOOCIDriver; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; @@ -120,7 +120,7 @@ public static function floatProvider(): iterable */ public function testIdempotentConversionToString(string $type, $originalValue): void { - if ($type === 'text' && $this->connection->getDriver() instanceof PDOOracleDriver) { + if ($type === 'text' && $this->connection->getDriver() instanceof PDOOCIDriver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported // see http://php.net/manual/en/pdo.lobs.php#example-1035 $this->markTestSkipped('DBAL doesn\'t support storing LOBs represented as streams using PDO_OCI'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php index 70217b09ede..2c84cce461f 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php @@ -5,7 +5,7 @@ namespace Doctrine\Tests\DBAL\Functional\Types; use Doctrine\DBAL\Driver\IBMDB2\Driver; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver as PDOOCIDriver; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; @@ -21,7 +21,7 @@ protected function setUp(): void { parent::setUp(); - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDOOCIDriver) { $this->markTestSkipped('PDO_OCI doesn\'t support binding binary values'); } From c4325fd7cd7d8039f19328073085f5ea53d21231 Mon Sep 17 00:00:00 2001 From: Kristjan Siimson Date: Fri, 3 Jul 2020 21:46:59 +0200 Subject: [PATCH 15/19] Add support for MYSQLI_OPT_READ_TIMEOUT --- lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index 2e8dd185013..9553296ca06 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -11,7 +11,6 @@ use Doctrine\DBAL\ParameterType; use mysqli; -use function defined; use function floor; use function func_get_args; use function in_array; @@ -28,6 +27,7 @@ use const MYSQLI_INIT_COMMAND; use const MYSQLI_OPT_CONNECT_TIMEOUT; use const MYSQLI_OPT_LOCAL_INFILE; +use const MYSQLI_OPT_READ_TIMEOUT; use const MYSQLI_READ_DEFAULT_FILE; use const MYSQLI_READ_DEFAULT_GROUP; use const MYSQLI_SERVER_PUBLIC_KEY; @@ -243,15 +243,13 @@ private function setDriverOptions(array $driverOptions = []): void $supportedDriverOptions = [ MYSQLI_OPT_CONNECT_TIMEOUT, MYSQLI_OPT_LOCAL_INFILE, + MYSQLI_OPT_READ_TIMEOUT, MYSQLI_INIT_COMMAND, MYSQLI_READ_DEFAULT_FILE, MYSQLI_READ_DEFAULT_GROUP, + MYSQLI_SERVER_PUBLIC_KEY, ]; - if (defined('MYSQLI_SERVER_PUBLIC_KEY')) { - $supportedDriverOptions[] = MYSQLI_SERVER_PUBLIC_KEY; - } - $exceptionMsg = "%s option '%s' with value '%s'"; foreach ($driverOptions as $option => $value) { From 66d682179d9fefde0fa6d8868430cb721469bc33 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 3 Jul 2020 19:16:30 -0700 Subject: [PATCH 16/19] Add TypeRegistry constructor --- lib/Doctrine/DBAL/Types/Type.php | 6 +++--- lib/Doctrine/DBAL/Types/TypeRegistry.php | 10 +++++++++- tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php | 7 ++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/DBAL/Types/Type.php b/lib/Doctrine/DBAL/Types/Type.php index 6dd4e9abb30..8a6a7cd7466 100644 --- a/lib/Doctrine/DBAL/Types/Type.php +++ b/lib/Doctrine/DBAL/Types/Type.php @@ -208,13 +208,13 @@ final public static function getTypeRegistry(): TypeRegistry private static function createTypeRegistry(): TypeRegistry { - $registry = new TypeRegistry(); + $instances = []; foreach (self::BUILTIN_TYPES_MAP as $name => $class) { - $registry->register($name, new $class()); + $instances[$name] = new $class(); } - return $registry; + return new TypeRegistry($instances); } /** diff --git a/lib/Doctrine/DBAL/Types/TypeRegistry.php b/lib/Doctrine/DBAL/Types/TypeRegistry.php index 362a5ccc9a4..4c2e31ecbcf 100644 --- a/lib/Doctrine/DBAL/Types/TypeRegistry.php +++ b/lib/Doctrine/DBAL/Types/TypeRegistry.php @@ -18,7 +18,15 @@ final class TypeRegistry { /** @var array Map of type names and their corresponding flyweight objects. */ - private $instances = []; + private $instances; + + /** + * @param array $instances + */ + public function __construct(array $instances = []) + { + $this->instances = $instances; + } /** * Finds a type by the given name. diff --git a/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php b/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php index be4ba0dddfe..98b0fd99a40 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php @@ -31,9 +31,10 @@ protected function setUp(): void $this->testType = new BlobType(); $this->otherTestType = new BinaryType(); - $this->registry = new TypeRegistry(); - $this->registry->register(self::TEST_TYPE_NAME, $this->testType); - $this->registry->register(self::OTHER_TEST_TYPE_NAME, $this->otherTestType); + $this->registry = new TypeRegistry([ + self::TEST_TYPE_NAME => $this->testType, + self::OTHER_TEST_TYPE_NAME => $this->otherTestType, + ]); } public function testGet(): void From da2349e44eeb05d79155dcd2d63a3c4f2332310f Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 4 Jul 2020 14:20:31 -0700 Subject: [PATCH 17/19] Remove workaround in PDOSqlsrv\Connection::quote() --- .../DBAL/Driver/PDOSqlsrv/Connection.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index 92611267d94..4790db626d5 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -3,11 +3,7 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; use Doctrine\DBAL\Driver\PDOConnection; -use Doctrine\DBAL\ParameterType; use PDO; -use function is_string; -use function strpos; -use function substr; /** * Sqlsrv Connection implementation. @@ -37,19 +33,4 @@ public function lastInsertId($name = null) return $stmt->fetchColumn(); } - - /** - * {@inheritDoc} - */ - public function quote($value, $type = ParameterType::STRING) - { - $val = parent::quote($value, $type); - - // Fix for a driver version terminating all values with null byte - if (is_string($val) && strpos($val, "\0") !== false) { - $val = substr($val, 0, -1); - } - - return $val; - } } From 8739b528a83b158e3e66f62c56939a505af658dd Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 5 Jul 2020 14:09:09 -0700 Subject: [PATCH 18/19] Update doctrine/coding-standard to 8.1 --- composer.json | 2 +- composer.lock | 41 ++- lib/Doctrine/DBAL/Cache/ArrayStatement.php | 1 + lib/Doctrine/DBAL/Cache/QueryCacheProfile.php | 1 + .../DBAL/Cache/ResultCacheStatement.php | 1 + lib/Doctrine/DBAL/Configuration.php | 7 +- lib/Doctrine/DBAL/Connection.php | 7 +- .../Connections/MasterSlaveConnection.php | 1 + lib/Doctrine/DBAL/DBALException.php | 9 +- .../DBAL/Driver/AbstractMySQLDriver.php | 29 +- .../EasyConnectString.php | 10 +- .../DBAL/Driver/AbstractPostgreSQLDriver.php | 1 + .../DBAL/Driver/AbstractSQLAnywhereDriver.php | 13 +- .../DBAL/Driver/AbstractSQLServerDriver.php | 13 +- .../PortWithoutHost.php | 2 +- .../DBAL/Driver/AbstractSQLiteDriver.php | 7 +- .../DBAL/Driver/IBMDB2/DB2Connection.php | 2 + .../DBAL/Driver/IBMDB2/DB2Statement.php | 8 +- .../DBAL/Driver/IBMDB2/DataSourceName.php | 24 +- .../DBAL/Driver/Mysqli/MysqliConnection.php | 9 +- .../DBAL/Driver/Mysqli/MysqliStatement.php | 5 +- lib/Doctrine/DBAL/Driver/OCI8/Driver.php | 1 + .../DBAL/Driver/OCI8/OCI8Connection.php | 2 + .../DBAL/Driver/OCI8/OCI8Statement.php | 4 +- lib/Doctrine/DBAL/Driver/PDOConnection.php | 1 + lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php | 1 + lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php | 3 +- .../DBAL/Driver/PDOSqlsrv/Statement.php | 3 +- lib/Doctrine/DBAL/Driver/PDOStatement.php | 6 +- .../DBAL/Driver/SQLAnywhere/Driver.php | 1 + .../SQLAnywhere/SQLAnywhereConnection.php | 1 + .../SQLAnywhere/SQLAnywhereException.php | 1 + .../SQLAnywhere/SQLAnywhereStatement.php | 2 + .../DBAL/Driver/SQLSrv/SQLSrvConnection.php | 2 + .../DBAL/Driver/SQLSrv/SQLSrvException.php | 2 + .../DBAL/Driver/SQLSrv/SQLSrvStatement.php | 2 + lib/Doctrine/DBAL/DriverManager.php | 21 +- .../Event/Listeners/OracleSessionInit.php | 2 + .../SchemaAlterTableAddColumnEventArgs.php | 1 + .../SchemaAlterTableChangeColumnEventArgs.php | 1 + .../DBAL/Event/SchemaAlterTableEventArgs.php | 1 + .../SchemaAlterTableRemoveColumnEventArgs.php | 1 + .../SchemaAlterTableRenameColumnEventArgs.php | 1 + .../SchemaCreateTableColumnEventArgs.php | 1 + .../DBAL/Event/SchemaCreateTableEventArgs.php | 1 + lib/Doctrine/DBAL/Id/TableGenerator.php | 2 + .../Internal/DependencyOrderCalculator.php | 10 +- lib/Doctrine/DBAL/Logging/EchoSQLLogger.php | 1 + .../DBAL/Platforms/AbstractPlatform.php | 22 +- lib/Doctrine/DBAL/Platforms/DB2Platform.php | 13 +- .../DBAL/Platforms/DrizzlePlatform.php | 4 +- .../Platforms/Keywords/MariaDb102Keywords.php | 4 +- .../Keywords/PostgreSQL100Keywords.php | 2 +- .../Keywords/ReservedKeywordsValidator.php | 1 + .../DBAL/Platforms/MariaDb1027Platform.php | 6 +- lib/Doctrine/DBAL/Platforms/MySqlPlatform.php | 8 +- .../DBAL/Platforms/OraclePlatform.php | 14 +- .../DBAL/Platforms/PostgreSQL100Platform.php | 4 +- .../DBAL/Platforms/PostgreSQL92Platform.php | 1 + .../DBAL/Platforms/PostgreSqlPlatform.php | 16 +- .../DBAL/Platforms/SQLAnywherePlatform.php | 3 +- .../DBAL/Platforms/SQLServer2008Platform.php | 2 +- .../DBAL/Platforms/SQLServer2012Platform.php | 5 +- .../DBAL/Platforms/SQLServerPlatform.php | 5 +- .../DBAL/Platforms/SqlitePlatform.php | 13 +- lib/Doctrine/DBAL/Portability/Connection.php | 2 + lib/Doctrine/DBAL/Portability/Statement.php | 7 +- .../Query/Expression/CompositeExpression.php | 1 + .../Query/Expression/ExpressionBuilder.php | 1 + lib/Doctrine/DBAL/Query/QueryBuilder.php | 5 +- lib/Doctrine/DBAL/Query/QueryException.php | 1 + lib/Doctrine/DBAL/SQLParserUtils.php | 11 +- lib/Doctrine/DBAL/Schema/AbstractAsset.php | 1 + .../DBAL/Schema/AbstractSchemaManager.php | 3 +- lib/Doctrine/DBAL/Schema/Column.php | 2 + lib/Doctrine/DBAL/Schema/Comparator.php | 18 +- lib/Doctrine/DBAL/Schema/DB2SchemaManager.php | 6 +- .../DBAL/Schema/DrizzleSchemaManager.php | 1 + .../DBAL/Schema/ForeignKeyConstraint.php | 3 +- lib/Doctrine/DBAL/Schema/Index.php | 5 +- .../DBAL/Schema/MySqlSchemaManager.php | 6 +- .../DBAL/Schema/OracleSchemaManager.php | 4 +- .../DBAL/Schema/PostgreSqlSchemaManager.php | 6 +- .../DBAL/Schema/SQLAnywhereSchemaManager.php | 1 + .../DBAL/Schema/SQLServerSchemaManager.php | 5 +- lib/Doctrine/DBAL/Schema/Schema.php | 13 +- lib/Doctrine/DBAL/Schema/SchemaDiff.php | 1 + lib/Doctrine/DBAL/Schema/SchemaException.php | 1 + lib/Doctrine/DBAL/Schema/Sequence.php | 1 + .../DBAL/Schema/SqliteSchemaManager.php | 28 +- .../SingleDatabaseSynchronizer.php | 1 + lib/Doctrine/DBAL/Schema/Table.php | 9 +- .../Visitor/CreateSchemaSqlCollector.php | 1 + .../Schema/Visitor/DropSchemaSqlCollector.php | 1 + lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php | 1 + .../DBAL/Sharding/PoolingShardConnection.php | 1 + .../SQLAzureFederationsSynchronizer.php | 1 + .../SQLAzure/SQLAzureShardManager.php | 1 + .../SQLAzure/Schema/MultiTenantVisitor.php | 1 + lib/Doctrine/DBAL/Statement.php | 1 + .../Tools/Console/Command/ImportCommand.php | 2 + .../Console/Command/ReservedWordsCommand.php | 1 + .../Tools/Console/Command/RunSqlCommand.php | 1 + lib/Doctrine/DBAL/Tools/Dumper.php | 5 +- lib/Doctrine/DBAL/Types/ArrayType.php | 3 +- lib/Doctrine/DBAL/Types/BinaryType.php | 1 + lib/Doctrine/DBAL/Types/BlobType.php | 1 + .../DBAL/Types/ConversionException.php | 3 +- lib/Doctrine/DBAL/Types/DateIntervalType.php | 1 + .../DBAL/Types/DateTimeImmutableType.php | 1 + lib/Doctrine/DBAL/Types/DateTimeType.php | 1 + lib/Doctrine/DBAL/Types/JsonArrayType.php | 1 + lib/Doctrine/DBAL/Types/JsonType.php | 2 + lib/Doctrine/DBAL/Types/ObjectType.php | 3 +- lib/Doctrine/DBAL/Types/SimpleArrayType.php | 1 + lib/Doctrine/DBAL/Types/TextType.php | 1 + lib/Doctrine/DBAL/Types/Type.php | 7 +- lib/Doctrine/DBAL/Types/TypeRegistry.php | 15 +- .../DBAL/Types/VarDateTimeImmutableType.php | 1 + lib/Doctrine/DBAL/Types/VarDateTimeType.php | 1 + phpcs.xml.dist | 1 + .../DBAL/Cache/QueryCacheProfileTest.php | 13 +- .../Doctrine/Tests/DBAL/ConfigurationTest.php | 6 +- .../Tests/DBAL/Connection/LoggingTest.php | 8 +- tests/Doctrine/Tests/DBAL/ConnectionTest.php | 99 +++---- .../Doctrine/Tests/DBAL/DBALExceptionTest.php | 13 +- .../DBAL/Driver/AbstractDB2DriverTest.php | 6 +- .../Tests/DBAL/Driver/AbstractDriverTest.php | 29 +- .../DBAL/Driver/AbstractMySQLDriverTest.php | 12 +- .../EasyConnectStringTest.php | 4 +- .../DBAL/Driver/AbstractOracleDriverTest.php | 12 +- .../Driver/AbstractPostgreSQLDriverTest.php | 12 +- .../Driver/AbstractSQLAnywhereDriverTest.php | 10 +- .../Driver/AbstractSQLServerDriverTest.php | 8 +- .../DBAL/Driver/AbstractSQLiteDriverTest.php | 10 +- .../Driver/DrizzlePDOMySql/DriverTest.php | 12 +- .../DBAL/Driver/IBMDB2/DB2ConnectionTest.php | 4 +- .../DBAL/Driver/IBMDB2/DB2DriverTest.php | 4 +- .../DBAL/Driver/IBMDB2/DataSourceNameTest.php | 6 +- .../Tests/DBAL/Driver/Mysqli/DriverTest.php | 4 +- .../Driver/Mysqli/MysqliConnectionTest.php | 9 +- .../Tests/DBAL/Driver/OCI8/DriverTest.php | 4 +- .../DBAL/Driver/OCI8/OCI8ConnectionTest.php | 4 +- .../DBAL/Driver/OCI8/OCI8StatementTest.php | 8 +- .../Tests/DBAL/Driver/PDOExceptionTest.php | 12 +- .../Tests/DBAL/Driver/PDOIbm/DriverTest.php | 4 +- .../Tests/DBAL/Driver/PDOMySql/DriverTest.php | 4 +- .../DBAL/Driver/PDOOracle/DriverTest.php | 4 +- .../Tests/DBAL/Driver/PDOPgSql/DriverTest.php | 14 +- .../DBAL/Driver/PDOSqlite/DriverTest.php | 4 +- .../DBAL/Driver/PDOSqlsrv/DriverTest.php | 4 +- .../DBAL/Driver/SQLAnywhere/DriverTest.php | 4 +- .../SQLAnywhere/SQLAnywhereConnectionTest.php | 4 +- .../Tests/DBAL/Driver/SQLSrv/DriverTest.php | 4 +- .../Driver/SQLSrv/SQLSrvConnectionTest.php | 4 +- .../DBAL/Driver/StatementIteratorTest.php | 13 +- .../Doctrine/Tests/DBAL/DriverManagerTest.php | 29 +- .../DBAL/Events/MysqlSessionInitTest.php | 4 +- .../DBAL/Events/OracleSessionInitTest.php | 9 +- .../Tests/DBAL/Events/SQLSessionInitTest.php | 4 +- .../InvalidArgumentExceptionTest.php | 2 +- .../Tests/DBAL/Functional/BlobTest.php | 17 +- .../Tests/DBAL/Functional/ConnectionTest.php | 53 ++-- .../Tests/DBAL/Functional/DataAccessTest.php | 120 ++++---- .../Functional/Driver/AbstractDriverTest.php | 10 +- .../Driver/IBMDB2/DB2DriverTest.php | 8 +- .../Driver/IBMDB2/DB2StatementTest.php | 4 +- .../Driver/Mysqli/ConnectionTest.php | 13 +- .../Functional/Driver/Mysqli/DriverTest.php | 4 +- .../Functional/Driver/OCI8/DriverTest.php | 8 +- .../Driver/OCI8/OCI8ConnectionTest.php | 4 +- .../Functional/Driver/OCI8/StatementTest.php | 8 +- .../Functional/Driver/PDOConnectionTest.php | 18 +- .../Functional/Driver/PDOMySql/DriverTest.php | 4 +- .../Driver/PDOOracle/DriverTest.php | 8 +- .../Functional/Driver/PDOPgSql/DriverTest.php | 13 +- .../Driver/PDOPgsqlConnectionTest.php | 6 +- .../Driver/PDOSqlite/DriverTest.php | 4 +- .../Driver/PDOSqlsrv/DriverTest.php | 12 +- .../Driver/SQLAnywhere/ConnectionTest.php | 6 +- .../Driver/SQLAnywhere/DriverTest.php | 6 +- .../Driver/SQLAnywhere/StatementTest.php | 6 +- .../Functional/Driver/SQLSrv/DriverTest.php | 6 +- .../Driver/SQLSrv/StatementTest.php | 4 +- .../Tests/DBAL/Functional/ExceptionTest.php | 42 +-- .../Functional/LikeWildcardsEscapingTest.php | 3 +- .../Functional/MasterSlaveConnectionTest.php | 26 +- .../DBAL/Functional/ModifyLimitQueryTest.php | 22 +- .../DBAL/Functional/NamedParametersTest.php | 8 +- .../DBAL/Functional/PDOStatementTest.php | 4 +- .../Platform/DateExpressionTest.php | 5 +- .../Platform/DefaultExpressionTest.php | 15 +- ...imaryKeyWithNewAutoIncrementColumnTest.php | 7 +- .../Platform/PlatformRestrictionsTest.php | 3 +- .../DBAL/Functional/Platform/QuotingTest.php | 4 +- .../Tests/DBAL/Functional/PortabilityTest.php | 19 +- .../Tests/DBAL/Functional/ResultCacheTest.php | 38 +-- .../DBAL/Functional/Schema/ComparatorTest.php | 6 +- .../Schema/Db2SchemaManagerTest.php | 4 +- .../Functional/Schema/DefaultValueTest.php | 9 +- .../Schema/DrizzleSchemaManagerTest.php | 4 +- .../DBAL/Functional/Schema/ForeignKeyTest.php | 2 +- .../Schema/MySqlSchemaManagerTest.php | 48 +-- .../Schema/OracleSchemaManagerTest.php | 21 +- .../Schema/PostgreSqlSchemaManagerTest.php | 55 ++-- .../Schema/SQLAnywhereSchemaManagerTest.php | 8 +- .../Schema/SQLServerSchemaManagerTest.php | 13 +- .../SchemaManagerFunctionalTestCase.php | 163 ++++++----- .../Schema/SqliteSchemaManagerTest.php | 27 +- .../Tests/DBAL/Functional/StatementTest.php | 33 ++- .../DBAL/Functional/TableGeneratorTest.php | 6 +- .../DBAL/Functional/TemporaryTableTest.php | 20 +- .../DBAL/Functional/Ticket/DBAL168Test.php | 2 +- .../DBAL/Functional/Ticket/DBAL202Test.php | 6 +- .../DBAL/Functional/Ticket/DBAL421Test.php | 9 +- .../DBAL/Functional/Ticket/DBAL461Test.php | 2 +- .../DBAL/Functional/Ticket/DBAL510Test.php | 4 +- .../DBAL/Functional/Ticket/DBAL630Test.php | 21 +- .../DBAL/Functional/Ticket/DBAL752Test.php | 5 +- .../Tests/DBAL/Functional/TransactionTest.php | 7 +- .../DBAL/Functional/TypeConversionTest.php | 31 +- .../DBAL/Functional/Types/BinaryTest.php | 7 +- .../Tests/DBAL/Functional/WriteTest.php | 43 +-- .../DependencyOrderCalculatorTest.php | 4 +- .../Tests/DBAL/Logging/DebugStackTest.php | 8 +- .../Tests/DBAL/Logging/LoggerChainTest.php | 8 +- .../TypeConversionPerformanceTest.php | 4 +- .../AbstractMySQLPlatformTestCase.php | 161 +++++----- .../Platforms/AbstractPlatformTestCase.php | 275 +++++++++--------- .../AbstractPostgreSqlPlatformTestCase.php | 165 +++++------ .../AbstractSQLServerPlatformTestCase.php | 199 ++++++------- .../Tests/DBAL/Platforms/DB2PlatformTest.php | 118 ++++---- .../Platforms/MariaDb1027PlatformTest.php | 10 +- .../DBAL/Platforms/MySQL57PlatformTest.php | 18 +- .../DBAL/Platforms/MySqlPlatformTest.php | 4 +- .../DBAL/Platforms/OraclePlatformTest.php | 163 +++++------ .../Platforms/PostgreSQL100PlatformTest.php | 4 +- .../Platforms/PostgreSQL91PlatformTest.php | 8 +- .../Platforms/PostgreSQL92PlatformTest.php | 12 +- .../Platforms/PostgreSQL94PlatformTest.php | 6 +- .../DBAL/Platforms/PostgreSqlPlatformTest.php | 6 +- .../ReservedKeywordsValidatorTest.php | 6 +- .../Platforms/SQLAnywhere11PlatformTest.php | 6 +- .../Platforms/SQLAnywhere12PlatformTest.php | 16 +- .../Platforms/SQLAnywhere16PlatformTest.php | 6 +- .../Platforms/SQLAnywherePlatformTest.php | 207 ++++++------- .../DBAL/Platforms/SQLAzurePlatformTest.php | 4 +- .../Platforms/SQLServer2008PlatformTest.php | 4 +- .../Platforms/SQLServer2012PlatformTest.php | 58 ++-- .../DBAL/Platforms/SQLServerPlatformTest.php | 10 +- .../DBAL/Platforms/SqlitePlatformTest.php | 126 ++++---- .../Tests/DBAL/Portability/StatementTest.php | 25 +- .../Expression/CompositeExpressionTest.php | 8 +- .../Expression/ExpressionBuilderTest.php | 46 +-- .../Tests/DBAL/Query/QueryBuilderTest.php | 140 ++++----- .../Tests/DBAL/SQLParserUtilsTest.php | 12 +- .../Tests/DBAL/Schema/ColumnDiffTest.php | 2 +- .../Doctrine/Tests/DBAL/Schema/ColumnTest.php | 18 +- .../Tests/DBAL/Schema/ComparatorTest.php | 115 ++++---- .../DBAL/Schema/DB2SchemaManagerTest.php | 13 +- .../DBAL/Schema/ForeignKeyConstraintTest.php | 8 +- .../Doctrine/Tests/DBAL/Schema/IndexTest.php | 28 +- .../DBAL/Schema/MySqlInheritCharsetTest.php | 7 +- .../DBAL/Schema/MySqlSchemaManagerTest.php | 7 +- .../DBAL/Schema/Platforms/MySQLSchemaTest.php | 8 +- .../Tests/DBAL/Schema/SchemaDiffTest.php | 6 +- .../Doctrine/Tests/DBAL/Schema/SchemaTest.php | 47 +-- .../Tests/DBAL/Schema/SequenceTest.php | 4 +- .../DBAL/Schema/SqliteSchemaManagerTest.php | 8 +- .../SingleDatabaseSynchronizerTest.php | 10 +- .../Tests/DBAL/Schema/TableDiffTest.php | 8 +- .../Doctrine/Tests/DBAL/Schema/TableTest.php | 111 +++---- .../Visitor/CreateSchemaSqlCollectorTest.php | 12 +- .../Visitor/DropSchemaSqlCollectorTest.php | 6 +- .../Visitor/RemoveNamespacedAssetsTest.php | 7 +- .../Schema/Visitor/SchemaSqlCollectorTest.php | 6 +- .../Sharding/PoolingShardConnectionTest.php | 30 +- .../DBAL/Sharding/PoolingShardManagerTest.php | 34 +-- .../Sharding/SQLAzure/AbstractTestCase.php | 5 +- .../DBAL/Sharding/SQLAzure/FunctionalTest.php | 3 +- .../SQLAzure/MultiTenantVisitorTest.php | 4 +- .../SQLAzureFederationsSynchronizerTest.php | 6 +- .../SQLAzure/SQLAzureShardManagerTest.php | 16 +- .../MultiTenantShardChoserTest.php | 4 +- tests/Doctrine/Tests/DBAL/StatementTest.php | 12 +- .../DBAL/Tools/Console/RunSqlCommandTest.php | 16 +- .../Doctrine/Tests/DBAL/Tools/DumperTest.php | 19 +- tests/Doctrine/Tests/DBAL/Types/ArrayTest.php | 13 +- .../Tests/DBAL/Types/BaseDateTypeTestCase.php | 19 +- .../Doctrine/Tests/DBAL/Types/BinaryTest.php | 19 +- tests/Doctrine/Tests/DBAL/Types/BlobTest.php | 11 +- .../Doctrine/Tests/DBAL/Types/BooleanTest.php | 8 +- .../DBAL/Types/ConversionExceptionTest.php | 15 +- .../DBAL/Types/DateImmutableTypeTest.php | 27 +- .../Tests/DBAL/Types/DateIntervalTest.php | 24 +- tests/Doctrine/Tests/DBAL/Types/DateTest.php | 11 +- .../DBAL/Types/DateTimeImmutableTypeTest.php | 27 +- .../Tests/DBAL/Types/DateTimeTest.php | 10 +- .../Types/DateTimeTzImmutableTypeTest.php | 25 +- .../Tests/DBAL/Types/DateTimeTzTest.php | 8 +- .../Doctrine/Tests/DBAL/Types/DecimalTest.php | 6 +- tests/Doctrine/Tests/DBAL/Types/FloatTest.php | 10 +- .../Tests/DBAL/Types/GuidTypeTest.php | 8 +- .../Doctrine/Tests/DBAL/Types/IntegerTest.php | 6 +- .../Tests/DBAL/Types/JsonArrayTest.php | 19 +- tests/Doctrine/Tests/DBAL/Types/JsonTest.php | 23 +- .../Doctrine/Tests/DBAL/Types/ObjectTest.php | 13 +- .../Tests/DBAL/Types/SmallIntTest.php | 6 +- .../Doctrine/Tests/DBAL/Types/StringTest.php | 12 +- .../DBAL/Types/TimeImmutableTypeTest.php | 27 +- tests/Doctrine/Tests/DBAL/Types/TimeTest.php | 8 +- .../Tests/DBAL/Types/TypeRegistryTest.php | 26 +- tests/Doctrine/Tests/DBAL/Types/TypeTest.php | 4 +- .../Types/VarDateTimeImmutableTypeTest.php | 22 +- .../Tests/DBAL/Types/VarDateTimeTest.php | 14 +- tests/Doctrine/Tests/DBAL/UtilTest.php | 4 +- .../Doctrine/Tests/DbalFunctionalTestCase.php | 10 +- .../Tests/DbalPerformanceTestCase.php | 8 +- .../Tests/DbalPerformanceTestListener.php | 3 +- tests/Doctrine/Tests/TestUtil.php | 43 +-- tests/Doctrine/Tests/Types/CommentedType.php | 1 + tests/Doctrine/Tests/Types/MySqlPointType.php | 1 + tests/continuousphp/bootstrap.php | 2 +- 324 files changed, 2653 insertions(+), 2380 deletions(-) diff --git a/composer.json b/composer.json index 788eb406c00..6cf85a3a2d6 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "doctrine/event-manager": "^1.0" }, "require-dev": { - "doctrine/coding-standard": "^7.0", + "doctrine/coding-standard": "^8.1", "jetbrains/phpstorm-stubs": "^2019.1", "nikic/php-parser": "^4.4", "phpstan/phpstan": "^0.12.31", diff --git a/composer.lock b/composer.lock index a606247d7fb..a6f7b2daffb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "dec9fb0cafafeca81a6e257452a8d7e2", + "content-hash": "8fe7de32ab1cec3ff8b2908b5b9e8de4", "packages": [ { "name": "doctrine/cache", @@ -477,22 +477,22 @@ }, { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.5.0", + "version": "v0.7.0", "source": { "type": "git", "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "e749410375ff6fb7a040a68878c656c2e610b132" + "reference": "e8d808670b8f882188368faaf1144448c169c0b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e749410375ff6fb7a040a68878c656c2e610b132", - "reference": "e749410375ff6fb7a040a68878c656c2e610b132", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e8d808670b8f882188368faaf1144448c169c0b7", + "reference": "e8d808670b8f882188368faaf1144448c169c0b7", "shasum": "" }, "require": { - "composer-plugin-api": "^1.0", - "php": "^5.3|^7", - "squizlabs/php_codesniffer": "^2|^3" + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2 || ^3 || 4.0.x-dev" }, "require-dev": { "composer/composer": "*", @@ -539,27 +539,27 @@ "stylecheck", "tests" ], - "time": "2018-10-26T13:21:45+00:00" + "time": "2020-06-25T14:57:39+00:00" }, { "name": "doctrine/coding-standard", - "version": "7.0.2", + "version": "8.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/coding-standard.git", - "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de" + "reference": "637003febec655f1b27f4301b44bf2264be57434" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/d8a60ec4da68025c42795b714f66e277dd3e11de", - "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de", + "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/637003febec655f1b27f4301b44bf2264be57434", + "reference": "637003febec655f1b27f4301b44bf2264be57434", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", - "php": "^7.2", - "slevomat/coding-standard": "^6.0", - "squizlabs/php_codesniffer": "^3.5.3" + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "php": "^7.2 || ^8.0", + "slevomat/coding-standard": "^6.3.9", + "squizlabs/php_codesniffer": "^3.5.5" }, "type": "phpcodesniffer-standard", "extra": { @@ -567,11 +567,6 @@ "dev-master": "7.0.x-dev" } }, - "autoload": { - "psr-4": { - "Doctrine\\Sniffs\\": "lib/Doctrine/Sniffs" - } - }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" @@ -600,7 +595,7 @@ "standard", "style" ], - "time": "2019-12-11T07:59:21+00:00" + "time": "2020-07-05T20:35:22+00:00" }, { "name": "doctrine/instantiator", diff --git a/lib/Doctrine/DBAL/Cache/ArrayStatement.php b/lib/Doctrine/DBAL/Cache/ArrayStatement.php index 5b72e599ac3..ef64e7cccfa 100644 --- a/lib/Doctrine/DBAL/Cache/ArrayStatement.php +++ b/lib/Doctrine/DBAL/Cache/ArrayStatement.php @@ -8,6 +8,7 @@ use InvalidArgumentException; use IteratorAggregate; use PDO; + use function array_merge; use function array_values; use function count; diff --git a/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php b/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php index aef70b4624b..cebffa565c0 100644 --- a/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php +++ b/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Cache; use Doctrine\Common\Cache\Cache; + use function hash; use function serialize; use function sha1; diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index cbb44a94a1a..f7a137fd816 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -10,6 +10,7 @@ use InvalidArgumentException; use IteratorAggregate; use PDO; + use function array_merge; use function array_values; use function assert; diff --git a/lib/Doctrine/DBAL/Configuration.php b/lib/Doctrine/DBAL/Configuration.php index 13260cd08bb..dcb93c39548 100644 --- a/lib/Doctrine/DBAL/Configuration.php +++ b/lib/Doctrine/DBAL/Configuration.php @@ -5,6 +5,7 @@ use Doctrine\Common\Cache\Cache; use Doctrine\DBAL\Logging\SQLLogger; use Doctrine\DBAL\Schema\AbstractAsset; + use function preg_match; /** @@ -101,7 +102,7 @@ public function getFilterSchemaAssetsExpression() /** * @param string $filterExpression */ - private function buildSchemaAssetsFilterFromExpression($filterExpression) : callable + private function buildSchemaAssetsFilterFromExpression($filterExpression): callable { return static function ($assetName) use ($filterExpression) { if ($assetName instanceof AbstractAsset) { @@ -115,7 +116,7 @@ private function buildSchemaAssetsFilterFromExpression($filterExpression) : call /** * Sets the callable to use to filter schema assets. */ - public function setSchemaAssetsFilter(?callable $callable = null) : ?callable + public function setSchemaAssetsFilter(?callable $callable = null): ?callable { $this->_attributes['filterSchemaAssetsExpression'] = null; @@ -125,7 +126,7 @@ public function setSchemaAssetsFilter(?callable $callable = null) : ?callable /** * Returns the callable to use to filter schema assets. */ - public function getSchemaAssetsFilter() : ?callable + public function getSchemaAssetsFilter(): ?callable { return $this->_attributes['filterSchemaAssetsExpressionCallable'] ?? null; } diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 8f3c16d7391..2e1965d43be 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -20,6 +20,7 @@ use Doctrine\DBAL\Types\Type; use Exception; use Throwable; + use function array_key_exists; use function assert; use function func_get_args; @@ -382,7 +383,7 @@ public function connect() * * @throws DBALException If an invalid platform was specified for this connection. */ - private function detectDatabasePlatform() : void + private function detectDatabasePlatform(): void { $version = $this->getDatabasePlatformVersion(); @@ -622,7 +623,7 @@ private function addIdentifierCondition( array &$columns, array &$values, array &$conditions - ) : void { + ): void { $platform = $this->getDatabasePlatform(); foreach ($identifier as $columnName => $value) { @@ -1323,7 +1324,7 @@ public function commit() /** * Commits all current nesting transactions. */ - private function commitAll() : void + private function commitAll(): void { while ($this->transactionNestingLevel !== 0) { if ($this->autoCommit === false && $this->transactionNestingLevel === 1) { diff --git a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php index 0a21d31b035..9362bc0c636 100644 --- a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php +++ b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Events; use InvalidArgumentException; + use function array_rand; use function assert; use function count; diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php index 30ada6c5ecd..dda63310675 100644 --- a/lib/Doctrine/DBAL/DBALException.php +++ b/lib/Doctrine/DBAL/DBALException.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Types\Type; use Exception; use Throwable; + use function array_map; use function bin2hex; use function get_class; @@ -37,7 +38,7 @@ public static function notSupported($method) return new self(sprintf("Operation '%s' is not supported by platform.", $method)); } - public static function invalidPlatformSpecified() : self + public static function invalidPlatformSpecified(): self { return new self( "Invalid 'platform' option specified, need to give an instance of " . AbstractPlatform::class . '.' @@ -47,7 +48,7 @@ public static function invalidPlatformSpecified() : self /** * @param mixed $invalidPlatform */ - public static function invalidPlatformType($invalidPlatform) : self + public static function invalidPlatformType($invalidPlatform): self { if (is_object($invalidPlatform)) { return new self( @@ -285,12 +286,12 @@ public static function typeNotFound($name) return new self('Type to be overwritten ' . $name . ' does not exist.'); } - public static function typeNotRegistered(Type $type) : self + public static function typeNotRegistered(Type $type): self { return new self(sprintf('Type of the class %s@%s is not registered.', get_class($type), spl_object_hash($type))); } - public static function typeAlreadyRegistered(Type $type) : self + public static function typeAlreadyRegistered(Type $type): self { return new self( sprintf('Type of the class %s@%s is already registered.', get_class($type), spl_object_hash($type)) diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index e31ea3a3ebd..7b454df5882 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Schema\MySqlSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; + use function assert; use function preg_match; use function stripos; @@ -143,13 +144,15 @@ public function createDatabasePlatformForVersion($version) * * @throws DBALException */ - private function getOracleMysqlVersionNumber(string $versionString) : string + private function getOracleMysqlVersionNumber(string $versionString): string { - if (! preg_match( - '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?/', - $versionString, - $versionParts - )) { + if ( + ! preg_match( + '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?/', + $versionString, + $versionParts + ) + ) { throw DBALException::invalidPlatformVersionSpecified( $versionString, '..' @@ -175,13 +178,15 @@ private function getOracleMysqlVersionNumber(string $versionString) : string * * @throws DBALException */ - private function getMariaDbMysqlVersionNumber(string $versionString) : string + private function getMariaDbMysqlVersionNumber(string $versionString): string { - if (! preg_match( - '/^(?:5\.5\.5-)?(mariadb-)?(?P\d+)\.(?P\d+)\.(?P\d+)/i', - $versionString, - $versionParts - )) { + if ( + ! preg_match( + '/^(?:5\.5\.5-)?(mariadb-)?(?P\d+)\.(?P\d+)\.(?P\d+)/i', + $versionString, + $versionParts + ) + ) { throw DBALException::invalidPlatformVersionSpecified( $versionString, '^(?:5\.5\.5-)?(mariadb-)?..' diff --git a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver/EasyConnectString.php b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver/EasyConnectString.php index 01f648b3b85..ba439744c01 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver/EasyConnectString.php +++ b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver/EasyConnectString.php @@ -23,7 +23,7 @@ private function __construct(string $string) $this->string = $string; } - public function __toString() : string + public function __toString(): string { return $this->string; } @@ -33,7 +33,7 @@ public function __toString() : string * * @param mixed[] $params */ - public static function fromArray(array $params) : self + public static function fromArray(array $params): self { return new self(self::renderParams($params)); } @@ -43,7 +43,7 @@ public static function fromArray(array $params) : self * * @param mixed[] $params */ - public static function fromConnectionParameters(array $params) : self + public static function fromConnectionParameters(array $params): self { if (! empty($params['connectstring'])) { return new self($params['connectstring']); @@ -90,7 +90,7 @@ public static function fromConnectionParameters(array $params) : self /** * @param mixed[] $params */ - private static function renderParams(array $params) : string + private static function renderParams(array $params): string { $chunks = []; @@ -110,7 +110,7 @@ private static function renderParams(array $params) : string /** * @param mixed $value */ - private static function renderValue($value) : string + private static function renderValue($value): string { if (is_array($value)) { return self::renderParams($value); diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index 46443a567be..9e293298133 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -13,6 +13,7 @@ use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Schema\PostgreSqlSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; + use function assert; use function preg_match; use function strpos; diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php index 4f5c6a1e4e4..5637f6bb987 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\SQLAnywherePlatform; use Doctrine\DBAL\Schema\SQLAnywhereSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; + use function assert; use function preg_match; use function version_compare; @@ -81,11 +82,13 @@ public function convertException($message, DriverException $exception) */ public function createDatabasePlatformForVersion($version) { - if (! preg_match( - '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?)?/', - $version, - $versionParts - )) { + if ( + ! preg_match( + '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?)?/', + $version, + $versionParts + ) + ) { throw DBALException::invalidPlatformVersionSpecified( $version, '...' diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php index 57a4189188f..ef8c4a563e4 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Schema\SQLServerSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; + use function assert; use function preg_match; use function version_compare; @@ -25,11 +26,13 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr */ public function createDatabasePlatformForVersion($version) { - if (! preg_match( - '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?)?/', - $version, - $versionParts - )) { + if ( + ! preg_match( + '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?)?/', + $version, + $versionParts + ) + ) { throw DBALException::invalidPlatformVersionSpecified( $version, '...' diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/PortWithoutHost.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/PortWithoutHost.php index 53b7610ade0..e968421fe7a 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/PortWithoutHost.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/PortWithoutHost.php @@ -13,7 +13,7 @@ */ final class PortWithoutHost extends AbstractDriverException { - public static function new() : self + public static function new(): self { return new self('Connection port specified without the host'); } diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php index 7ba260b99dd..f0ff91a1255 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\SqliteSchemaManager; + use function strpos; /** @@ -25,7 +26,8 @@ public function convertException($message, DriverException $exception) return new Exception\LockWaitTimeoutException($message, $exception); } - if (strpos($exception->getMessage(), 'must be unique') !== false || + if ( + strpos($exception->getMessage(), 'must be unique') !== false || strpos($exception->getMessage(), 'is not unique') !== false || strpos($exception->getMessage(), 'are not unique') !== false || strpos($exception->getMessage(), 'UNIQUE constraint failed') !== false @@ -33,7 +35,8 @@ public function convertException($message, DriverException $exception) return new Exception\UniqueConstraintViolationException($message, $exception); } - if (strpos($exception->getMessage(), 'may not be NULL') !== false || + if ( + strpos($exception->getMessage(), 'may not be NULL') !== false || strpos($exception->getMessage(), 'NOT NULL constraint failed') !== false ) { return new Exception\NotNullConstraintViolationException($message, $exception); diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php index 841ea4c9c61..493efb7716a 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; use stdClass; + use function assert; use function db2_autocommit; use function db2_commit; @@ -23,6 +24,7 @@ use function db2_stmt_errormsg; use function func_get_args; use function is_bool; + use const DB2_AUTOCOMMIT_OFF; use const DB2_AUTOCOMMIT_ON; diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index 60652060c5c..302e759af2c 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -12,6 +12,7 @@ use ReflectionObject; use ReflectionProperty; use stdClass; + use function array_change_key_case; use function assert; use function db2_bind_param; @@ -41,6 +42,7 @@ use function stream_get_meta_data; use function strtolower; use function tmpfile; + use const CASE_LOWER; use const DB2_BINARY; use const DB2_CHAR; @@ -138,7 +140,7 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l * * @throws DB2Exception */ - private function bind($position, &$variable, int $parameterType, int $dataType) : void + private function bind($position, &$variable, int $parameterType, int $dataType): void { $this->bindParam[$position] =& $variable; @@ -443,7 +445,7 @@ private function createTemporaryFile() * * @throws DB2Exception */ - private function copyStreamToStream($source, $target) : void + private function copyStreamToStream($source, $target): void { if (@stream_copy_to_stream($source, $target) === false) { throw new DB2Exception('Could not copy source stream to temporary file: ' . error_get_last()['message']); @@ -455,7 +457,7 @@ private function copyStreamToStream($source, $target) : void * * @throws DB2Exception */ - private function writeStringToStream(string $string, $target) : void + private function writeStringToStream(string $string, $target): void { if (@fwrite($target, $string) === false) { throw new DB2Exception('Could not write string to temporary file: ' . error_get_last()['message']); diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DataSourceName.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DataSourceName.php index c4dfc1f9ab3..e1ec42f2d84 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DataSourceName.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DataSourceName.php @@ -21,7 +21,7 @@ private function __construct(string $string) $this->string = $string; } - public function toString() : string + public function toString(): string { return $this->string; } @@ -31,7 +31,7 @@ public function toString() : string * * @param array $params */ - public static function fromArray(array $params) : self + public static function fromArray(array $params): self { $chunks = []; @@ -47,7 +47,7 @@ public static function fromArray(array $params) : self * * @param array $params */ - public static function fromConnectionParameters(array $params) : self + public static function fromConnectionParameters(array $params): self { if (isset($params['dbname']) && strpos($params['dbname'], '=') !== false) { return new self($params['dbname']); @@ -55,14 +55,16 @@ public static function fromConnectionParameters(array $params) : self $dsnParams = []; - foreach ([ - 'host' => 'HOSTNAME', - 'port' => 'PORT', - 'protocol' => 'PROTOCOL', - 'dbname' => 'DATABASE', - 'user' => 'UID', - 'password' => 'PWD', - ] as $dbalParam => $dsnParam) { + foreach ( + [ + 'host' => 'HOSTNAME', + 'port' => 'PORT', + 'protocol' => 'PROTOCOL', + 'dbname' => 'DATABASE', + 'user' => 'UID', + 'password' => 'PWD', + ] as $dbalParam => $dsnParam + ) { if (! isset($params[$dbalParam])) { continue; } diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index 11cad6101ec..ae9b4fef7a7 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; use mysqli; + use function defined; use function floor; use function func_get_args; @@ -20,6 +21,7 @@ use function set_error_handler; use function sprintf; use function stripos; + use const MYSQLI_INIT_COMMAND; use const MYSQLI_OPT_CONNECT_TIMEOUT; use const MYSQLI_OPT_LOCAL_INFILE; @@ -226,7 +228,7 @@ public function errorInfo() * @throws MysqliException When one of of the options is not supported. * @throws MysqliException When applying doesn't work - e.g. due to incorrect value. */ - private function setDriverOptions(array $driverOptions = []) : void + private function setDriverOptions(array $driverOptions = []): void { $supportedDriverOptions = [ MYSQLI_OPT_CONNECT_TIMEOUT, @@ -285,9 +287,10 @@ public function ping() * * @throws MysqliException */ - private function setSecureConnection(array $params) : void + private function setSecureConnection(array $params): void { - if (! isset($params['ssl_key']) && + if ( + ! isset($params['ssl_key']) && ! isset($params['ssl_cert']) && ! isset($params['ssl_ca']) && ! isset($params['ssl_capath']) && diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index e45e1235843..be852c1873a 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -11,6 +11,7 @@ use mysqli; use mysqli_stmt; use PDO; + use function array_combine; use function array_fill; use function assert; @@ -207,7 +208,7 @@ public function execute($params = null) /** * Binds parameters with known types previously bound to the statement */ - private function bindTypedParameters() : void + private function bindTypedParameters(): void { $streams = $values = []; $types = $this->types; @@ -250,7 +251,7 @@ private function bindTypedParameters() : void * * @throws MysqliException */ - private function sendLongData(array $streams) : void + private function sendLongData(array $streams): void { foreach ($streams as $paramNr => $stream) { while (! feof($stream)) { diff --git a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php index 0f2ebf362cb..b749154845e 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractOracleDriver; + use const OCI_NO_AUTO_COMMIT; /** diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index 36376bc731b..eb31ace09e5 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; use UnexpectedValueException; + use function addcslashes; use function func_get_args; use function is_float; @@ -19,6 +20,7 @@ use function preg_match; use function sprintf; use function str_replace; + use const OCI_COMMIT_ON_SUCCESS; use const OCI_NO_AUTO_COMMIT; diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index 74607ddec76..b0ccceaccd1 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -9,6 +9,7 @@ use InvalidArgumentException; use IteratorAggregate; use PDO; + use function array_key_exists; use function assert; use function count; @@ -30,6 +31,7 @@ use function preg_quote; use function sprintf; use function substr; + use const OCI_ASSOC; use const OCI_B_BIN; use const OCI_B_BLOB; @@ -311,7 +313,7 @@ public function bindParam($param, &$variable, $type = ParameterType::STRING, $le /** * Converts DBAL parameter type to oci8 parameter type */ - private function convertParameterType(int $type) : int + private function convertParameterType(int $type): int { switch ($type) { case ParameterType::BINARY: diff --git a/lib/Doctrine/DBAL/Driver/PDOConnection.php b/lib/Doctrine/DBAL/Driver/PDOConnection.php index 0248e65c2c4..7c38b4398e5 100644 --- a/lib/Doctrine/DBAL/Driver/PDOConnection.php +++ b/lib/Doctrine/DBAL/Driver/PDOConnection.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\ParameterType; use PDO; + use function assert; use function func_get_args; diff --git a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php index f25cd5cded3..43f06cb7b7f 100644 --- a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\PDOConnection; use PDO; use PDOException; + use function defined; /** @@ -27,7 +28,8 @@ public function connect(array $params, $username = null, $password = null, array $driverOptions ); - if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES') + if ( + defined('PDO::PGSQL_ATTR_DISABLE_PREPARES') && (! isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES]) || $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES] === true ) diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php index d08c6a2c848..4566f649578 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\Platforms\SqlitePlatform; use PDOException; + use function array_merge; /** diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php index 955ce507985..880f1263da0 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Driver\AbstractSQLServerDriver; use Doctrine\DBAL\Driver\AbstractSQLServerDriver\PortWithoutHost; + use function is_int; use function sprintf; @@ -73,7 +74,7 @@ private function _constructPdoDsn(array $params, array $connectionOptions) * * @param string[] $connectionOptions */ - private function getConnectionOptionsDsn(array $connectionOptions) : string + private function getConnectionOptionsDsn(array $connectionOptions): string { $connectionOptionsDsn = ''; diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php index 6803bb14ed7..8d6521ff56c 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php @@ -16,7 +16,8 @@ class Statement extends PDOStatement */ public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null, $driverOptions = null) { - if (($type === ParameterType::LARGE_OBJECT || $type === ParameterType::BINARY) + if ( + ($type === ParameterType::LARGE_OBJECT || $type === ParameterType::BINARY) && $driverOptions === null ) { $driverOptions = PDO::SQLSRV_ENCODING_BINARY; diff --git a/lib/Doctrine/DBAL/Driver/PDOStatement.php b/lib/Doctrine/DBAL/Driver/PDOStatement.php index c7db7d4eb87..e0e8b66cccd 100644 --- a/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -5,12 +5,14 @@ use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; use PDO; + use function array_slice; use function assert; use function func_get_args; use function is_array; use function sprintf; use function trigger_error; + use const E_USER_DEPRECATED; /** @@ -196,7 +198,7 @@ public function fetchColumn($columnIndex = 0) * * @param int $type Parameter type */ - private function convertParamType(int $type) : int + private function convertParamType(int $type): int { if (! isset(self::PARAM_TYPE_MAP[$type])) { // TODO: next major: throw an exception @@ -216,7 +218,7 @@ private function convertParamType(int $type) : int * * @param int $fetchMode Fetch mode */ - private function convertFetchMode(int $fetchMode) : int + private function convertFetchMode(int $fetchMode): int { if (! isset(self::FETCH_MODE_MAP[$fetchMode])) { // TODO: next major: throw an exception diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php index 9564dc2981d..5ec94f6c9a0 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver; + use function array_keys; use function array_map; use function implode; diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php index d47782003e6..10e284efd78 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; + use function assert; use function func_get_args; use function is_float; diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php index 022cfe2dfa7..5446a3b142c 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Driver\AbstractDriverException; use InvalidArgumentException; + use function sasql_error; use function sasql_errorcode; use function sasql_sqlstate; diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php index 7850d704171..45e414acfde 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php @@ -11,6 +11,7 @@ use ReflectionClass; use ReflectionObject; use stdClass; + use function array_key_exists; use function assert; use function func_get_args; @@ -35,6 +36,7 @@ use function sasql_stmt_reset; use function sasql_stmt_result_metadata; use function sprintf; + use const SASQL_BOTH; /** diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php index 5f3f1a8f524..7200c71eecf 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; + use function func_get_args; use function is_float; use function is_int; @@ -19,6 +20,7 @@ use function sqlsrv_rows_affected; use function sqlsrv_server_info; use function str_replace; + use const SQLSRV_ERR_ERRORS; /** diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php index 4dfe548f87a..af70c6852ff 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php @@ -3,8 +3,10 @@ namespace Doctrine\DBAL\Driver\SQLSrv; use Doctrine\DBAL\Driver\AbstractDriverException; + use function rtrim; use function sqlsrv_errors; + use const SQLSRV_ERR_ERRORS; /** diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index e728575fa4f..9687b5c0fbb 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; + use function array_key_exists; use function count; use function func_get_args; @@ -28,6 +29,7 @@ use function sqlsrv_rows_affected; use function SQLSRV_SQLTYPE_VARBINARY; use function stripos; + use const SQLSRV_ENC_BINARY; use const SQLSRV_ERR_ERRORS; use const SQLSRV_FETCH_ASSOC; diff --git a/lib/Doctrine/DBAL/DriverManager.php b/lib/Doctrine/DBAL/DriverManager.php index d3ed63a7f39..f7462bbd462 100644 --- a/lib/Doctrine/DBAL/DriverManager.php +++ b/lib/Doctrine/DBAL/DriverManager.php @@ -15,6 +15,7 @@ use Doctrine\DBAL\Driver\SQLAnywhere\Driver as SQLAnywhereDriver; use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; use PDO; + use function array_keys; use function array_map; use function array_merge; @@ -129,7 +130,7 @@ public static function getConnection( array $params, ?Configuration $config = null, ?EventManager $eventManager = null - ) : Connection { + ): Connection { // create default config and event manager, if not set if (! $config) { $config = new Configuration(); @@ -196,7 +197,7 @@ public static function getConnection( * * @return string[] */ - public static function getAvailableDrivers() : array + public static function getAvailableDrivers(): array { return array_keys(self::$_driverMap); } @@ -208,7 +209,7 @@ public static function getAvailableDrivers() : array * * @throws DBALException */ - private static function _checkParams(array $params) : void + private static function _checkParams(array $params): void { // check existence of mandatory parameters @@ -234,7 +235,7 @@ private static function _checkParams(array $params) : void * * @return string The normalized connection URL path */ - private static function normalizeDatabaseUrlPath(string $urlPath) : string + private static function normalizeDatabaseUrlPath(string $urlPath): string { // Trim leading slash from URL path. return substr($urlPath, 1); @@ -251,7 +252,7 @@ private static function normalizeDatabaseUrlPath(string $urlPath) : string * * @throws DBALException */ - private static function parseDatabaseUrl(array $params) : array + private static function parseDatabaseUrl(array $params): array { if (! isset($params['url'])) { return $params; @@ -310,7 +311,7 @@ private static function parseDatabaseUrl(array $params) : array * * @return mixed[] The resolved connection parameters. */ - private static function parseDatabaseUrlPath(array $url, array $params) : array + private static function parseDatabaseUrlPath(array $url, array $params): array { if (! isset($url['path'])) { return $params; @@ -339,7 +340,7 @@ private static function parseDatabaseUrlPath(array $url, array $params) : array * * @return mixed[] The resolved connection parameters. */ - private static function parseDatabaseUrlQuery(array $url, array $params) : array + private static function parseDatabaseUrlQuery(array $url, array $params): array { if (! isset($url['query'])) { return $params; @@ -364,7 +365,7 @@ private static function parseDatabaseUrlQuery(array $url, array $params) : array * * @return mixed[] The resolved connection parameters. */ - private static function parseRegularDatabaseUrlPath(array $url, array $params) : array + private static function parseRegularDatabaseUrlPath(array $url, array $params): array { $params['dbname'] = $url['path']; @@ -383,7 +384,7 @@ private static function parseRegularDatabaseUrlPath(array $url, array $params) : * * @return mixed[] The resolved connection parameters. */ - private static function parseSqliteDatabaseUrlPath(array $url, array $params) : array + private static function parseSqliteDatabaseUrlPath(array $url, array $params): array { if ($url['path'] === ':memory:') { $params['memory'] = true; @@ -406,7 +407,7 @@ private static function parseSqliteDatabaseUrlPath(array $url, array $params) : * * @throws DBALException If parsing failed or resolution is not possible. */ - private static function parseDatabaseUrlScheme(array $url, array $params) : array + private static function parseDatabaseUrlScheme(array $url, array $params): array { if (isset($url['scheme'])) { // The requested driver from the URL scheme takes precedence diff --git a/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php b/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php index abcf42a5ac9..3e382f72c61 100644 --- a/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php +++ b/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php @@ -5,10 +5,12 @@ use Doctrine\Common\EventSubscriber; use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Events; + use function array_change_key_case; use function array_merge; use function count; use function implode; + use const CASE_UPPER; /** diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php index 1aee06f8e27..1460d0bf1d9 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php index e806c9a6cb1..ac01acccbed 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\TableDiff; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php index 505d2a3600a..cde0cc553af 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\TableDiff; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php index 7a2fe596a46..f9413e37068 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php index 3f65e62ecab..b1c015115f9 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php index d24ff439595..ce88deda5cc 100644 --- a/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Table; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php index ee4061b4543..3fd8149f5f8 100644 --- a/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Table; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Id/TableGenerator.php b/lib/Doctrine/DBAL/Id/TableGenerator.php index 97bc70282f3..a3f7c12dd94 100644 --- a/lib/Doctrine/DBAL/Id/TableGenerator.php +++ b/lib/Doctrine/DBAL/Id/TableGenerator.php @@ -8,9 +8,11 @@ use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\LockMode; use Throwable; + use function array_change_key_case; use function assert; use function is_int; + use const CASE_LOWER; /** diff --git a/lib/Doctrine/DBAL/Internal/DependencyOrderCalculator.php b/lib/Doctrine/DBAL/Internal/DependencyOrderCalculator.php index c1026993be8..55b70c190ab 100644 --- a/lib/Doctrine/DBAL/Internal/DependencyOrderCalculator.php +++ b/lib/Doctrine/DBAL/Internal/DependencyOrderCalculator.php @@ -35,7 +35,7 @@ final class DependencyOrderCalculator /** * Checks for node (vertex) existence in graph. */ - public function hasNode(string $hash) : bool + public function hasNode(string $hash): bool { return isset($this->nodeList[$hash]); } @@ -45,7 +45,7 @@ public function hasNode(string $hash) : bool * * @param object $node */ - public function addNode(string $hash, $node) : void + public function addNode(string $hash, $node): void { $vertex = new DependencyOrderNode(); @@ -59,7 +59,7 @@ public function addNode(string $hash, $node) : void /** * Adds a new dependency (edge) to the graph using their hashes. */ - public function addDependency(string $fromHash, string $toHash) : void + public function addDependency(string $fromHash, string $toHash): void { $vertex = $this->nodeList[$fromHash]; $edge = new DependencyOrderEdge(); @@ -78,7 +78,7 @@ public function addDependency(string $fromHash, string $toHash) : void * * @return array */ - public function sort() : array + public function sort(): array { foreach ($this->nodeList as $vertex) { if ($vertex->state !== self::NOT_VISITED) { @@ -101,7 +101,7 @@ public function sort() : array * * {@internal Highly performance-sensitive method.} */ - private function visit(DependencyOrderNode $vertex) : void + private function visit(DependencyOrderNode $vertex): void { $vertex->state = self::IN_PROGRESS; diff --git a/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php b/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php index c722797dd8b..a3228d3df93 100644 --- a/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php +++ b/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Logging; use function var_dump; + use const PHP_EOL; /** diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index b40e5219412..f0a4af8e1b0 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -28,6 +28,7 @@ use Doctrine\DBAL\Types\Type; use InvalidArgumentException; use UnexpectedValueException; + use function addcslashes; use function array_map; use function array_merge; @@ -54,6 +55,7 @@ use function strtolower; use function strtoupper; use function trigger_error; + use const E_USER_DEPRECATED; /** @@ -574,7 +576,7 @@ public function getSqlCommentEndString() /** * Gets the maximum length of a char field. */ - public function getCharMaxLength() : int + public function getCharMaxLength(): int { return $this->getVarcharMaxLength(); } @@ -1550,7 +1552,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE $options['indexes'] = []; $options['primary'] = []; - if (($createFlags&self::CREATE_INDEXES) > 0) { + if (($createFlags & self::CREATE_INDEXES) > 0) { foreach ($table->getIndexes() as $index) { if ($index->isPrimary()) { $options['primary'] = $index->getQuotedColumns($this); @@ -1592,7 +1594,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE $columns[$columnData['name']] = $columnData; } - if (($createFlags&self::CREATE_FOREIGNKEYS) > 0) { + if (($createFlags & self::CREATE_FOREIGNKEYS) > 0) { $options['foreignKeys'] = []; foreach ($table->getForeignKeys() as $fkConstraint) { $options['foreignKeys'][] = $fkConstraint; @@ -1628,7 +1630,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE return array_merge($sql, $columnSql); } - protected function getCommentOnTableSQL(string $tableName, ?string $comment) : string + protected function getCommentOnTableSQL(string $tableName, ?string $comment): string { $tableName = new Identifier($tableName); @@ -2437,7 +2439,7 @@ public function getCustomTypeDeclarationSQL(array $columnDef) * * @param mixed[]|Index $columnsOrIndex array declaration is deprecated, prefer passing Index to this method */ - public function getIndexFieldDeclarationListSQL($columnsOrIndex) : string + public function getIndexFieldDeclarationListSQL($columnsOrIndex): string { if ($columnsOrIndex instanceof Index) { return implode(', ', $columnsOrIndex->getQuotedColumns($this)); @@ -2692,7 +2694,7 @@ public function convertBooleans($item) */ public function convertFromBoolean($item) { - return $item === null ? null: (bool) $item; + return $item === null ? null : (bool) $item; } /** @@ -3133,7 +3135,7 @@ public function supportsPartialIndexes() /** * Whether the platform supports indexes with column length definitions. */ - public function supportsColumnLengthIndexes() : bool + public function supportsColumnLengthIndexes(): bool { return false; } @@ -3203,7 +3205,7 @@ public function supportsForeignKeyConstraints() * * If false, then getDropForeignKeySQL() throws exception. */ - public function supportsCreateDropForeignKeyConstraints() : bool + public function supportsCreateDropForeignKeyConstraints(): bool { return true; } @@ -3646,7 +3648,7 @@ public function getStringLiteralQuoteCharacter() * @param string $escapeChar should be reused by the caller in the LIKE * expression. */ - final public function escapeStringForLike(string $inputString, string $escapeChar) : string + final public function escapeStringForLike(string $inputString, string $escapeChar): string { return preg_replace( '~([' . preg_quote($this->getLikeWildcardCharacters() . $escapeChar, '~') . '])~u', @@ -3655,7 +3657,7 @@ final public function escapeStringForLike(string $inputString, string $escapeCha ); } - protected function getLikeWildcardCharacters() : string + protected function getLikeWildcardCharacters(): string { return '%_'; } diff --git a/lib/Doctrine/DBAL/Platforms/DB2Platform.php b/lib/Doctrine/DBAL/Platforms/DB2Platform.php index 6f3931ec84c..297e43ced6a 100644 --- a/lib/Doctrine/DBAL/Platforms/DB2Platform.php +++ b/lib/Doctrine/DBAL/Platforms/DB2Platform.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; + use function array_merge; use function count; use function current; @@ -22,7 +23,7 @@ class DB2Platform extends AbstractPlatform { - public function getCharMaxLength() : int + public function getCharMaxLength(): int { return 254; } @@ -523,7 +524,8 @@ public function getAlterTableSQL(TableDiff $diff) $queryPart = 'ADD COLUMN ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnDef); // Adding non-nullable columns to a table requires a default value to be specified. - if (! empty($columnDef['notnull']) && + if ( + ! empty($columnDef['notnull']) && ! isset($columnDef['default']) && empty($columnDef['autoincrement']) ) { @@ -626,7 +628,7 @@ public function getAlterTableSQL(TableDiff $diff) * @param string[] $sql The sequence of table alteration statements to fill. * @param mixed[] $queryParts The sequence of column alteration clauses to fill. */ - private function gatherAlterColumnSQL(Identifier $table, ColumnDiff $columnDiff, array &$sql, array &$queryParts) : void + private function gatherAlterColumnSQL(Identifier $table, ColumnDiff $columnDiff, array &$sql, array &$queryParts): void { $alterColumnClauses = $this->getAlterColumnClausesSQL($columnDiff); @@ -668,7 +670,8 @@ private function getAlterColumnClausesSQL(ColumnDiff $columnDiff) $clauses = []; - if ($columnDiff->hasChanged('type') || + if ( + $columnDiff->hasChanged('type') || $columnDiff->hasChanged('length') || $columnDiff->hasChanged('precision') || $columnDiff->hasChanged('scale') || @@ -901,7 +904,7 @@ protected function getReservedKeywordsClass() return Keywords\DB2Keywords::class; } - public function getListTableCommentsSQL(string $table) : string + public function getListTableCommentsSQL(string $table): string { return sprintf( <<<'SQL' diff --git a/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php b/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php index f796a48c786..78d44e3948c 100644 --- a/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Types\BinaryType; use InvalidArgumentException; + use function array_merge; use function array_unique; use function array_values; @@ -518,7 +519,8 @@ public function getAlterTableSQL(TableDiff $diff) // Do not generate column alteration clause if type is binary and only fixed property has changed. // Drizzle only supports binary type columns with variable length. // Avoids unnecessary table alteration statements. - if ($columnArray['type'] instanceof BinaryType && + if ( + $columnArray['type'] instanceof BinaryType && $columnDiff->hasChanged('fixed') && count($columnDiff->changedProperties) === 1 ) { diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php index 0efd5f9a7fc..8cb2befe8e9 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php @@ -9,7 +9,7 @@ */ final class MariaDb102Keywords extends MySQLKeywords { - public function getName() : string + public function getName(): string { return 'MariaDb102'; } @@ -17,7 +17,7 @@ public function getName() : string /** * {@inheritdoc} */ - protected function getKeywords() : array + protected function getKeywords(): array { return [ 'ACCESSIBLE', diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php index 07d87efba30..dad68ead2df 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php @@ -9,7 +9,7 @@ */ class PostgreSQL100Keywords extends PostgreSQL94Keywords { - public function getName() : string + public function getName(): string { return 'PostgreSQL100'; } diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php b/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php index 68cdf3d15d8..c9053125d7f 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Visitor\Visitor; + use function implode; use function str_replace; diff --git a/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php b/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php index 2fff4e87ee7..03b59e2322e 100644 --- a/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php +++ b/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php @@ -16,17 +16,17 @@ final class MariaDb1027Platform extends MySqlPlatform * * @link https://mariadb.com/kb/en/library/json-data-type/ */ - public function getJsonTypeDeclarationSQL(array $field) : string + public function getJsonTypeDeclarationSQL(array $field): string { return 'LONGTEXT'; } - protected function getReservedKeywordsClass() : string + protected function getReservedKeywordsClass(): string { return Keywords\MariaDb102Keywords::class; } - protected function initializeDoctrineTypeMappings() : void + protected function initializeDoctrineTypeMappings(): void { parent::initializeDoctrineTypeMappings(); diff --git a/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php b/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php index 6c8defc7e07..efda7ee0017 100644 --- a/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\TextType; use InvalidArgumentException; + use function array_diff_key; use function array_merge; use function array_unique; @@ -383,7 +384,7 @@ public function getListTableColumnsSQL($table, $database = null) ' ORDER BY ORDINAL_POSITION ASC'; } - public function getListTableMetadataSQL(string $table, ?string $database = null) : string + public function getListTableMetadataSQL(string $table, ?string $database = null): string { return sprintf( <<<'SQL' @@ -587,7 +588,8 @@ public function getAlterTableSQL(TableDiff $diff) $columnArray = $column->toArray(); // Don't propagate default value changes for unsupported column types. - if ($columnDiff->hasChanged('default') && + if ( + $columnDiff->hasChanged('default') && count($columnDiff->changedProperties) === 1 && ($columnArray['type'] instanceof TextType || $columnArray['type'] instanceof BlobType) ) { @@ -1184,7 +1186,7 @@ public function getDefaultTransactionIsolationLevel() return TransactionIsolationLevel::REPEATABLE_READ; } - public function supportsColumnLengthIndexes() : bool + public function supportsColumnLengthIndexes(): bool { return true; } diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index 2f7d789584a..279b47d91b1 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\BinaryType; use InvalidArgumentException; + use function array_merge; use function count; use function explode; @@ -394,8 +395,10 @@ protected function _getCreateTableSQL($table, array $columns, array $options = [ $sql[] = $this->getCreateSequenceSQL($column['sequence']); } - if (! isset($column['autoincrement']) || ! $column['autoincrement'] && - (! isset($column['autoinc']) || ! $column['autoinc'])) { + if ( + ! isset($column['autoincrement']) || ! $column['autoincrement'] && + (! isset($column['autoinc']) || ! $column['autoinc']) + ) { continue; } @@ -592,7 +595,7 @@ private function normalizeIdentifier($name) * if the new string exceeds max identifier length, * keeps $suffix, cuts from $identifier as much as the part exceeding. */ - private function addSuffix(string $identifier, string $suffix) : string + private function addSuffix(string $identifier, string $suffix): string { $maxPossibleLengthWithoutSuffix = $this->getMaxIdentifierLength() - strlen($suffix); if (strlen($identifier) > $maxPossibleLengthWithoutSuffix) { @@ -830,7 +833,8 @@ public function getAlterTableSQL(TableDiff $diff) // Do not generate column alteration clause if type is binary and only fixed property has changed. // Oracle only supports binary type columns with variable length. // Avoids unnecessary table alteration statements. - if ($column->getType() instanceof BinaryType && + if ( + $column->getType() instanceof BinaryType && $columnDiff->hasChanged('fixed') && count($columnDiff->changedProperties) === 1 ) { @@ -1206,7 +1210,7 @@ public function getBlobTypeDeclarationSQL(array $field) return 'BLOB'; } - public function getListTableCommentsSQL(string $table, ?string $database = null) : string + public function getListTableCommentsSQL(string $table, ?string $database = null): string { $tableCommentsName = 'user_tab_comments'; $ownerCondition = ''; diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php b/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php index 957f9f42458..f5610056230 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php @@ -11,7 +11,7 @@ */ class PostgreSQL100Platform extends PostgreSQL94Platform { - protected function getReservedKeywordsClass() : string + protected function getReservedKeywordsClass(): string { return PostgreSQL100Keywords::class; } @@ -19,7 +19,7 @@ protected function getReservedKeywordsClass() : string /** * {@inheritDoc} */ - public function getListSequencesSQL($database) : string + public function getListSequencesSQL($database): string { return 'SELECT sequence_name AS relname, sequence_schema AS schemaname, diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php b/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php index 1703056143f..a00e4fe2429 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\DBAL\Types\Types; + use function sprintf; /** diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php index 613f426da1d..f7fd003d0ba 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -15,6 +15,7 @@ use Doctrine\DBAL\Types\IntegerType; use Doctrine\DBAL\Types\Type; use UnexpectedValueException; + use function array_diff; use function array_merge; use function array_unique; @@ -113,7 +114,7 @@ public function getLocateExpression($str, $substr, $startPos = false) if ($startPos !== false) { $str = $this->getSubstringExpression($str, $startPos); - return 'CASE WHEN (POSITION(' . $substr . ' IN ' . $str . ') = 0) THEN 0 ELSE (POSITION(' . $substr . ' IN ' . $str . ') + ' . ($startPos-1) . ') END'; + return 'CASE WHEN (POSITION(' . $substr . ' IN ' . $str . ') = 0) THEN 0 ELSE (POSITION(' . $substr . ' IN ' . $str . ') + ' . ($startPos - 1) . ') END'; } return 'POSITION(' . $substr . ' IN ' . $str . ')'; @@ -480,7 +481,8 @@ public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey $query .= ' NOT DEFERRABLE'; } - if (($foreignKey->hasOption('feferred') && $foreignKey->getOption('feferred') !== false) + if ( + ($foreignKey->hasOption('feferred') && $foreignKey->getOption('feferred') !== false) || ($foreignKey->hasOption('deferred') && $foreignKey->getOption('deferred') !== false) ) { $query .= ' INITIALLY DEFERRED'; @@ -1222,7 +1224,7 @@ public function getDefaultValueDeclarationSQL($field) /** * @param mixed[] $field */ - private function isSerialField(array $field) : bool + private function isSerialField(array $field): bool { return isset($field['type'], $field['autoincrement']) && $field['autoincrement'] === true @@ -1232,7 +1234,7 @@ private function isSerialField(array $field) : bool /** * Check whether the type of a column is changed in a way that invalidates the default value for the column */ - private function typeChangeBreaksDefaultValue(ColumnDiff $columnDiff) : bool + private function typeChangeBreaksDefaultValue(ColumnDiff $columnDiff): bool { if (! $columnDiff->fromColumn) { return $columnDiff->hasChanged('type'); @@ -1246,17 +1248,17 @@ private function typeChangeBreaksDefaultValue(ColumnDiff $columnDiff) : bool && ! ($oldTypeIsNumeric && $newTypeIsNumeric && $columnDiff->column->getAutoincrement()); } - private function isNumericType(Type $type) : bool + private function isNumericType(Type $type): bool { return $type instanceof IntegerType || $type instanceof BigIntType; } - private function getOldColumnComment(ColumnDiff $columnDiff) : ?string + private function getOldColumnComment(ColumnDiff $columnDiff): ?string { return $columnDiff->fromColumn ? $this->getColumnComment($columnDiff->fromColumn) : null; } - public function getListTableMetadataSQL(string $table, ?string $schema = null) : string + public function getListTableMetadataSQL(string $table, ?string $schema = null): string { if ($schema !== null) { $table = $schema . '.' . $table; diff --git a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php index e9cb363c6b8..bde1a8313fa 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use InvalidArgumentException; + use function array_merge; use function array_unique; use function array_values; @@ -1333,7 +1334,7 @@ protected function doModifyLimitQuery($query, $limit, $offset) return $matches[1] . $limitOffsetClause . ' ' . $matches[3]; } - private function getTopClauseSQL(?int $limit, ?int $offset) : string + private function getTopClauseSQL(?int $limit, ?int $offset): string { if ($offset > 0) { return sprintf('TOP %s START AT %d', $limit ?? 'ALL', $offset + 1); diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php index c2e36f34e67..3a3cac3145c 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php @@ -110,7 +110,7 @@ protected function getReservedKeywordsClass() return Keywords\SQLServer2008Keywords::class; } - protected function getLikeWildcardCharacters() : string + protected function getLikeWildcardCharacters(): string { return parent::getLikeWildcardCharacters() . '[]^'; } diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php index 0e1250542b6..4aa29f5ffb6 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php @@ -3,9 +3,11 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\DBAL\Schema\Sequence; + use function preg_match; use function preg_match_all; use function substr_count; + use const PREG_OFFSET_CAPTURE; /** @@ -108,7 +110,8 @@ protected function doModifyLimitQuery($query, $limit, $offset = null) $orderByPos = $matches[0][$matchesCount - 1][1]; } - if ($orderByPos === false + if ( + $orderByPos === false || substr_count($query, '(', $orderByPos) - substr_count($query, ')', $orderByPos) ) { if (preg_match('/^SELECT\s+DISTINCT/im', $query)) { diff --git a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php index 322fe1ec621..d4da5e0d386 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; use InvalidArgumentException; + use function array_merge; use function array_unique; use function array_values; @@ -1667,7 +1668,7 @@ private function generateIdentifierName($identifier) return strtoupper(dechex(crc32($identifier->getName()))); } - protected function getCommentOnTableSQL(string $tableName, ?string $comment) : string + protected function getCommentOnTableSQL(string $tableName, ?string $comment): string { return sprintf( <<<'SQL' @@ -1681,7 +1682,7 @@ protected function getCommentOnTableSQL(string $tableName, ?string $comment) : s ); } - public function getListTableMetadataSQL(string $table) : string + public function getListTableMetadataSQL(string $table): string { return sprintf( <<<'SQL' diff --git a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php index 3f8746cc14a..04c1fe50b57 100644 --- a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types; + use function array_merge; use function array_unique; use function array_values; @@ -376,7 +377,7 @@ protected function _getCreateTableSQL($name, array $columns, array $options = [] * @param mixed[][] $columns * @param mixed[] $options */ - private function getNonAutoincrementPrimaryKeyDefinition(array $columns, array $options) : string + private function getNonAutoincrementPrimaryKeyDefinition(array $columns, array $options): string { if (empty($options['primary'])) { return ''; @@ -622,7 +623,7 @@ public function getInlineColumnCommentSQL($comment) return '--' . str_replace("\n", "\n--", $comment) . "\n"; } - private function getInlineTableCommentSQL(string $comment) : string + private function getInlineTableCommentSQL(string $comment): string { return $this->getInlineColumnCommentSQL($comment); } @@ -776,7 +777,7 @@ public function supportsForeignKeyConstraints() return true; } - public function supportsCreateDropForeignKeyConstraints() : bool + public function supportsCreateDropForeignKeyConstraints(): bool { return false; } @@ -968,7 +969,8 @@ private function getSimpleAlterTableSQL(TableDiff $diff) { // Suppress changes on integer type autoincrement columns. foreach ($diff->changedColumns as $oldColumnName => $columnDiff) { - if (! $columnDiff->fromColumn instanceof Column || + if ( + ! $columnDiff->fromColumn instanceof Column || ! $columnDiff->column instanceof Column || ! $columnDiff->column->getAutoincrement() || ! $columnDiff->column->getType() instanceof Types\IntegerType @@ -991,7 +993,8 @@ private function getSimpleAlterTableSQL(TableDiff $diff) unset($diff->changedColumns[$oldColumnName]); } - if (! empty($diff->renamedColumns) || ! empty($diff->addedForeignKeys) || ! empty($diff->addedIndexes) + if ( + ! empty($diff->renamedColumns) || ! empty($diff->addedForeignKeys) || ! empty($diff->addedIndexes) || ! empty($diff->changedColumns) || ! empty($diff->changedForeignKeys) || ! empty($diff->changedIndexes) || ! empty($diff->removedColumns) || ! empty($diff->removedForeignKeys) || ! empty($diff->removedIndexes) || ! empty($diff->renamedIndexes) diff --git a/lib/Doctrine/DBAL/Portability/Connection.php b/lib/Doctrine/DBAL/Portability/Connection.php index ce8bfee248c..266b8ad095b 100644 --- a/lib/Doctrine/DBAL/Portability/Connection.php +++ b/lib/Doctrine/DBAL/Portability/Connection.php @@ -6,7 +6,9 @@ use Doctrine\DBAL\ColumnCase; use Doctrine\DBAL\Driver\PDOConnection; use PDO; + use function func_get_args; + use const CASE_LOWER; use const CASE_UPPER; diff --git a/lib/Doctrine/DBAL/Portability/Statement.php b/lib/Doctrine/DBAL/Portability/Statement.php index 514b3be2d74..624327a96b9 100644 --- a/lib/Doctrine/DBAL/Portability/Statement.php +++ b/lib/Doctrine/DBAL/Portability/Statement.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; + use function array_change_key_case; use function assert; use function is_string; @@ -136,7 +137,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX $row = $this->stmt->fetch($fetchMode); - $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM); + $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL | Connection::PORTABILITY_RTRIM); $fixCase = $this->case !== null && ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED) && ($this->portability & Connection::PORTABILITY_FIX_CASE); @@ -159,7 +160,7 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n $rows = $this->stmt->fetchAll($fetchMode); } - $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM); + $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL | Connection::PORTABILITY_RTRIM); $fixCase = $this->case !== null && ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED) && ($this->portability & Connection::PORTABILITY_FIX_CASE); @@ -224,7 +225,7 @@ public function fetchColumn($columnIndex = 0) { $value = $this->stmt->fetchColumn($columnIndex); - if ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM)) { + if ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL | Connection::PORTABILITY_RTRIM)) { if (($this->portability & Connection::PORTABILITY_EMPTY_TO_NULL) && $value === '') { $value = null; } elseif (($this->portability & Connection::PORTABILITY_RTRIM) && is_string($value)) { diff --git a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php index 96f94a36e66..234b61b61dd 100644 --- a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php +++ b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Query\Expression; use Countable; + use function count; use function implode; diff --git a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php index dfcc31ec709..e062a6fde7b 100644 --- a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php +++ b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Query\Expression; use Doctrine\DBAL\Connection; + use function func_get_arg; use function func_get_args; use function func_num_args; diff --git a/lib/Doctrine/DBAL/Query/QueryBuilder.php b/lib/Doctrine/DBAL/Query/QueryBuilder.php index 1dca7dbe959..bd792288b3e 100644 --- a/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Query\Expression\CompositeExpression; use Doctrine\DBAL\Query\Expression\ExpressionBuilder; + use function array_key_exists; use function array_keys; use function array_unshift; @@ -487,7 +488,7 @@ public function select($select = null) * * @return $this This QueryBuilder instance. */ - public function distinct() : self + public function distinct(): self { $this->sqlParts['distinct'] = true; @@ -1175,7 +1176,7 @@ private function getFromClauses() * * @throws QueryException */ - private function verifyAllAliasesAreKnown(array $knownAliases) : void + private function verifyAllAliasesAreKnown(array $knownAliases): void { foreach ($this->sqlParts['join'] as $fromAlias => $joins) { if (! isset($knownAliases[$fromAlias])) { diff --git a/lib/Doctrine/DBAL/Query/QueryException.php b/lib/Doctrine/DBAL/Query/QueryException.php index a9bb52d8102..76bb9ba7559 100644 --- a/lib/Doctrine/DBAL/Query/QueryException.php +++ b/lib/Doctrine/DBAL/Query/QueryException.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Query; use Doctrine\DBAL\DBALException; + use function implode; /** diff --git a/lib/Doctrine/DBAL/SQLParserUtils.php b/lib/Doctrine/DBAL/SQLParserUtils.php index ff9d9a1b4b9..ee57bd6cd63 100644 --- a/lib/Doctrine/DBAL/SQLParserUtils.php +++ b/lib/Doctrine/DBAL/SQLParserUtils.php @@ -19,6 +19,7 @@ use function strlen; use function strpos; use function substr; + use const PREG_OFFSET_CAPTURE; /** @@ -65,13 +66,13 @@ public static function getPlaceholderPositions($statement, $isPositional = true) * * @return int[] */ - private static function getPositionalPlaceholderPositions(string $statement) : array + private static function getPositionalPlaceholderPositions(string $statement): array { return self::collectPlaceholders( $statement, '?', self::POSITIONAL_TOKEN, - static function (string $_, int $placeholderPosition, int $fragmentPosition, array &$carry) : void { + static function (string $_, int $placeholderPosition, int $fragmentPosition, array &$carry): void { $carry[] = $placeholderPosition + $fragmentPosition; } ); @@ -82,13 +83,13 @@ static function (string $_, int $placeholderPosition, int $fragmentPosition, arr * * @return string[] */ - private static function getNamedPlaceholderPositions(string $statement) : array + private static function getNamedPlaceholderPositions(string $statement): array { return self::collectPlaceholders( $statement, ':', self::NAMED_TOKEN, - static function (string $placeholder, int $placeholderPosition, int $fragmentPosition, array &$carry) : void { + static function (string $placeholder, int $placeholderPosition, int $fragmentPosition, array &$carry): void { $carry[$placeholderPosition + $fragmentPosition] = substr($placeholder, 1); } ); @@ -97,7 +98,7 @@ static function (string $placeholder, int $placeholderPosition, int $fragmentPos /** * @return mixed[] */ - private static function collectPlaceholders(string $statement, string $match, string $token, callable $collector) : array + private static function collectPlaceholders(string $statement, string $match, string $token, callable $collector): array { if (strpos($statement, $match) === false) { return []; diff --git a/lib/Doctrine/DBAL/Schema/AbstractAsset.php b/lib/Doctrine/DBAL/Schema/AbstractAsset.php index b64cb42e208..3424b17c544 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractAsset.php +++ b/lib/Doctrine/DBAL/Schema/AbstractAsset.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function array_map; use function crc32; use function dechex; diff --git a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php index b90994e0e64..1d7f1eec73a 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Events; use Doctrine\DBAL\Platforms\AbstractPlatform; use Throwable; + use function array_filter; use function array_intersect; use function array_map; @@ -429,7 +430,7 @@ public function createDatabase($database) */ public function createTable(Table $table) { - $createFlags = AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS; + $createFlags = AbstractPlatform::CREATE_INDEXES | AbstractPlatform::CREATE_FOREIGNKEYS; $this->_execSql($this->_platform->getCreateTableSQL($table, $createFlags)); } diff --git a/lib/Doctrine/DBAL/Schema/Column.php b/lib/Doctrine/DBAL/Schema/Column.php index 81dbef70975..be9399a3b07 100644 --- a/lib/Doctrine/DBAL/Schema/Column.php +++ b/lib/Doctrine/DBAL/Schema/Column.php @@ -3,11 +3,13 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Types\Type; + use function array_merge; use function is_numeric; use function method_exists; use function sprintf; use function trigger_error; + use const E_USER_DEPRECATED; /** diff --git a/lib/Doctrine/DBAL/Schema/Comparator.php b/lib/Doctrine/DBAL/Schema/Comparator.php index e241cf658c5..c224e1142c7 100644 --- a/lib/Doctrine/DBAL/Schema/Comparator.php +++ b/lib/Doctrine/DBAL/Schema/Comparator.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Types; + use function array_intersect_key; use function array_key_exists; use function array_keys; @@ -248,7 +249,8 @@ public function diffTable(Table $table1, Table $table2) /* See if there are any removed indexes in table 2 */ foreach ($table1Indexes as $indexName => $index) { // See if index is removed in table 2. - if (($index->isPrimary() && ! $table2->hasPrimaryKey()) || + if ( + ($index->isPrimary() && ! $table2->hasPrimaryKey()) || ! $index->isPrimary() && ! $table2->hasIndex($indexName) ) { $tableDifferences->removedIndexes[$indexName] = $index; @@ -447,12 +449,15 @@ public function diffColumn(Column $column1, Column $column2) // Null values need to be checked additionally as they tell whether to create or drop a default value. // null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation. - if (($properties1['default'] === null) !== ($properties2['default'] === null) - || $properties1['default'] != $properties2['default']) { + if ( + ($properties1['default'] === null) !== ($properties2['default'] === null) + || $properties1['default'] != $properties2['default'] + ) { $changedProperties[] = 'default'; } - if (($properties1['type'] instanceof Types\StringType && ! $properties1['type'] instanceof Types\GuidType) || + if ( + ($properties1['type'] instanceof Types\StringType && ! $properties1['type'] instanceof Types\GuidType) || $properties1['type'] instanceof Types\BinaryType ) { // check if value of length is set at all, default value assumed otherwise. @@ -476,7 +481,8 @@ public function diffColumn(Column $column1, Column $column2) } // A null value and an empty string are actually equal for a comment so they should not trigger a change. - if ($properties1['comment'] !== $properties2['comment'] && + if ( + $properties1['comment'] !== $properties2['comment'] && ! ($properties1['comment'] === null && $properties2['comment'] === '') && ! ($properties2['comment'] === null && $properties1['comment'] === '') ) { @@ -513,7 +519,7 @@ public function diffColumn(Column $column1, Column $column2) * * @deprecated */ - private function isALegacyJsonComparison(Types\Type $one, Types\Type $other) : bool + private function isALegacyJsonComparison(Types\Type $one, Types\Type $other): bool { if (! $one instanceof Types\JsonType || ! $other instanceof Types\JsonType) { return false; diff --git a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php index d2d6cef0743..1559fa135fe 100644 --- a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\DB2Platform; use Doctrine\DBAL\Types\Type; + use function array_change_key_case; use function assert; use function is_resource; @@ -12,6 +13,7 @@ use function strpos; use function strtolower; use function substr; + use const CASE_LOWER; /** @@ -209,7 +211,7 @@ protected function _getPortableViewDefinition($view) //$view['text'] = (is_resource($view['text']) ? stream_get_contents($view['text']) : $view['text']); if (! is_resource($view['text'])) { $pos = strpos($view['text'], ' AS '); - $sql = substr($view['text'], $pos+4); + $sql = substr($view['text'], $pos + 4); } else { $sql = ''; } @@ -220,7 +222,7 @@ protected function _getPortableViewDefinition($view) /** * {@inheritdoc} */ - public function listTableDetails($tableName) : Table + public function listTableDetails($tableName): Table { $table = parent::listTableDetails($tableName); diff --git a/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php b/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php index c334db2797b..47a2e2f0bc7 100644 --- a/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Types\Type; + use function explode; use function strtolower; use function trim; diff --git a/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php b/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php index 3611b77dccd..b3b628f3e6f 100644 --- a/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php +++ b/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function array_keys; use function array_map; use function in_array; @@ -85,7 +86,7 @@ public function __construct(array $localColumnNames, $foreignTableName, array $f * * @return Identifier[] */ - private function createIdentifierMap(array $names) : array + private function createIdentifierMap(array $names): array { $identifiers = []; diff --git a/lib/Doctrine/DBAL/Schema/Index.php b/lib/Doctrine/DBAL/Schema/Index.php index 07b1c008c19..81299353011 100644 --- a/lib/Doctrine/DBAL/Schema/Index.php +++ b/lib/Doctrine/DBAL/Schema/Index.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use InvalidArgumentException; + use function array_filter; use function array_keys; use function array_map; @@ -348,9 +349,9 @@ private function samePartialIndex(Index $other) /** * Returns whether the index has the same column lengths as the other */ - private function hasSameColumnLengths(self $other) : bool + private function hasSameColumnLengths(self $other): bool { - $filter = static function (?int $length) : bool { + $filter = static function (?int $length): bool { return $length !== null; }; diff --git a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php index 15866efae9e..2e37d56be8f 100644 --- a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\MariaDb1027Platform; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Types\Type; + use function array_change_key_case; use function array_shift; use function array_values; @@ -16,6 +17,7 @@ use function strtok; use function strtolower; use function strtr; + use const CASE_LOWER; /** @@ -243,7 +245,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) * * @param string|null $columnDefault default value as stored in information_schema for MariaDB >= 10.2.7 */ - private function getMariaDb1027ColumnDefault(MariaDb1027Platform $platform, ?string $columnDefault) : ?string + private function getMariaDb1027ColumnDefault(MariaDb1027Platform $platform, ?string $columnDefault): ?string { if ($columnDefault === 'NULL' || $columnDefault === null) { return null; @@ -351,7 +353,7 @@ public function listTableDetails($tableName) /** * @return string[]|true[] */ - private function parseCreateOptions(?string $string) : array + private function parseCreateOptions(?string $string): array { $options = []; diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index e2816caeb00..d3eb7ba686a 100644 --- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Types\Type; use Throwable; + use function array_change_key_case; use function array_values; use function assert; @@ -17,6 +18,7 @@ use function strtolower; use function strtoupper; use function trim; + use const CASE_LOWER; /** @@ -398,7 +400,7 @@ private function killUserSessions($user) /** * {@inheritdoc} */ - public function listTableDetails($tableName) : Table + public function listTableDetails($tableName): Table { $table = parent::listTableDetails($tableName); diff --git a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php index 287a7dac6ba..059a3398590 100644 --- a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; + use function array_change_key_case; use function array_filter; use function array_keys; @@ -24,6 +25,7 @@ use function strpos; use function strtolower; use function trim; + use const CASE_LOWER; /** @@ -492,7 +494,7 @@ private function fixVersion94NegativeNumericDefaultValue($defaultValue) /** * Parses a default value expression as given by PostgreSQL */ - private function parseDefaultExpression(?string $default) : ?string + private function parseDefaultExpression(?string $default): ?string { if ($default === null) { return $default; @@ -504,7 +506,7 @@ private function parseDefaultExpression(?string $default) : ?string /** * {@inheritdoc} */ - public function listTableDetails($tableName) : Table + public function listTableDetails($tableName): Table { $table = parent::listTableDetails($tableName); diff --git a/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php b/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php index 9825a759755..3f83b93e9e4 100644 --- a/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\SQLAnywherePlatform; use Doctrine\DBAL\Types\Type; + use function assert; use function is_string; use function preg_replace; diff --git a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php index 54960657dd3..dd34010869c 100644 --- a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Types\Type; use PDOException; use Throwable; + use function assert; use function count; use function in_array; @@ -126,7 +127,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) return $column; } - private function parseDefaultExpression(string $value) : ?string + private function parseDefaultExpression(string $value): ?string { while (preg_match('/^\((.*)\)$/s', $value, $matches)) { $value = $matches[1]; @@ -332,7 +333,7 @@ private function closeActiveDatabaseConnections($database) /** * @param string $tableName */ - public function listTableDetails($tableName) : Table + public function listTableDetails($tableName): Table { $table = parent::listTableDetails($tableName); diff --git a/lib/Doctrine/DBAL/Schema/Schema.php b/lib/Doctrine/DBAL/Schema/Schema.php index ff09ef52cf1..8afe816f6b6 100644 --- a/lib/Doctrine/DBAL/Schema/Schema.php +++ b/lib/Doctrine/DBAL/Schema/Schema.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; use Doctrine\DBAL\Schema\Visitor\NamespaceVisitor; use Doctrine\DBAL\Schema\Visitor\Visitor; + use function array_keys; use function strpos; use function strtolower; @@ -106,9 +107,11 @@ protected function _addTable(Table $table) throw SchemaException::tableAlreadyExists($tableName); } - if ($namespaceName !== null + if ( + $namespaceName !== null && ! $table->isInDefaultNamespace($this->getName()) - && ! $this->hasNamespace($namespaceName)) { + && ! $this->hasNamespace($namespaceName) + ) { $this->createNamespace($namespaceName); } @@ -130,9 +133,11 @@ protected function _addSequence(Sequence $sequence) throw SchemaException::sequenceAlreadyExists($seqName); } - if ($namespaceName !== null + if ( + $namespaceName !== null && ! $sequence->isInDefaultNamespace($this->getName()) - && ! $this->hasNamespace($namespaceName)) { + && ! $this->hasNamespace($namespaceName) + ) { $this->createNamespace($namespaceName); } diff --git a/lib/Doctrine/DBAL/Schema/SchemaDiff.php b/lib/Doctrine/DBAL/Schema/SchemaDiff.php index 4e5dc91f621..fa643aec912 100644 --- a/lib/Doctrine/DBAL/Schema/SchemaDiff.php +++ b/lib/Doctrine/DBAL/Schema/SchemaDiff.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Internal\DependencyOrderCalculator; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function array_merge; /** diff --git a/lib/Doctrine/DBAL/Schema/SchemaException.php b/lib/Doctrine/DBAL/Schema/SchemaException.php index c7465eee4ad..4543334ba43 100644 --- a/lib/Doctrine/DBAL/Schema/SchemaException.php +++ b/lib/Doctrine/DBAL/Schema/SchemaException.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\DBALException; + use function implode; use function sprintf; diff --git a/lib/Doctrine/DBAL/Schema/Sequence.php b/lib/Doctrine/DBAL/Schema/Sequence.php index 2301c8ae7e1..19dec9cd57a 100644 --- a/lib/Doctrine/DBAL/Schema/Sequence.php +++ b/lib/Doctrine/DBAL/Schema/Sequence.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema\Visitor\Visitor; + use function count; use function sprintf; diff --git a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php index 03076d96b6a..3d149e895ed 100644 --- a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Types\StringType; use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\Type; + use function array_change_key_case; use function array_map; use function array_reverse; @@ -26,6 +27,7 @@ use function trim; use function unlink; use function usort; + use const CASE_LOWER; /** @@ -120,8 +122,9 @@ public function listTableForeignKeys($table, $database = null) if (! empty($tableForeignKeys)) { $createSql = $this->getCreateTableSQL($table); - if ($createSql !== null && preg_match_all( - '# + if ( + $createSql !== null && preg_match_all( + '# (?:CONSTRAINT\s+([^\s]+)\s+)? (?:FOREIGN\s+KEY[^\)]+\)\s*)? REFERENCES\s+[^\s]+\s+(?:\([^\)]+\))? @@ -130,9 +133,10 @@ public function listTableForeignKeys($table, $database = null) (NOT\s+DEFERRABLE|DEFERRABLE) (?:\s+INITIALLY\s+(DEFERRED|IMMEDIATE))? )?#isx', - $createSql, - $match - )) { + $createSql, + $match + ) + ) { $names = array_reverse($match[1]); $deferrable = array_reverse($match[2]); $deferred = array_reverse($match[3]); @@ -415,7 +419,7 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) 'onDelete' => $value['on_delete'], 'onUpdate' => $value['on_update'], 'deferrable' => $value['deferrable'], - 'deferred'=> $value['deferred'], + 'deferred' => $value['deferred'], ]; } @@ -434,7 +438,7 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) 'onDelete' => $constraint['onDelete'], 'onUpdate' => $constraint['onUpdate'], 'deferrable' => $constraint['deferrable'], - 'deferred'=> $constraint['deferred'], + 'deferred' => $constraint['deferred'], ] ); } @@ -467,7 +471,7 @@ private function getTableDiffForAlterForeignKey($table) return $tableDiff; } - private function parseColumnCollationFromSQL(string $column, string $sql) : ?string + private function parseColumnCollationFromSQL(string $column, string $sql): ?string { $pattern = '{(?:\W' . preg_quote($column) . '\W|\W' . preg_quote($this->_platform->quoteSingleIdentifier($column)) . '\W)[^,(]+(?:\([^()]+\)[^,]*)?(?:(?:DEFAULT|CHECK)\s*(?:\(.*?\))?[^,]*)*COLLATE\s+["\']?([^\s,"\')]+)}is'; @@ -479,7 +483,7 @@ private function parseColumnCollationFromSQL(string $column, string $sql) : ?str return $match[1]; } - private function parseTableCommentFromSQL(string $table, string $sql) : ?string + private function parseTableCommentFromSQL(string $table, string $sql): ?string { $pattern = '/\s* # Allow whitespace characters at start of line CREATE\sTABLE # Match "CREATE TABLE" @@ -498,7 +502,7 @@ private function parseTableCommentFromSQL(string $table, string $sql) : ?string return $comment === '' ? null : $comment; } - private function parseColumnCommentFromSQL(string $column, string $sql) : ?string + private function parseColumnCommentFromSQL(string $column, string $sql): ?string { $pattern = '{[\s(,](?:\W' . preg_quote($this->_platform->quoteSingleIdentifier($column)) . '\W|\W' . preg_quote($column) . '\W)(?:\([^)]*?\)|[^,(])*?,?((?:(?!\n))(?:\s*--[^\n]*\n?)+)}i'; @@ -512,7 +516,7 @@ private function parseColumnCommentFromSQL(string $column, string $sql) : ?strin return $comment === '' ? null : $comment; } - private function getCreateTableSQL(string $table) : ?string + private function getCreateTableSQL(string $table): ?string { return $this->_conn->fetchColumn( <<<'SQL' @@ -535,7 +539,7 @@ private function getCreateTableSQL(string $table) : ?string /** * @param string $tableName */ - public function listTableDetails($tableName) : Table + public function listTableDetails($tableName): Table { $table = parent::listTableDetails($tableName); diff --git a/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php b/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php index dd4b1ca5f40..43c0fc6a544 100644 --- a/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php +++ b/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; + use function count; /** diff --git a/lib/Doctrine/DBAL/Schema/Table.php b/lib/Doctrine/DBAL/Schema/Table.php index 6fa660efd5e..a6be32c68a4 100644 --- a/lib/Doctrine/DBAL/Schema/Table.php +++ b/lib/Doctrine/DBAL/Schema/Table.php @@ -5,12 +5,14 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\DBAL\Types\Type; + use function array_filter; use function array_merge; use function in_array; use function preg_match; use function strlen; use function strtolower; + use const ARRAY_FILTER_USE_KEY; /** @@ -475,7 +477,8 @@ protected function _addIndex(Index $indexCandidate) $replacedImplicitIndexes[] = $name; } - if ((isset($this->_indexes[$indexName]) && ! in_array($indexName, $replacedImplicitIndexes, true)) || + if ( + (isset($this->_indexes[$indexName]) && ! in_array($indexName, $replacedImplicitIndexes, true)) || ($this->_primaryKeyName !== false && $indexCandidate->isPrimary()) ) { throw SchemaException::indexAlreadyExists($indexName, $this->_name); @@ -846,7 +849,7 @@ private function normalizeIdentifier($identifier) return $this->trimQuotes(strtolower($identifier)); } - public function setComment(?string $comment) : self + public function setComment(?string $comment): self { // For keeping backward compatibility with MySQL in previous releases, table comments are stored as options. $this->addOption('comment', $comment); @@ -854,7 +857,7 @@ public function setComment(?string $comment) : self return $this; } - public function getComment() : ?string + public function getComment(): ?string { return $this->_options['comment'] ?? null; } diff --git a/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php b/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php index 12f417119fc..c3428ce58ac 100644 --- a/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php +++ b/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Table; + use function array_merge; class CreateSchemaSqlCollector extends AbstractVisitor diff --git a/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php b/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php index 05b87fb16b0..a2355ac7de3 100644 --- a/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php +++ b/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Table; use SplObjectStorage; + use function assert; use function strlen; diff --git a/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php b/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php index 84a009f8a1e..b36e009ca26 100644 --- a/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php +++ b/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; + use function current; use function file_put_contents; use function in_array; diff --git a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php index 8d8134127d7..fdbc1ad6e76 100644 --- a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php +++ b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Events; use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser; use InvalidArgumentException; + use function array_merge; use function is_numeric; use function is_string; diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php index 417f674a3e0..2f2082451fe 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; use RuntimeException; + use function array_merge; /** diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php index d8178ee07db..ce092c6bcb1 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Sharding\ShardManager; use Doctrine\DBAL\Types\Type; use RuntimeException; + use function sprintf; /** diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php index e85a3025f18..658927eb435 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Visitor\Visitor; use RuntimeException; + use function in_array; /** diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index ee8dcfcfceb..09ef029cbf8 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -8,6 +8,7 @@ use IteratorAggregate; use PDO; use Throwable; + use function is_array; use function is_string; diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php index eb15dd96a48..c53c9ccf172 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php @@ -11,6 +11,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function error_get_last; use function file_exists; @@ -18,6 +19,7 @@ use function is_readable; use function realpath; use function sprintf; + use const PHP_EOL; /** diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php index cc3d1611ecf..57b54ad6b96 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php @@ -26,6 +26,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; + use function array_keys; use function assert; use function count; diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php index 5111a6505db..d17db5ae4c8 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php @@ -10,6 +10,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function is_numeric; use function is_string; diff --git a/lib/Doctrine/DBAL/Tools/Dumper.php b/lib/Doctrine/DBAL/Tools/Dumper.php index 25c165901f9..d7559d8fb20 100644 --- a/lib/Doctrine/DBAL/Tools/Dumper.php +++ b/lib/Doctrine/DBAL/Tools/Dumper.php @@ -8,6 +8,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Persistence\Proxy; use stdClass; + use function array_keys; use function assert; use function class_exists; @@ -52,7 +53,7 @@ private function __construct() * @param mixed $var The variable to dump. * @param int $maxDepth The maximum nesting level for object properties. */ - public static function dump($var, int $maxDepth = 2) : string + public static function dump($var, int $maxDepth = 2): string { $html = ini_set('html_errors', '1'); assert(is_string($html)); @@ -160,7 +161,7 @@ private static function fillReturnWithClassAttributes($var, stdClass $return, in /** * @param object $object */ - private static function getClass($object) : string + private static function getClass($object): string { $class = get_class($object); diff --git a/lib/Doctrine/DBAL/Types/ArrayType.php b/lib/Doctrine/DBAL/Types/ArrayType.php index 78325ad95c9..e915ca8e387 100644 --- a/lib/Doctrine/DBAL/Types/ArrayType.php +++ b/lib/Doctrine/DBAL/Types/ArrayType.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function is_resource; use function restore_error_handler; use function serialize; @@ -43,7 +44,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $value = is_resource($value) ? stream_get_contents($value) : $value; - set_error_handler(function (int $code, string $message) : bool { + set_error_handler(function (int $code, string $message): bool { throw ConversionException::conversionFailedUnserialization($this->getName(), $message); }); diff --git a/lib/Doctrine/DBAL/Types/BinaryType.php b/lib/Doctrine/DBAL/Types/BinaryType.php index d604b3bff69..bf537e8ddb3 100644 --- a/lib/Doctrine/DBAL/Types/BinaryType.php +++ b/lib/Doctrine/DBAL/Types/BinaryType.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function assert; use function fopen; use function fseek; diff --git a/lib/Doctrine/DBAL/Types/BlobType.php b/lib/Doctrine/DBAL/Types/BlobType.php index e4bb22f08d8..fedb0f245ac 100644 --- a/lib/Doctrine/DBAL/Types/BlobType.php +++ b/lib/Doctrine/DBAL/Types/BlobType.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function assert; use function fopen; use function fseek; diff --git a/lib/Doctrine/DBAL/Types/ConversionException.php b/lib/Doctrine/DBAL/Types/ConversionException.php index 4733b572257..55dfedee754 100644 --- a/lib/Doctrine/DBAL/Types/ConversionException.php +++ b/lib/Doctrine/DBAL/Types/ConversionException.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\DBALException; use Throwable; + use function get_class; use function gettype; use function implode; @@ -111,7 +112,7 @@ public static function conversionFailedSerialization($value, $format, $error) )); } - public static function conversionFailedUnserialization(string $format, string $error) : self + public static function conversionFailedUnserialization(string $format, string $error): self { return new self(sprintf( "Could not convert database value to '%s' as an error was triggered by the unserialization: '%s'", diff --git a/lib/Doctrine/DBAL/Types/DateIntervalType.php b/lib/Doctrine/DBAL/Types/DateIntervalType.php index 96a446e8607..239dcf7481e 100644 --- a/lib/Doctrine/DBAL/Types/DateIntervalType.php +++ b/lib/Doctrine/DBAL/Types/DateIntervalType.php @@ -5,6 +5,7 @@ use DateInterval; use Doctrine\DBAL\Platforms\AbstractPlatform; use Throwable; + use function substr; /** diff --git a/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php b/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php index 51960a8c344..9af4fc34908 100644 --- a/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php +++ b/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php @@ -4,6 +4,7 @@ use DateTimeImmutable; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function date_create_immutable; /** diff --git a/lib/Doctrine/DBAL/Types/DateTimeType.php b/lib/Doctrine/DBAL/Types/DateTimeType.php index 65071a6b188..069a03d4e7a 100644 --- a/lib/Doctrine/DBAL/Types/DateTimeType.php +++ b/lib/Doctrine/DBAL/Types/DateTimeType.php @@ -5,6 +5,7 @@ use DateTime; use DateTimeInterface; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function date_create; /** diff --git a/lib/Doctrine/DBAL/Types/JsonArrayType.php b/lib/Doctrine/DBAL/Types/JsonArrayType.php index bc468fba0f3..400e0ef3837 100644 --- a/lib/Doctrine/DBAL/Types/JsonArrayType.php +++ b/lib/Doctrine/DBAL/Types/JsonArrayType.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function is_resource; use function json_decode; use function stream_get_contents; diff --git a/lib/Doctrine/DBAL/Types/JsonType.php b/lib/Doctrine/DBAL/Types/JsonType.php index 5fc00937fef..b40b3334513 100644 --- a/lib/Doctrine/DBAL/Types/JsonType.php +++ b/lib/Doctrine/DBAL/Types/JsonType.php @@ -3,12 +3,14 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function is_resource; use function json_decode; use function json_encode; use function json_last_error; use function json_last_error_msg; use function stream_get_contents; + use const JSON_ERROR_NONE; /** diff --git a/lib/Doctrine/DBAL/Types/ObjectType.php b/lib/Doctrine/DBAL/Types/ObjectType.php index 82b1a752ee1..4ca1cf4d531 100644 --- a/lib/Doctrine/DBAL/Types/ObjectType.php +++ b/lib/Doctrine/DBAL/Types/ObjectType.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function is_resource; use function restore_error_handler; use function serialize; @@ -42,7 +43,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $value = is_resource($value) ? stream_get_contents($value) : $value; - set_error_handler(function (int $code, string $message) : bool { + set_error_handler(function (int $code, string $message): bool { throw ConversionException::conversionFailedUnserialization($this->getName(), $message); }); diff --git a/lib/Doctrine/DBAL/Types/SimpleArrayType.php b/lib/Doctrine/DBAL/Types/SimpleArrayType.php index 31c22b8e6f6..bdf08249a49 100644 --- a/lib/Doctrine/DBAL/Types/SimpleArrayType.php +++ b/lib/Doctrine/DBAL/Types/SimpleArrayType.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function explode; use function implode; use function is_resource; diff --git a/lib/Doctrine/DBAL/Types/TextType.php b/lib/Doctrine/DBAL/Types/TextType.php index 76dd7c48cf0..3eb8047ed62 100644 --- a/lib/Doctrine/DBAL/Types/TextType.php +++ b/lib/Doctrine/DBAL/Types/TextType.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function is_resource; use function stream_get_contents; diff --git a/lib/Doctrine/DBAL/Types/Type.php b/lib/Doctrine/DBAL/Types/Type.php index 4a0d80ffe55..8f80cc38687 100644 --- a/lib/Doctrine/DBAL/Types/Type.php +++ b/lib/Doctrine/DBAL/Types/Type.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function array_map; use function get_class; use function str_replace; @@ -196,7 +197,7 @@ abstract public function getName(); /** * @internal This method is only to be used within DBAL for forward compatibility purposes. Do not use directly. */ - final public static function getTypeRegistry() : TypeRegistry + final public static function getTypeRegistry(): TypeRegistry { if (self::$typeRegistry === null) { self::$typeRegistry = self::createTypeRegistry(); @@ -205,7 +206,7 @@ final public static function getTypeRegistry() : TypeRegistry return self::$typeRegistry; } - private static function createTypeRegistry() : TypeRegistry + private static function createTypeRegistry(): TypeRegistry { $registry = new TypeRegistry(); @@ -295,7 +296,7 @@ public function getBindingType() public static function getTypesMap() { return array_map( - static function (Type $type) : string { + static function (Type $type): string { return get_class($type); }, self::getTypeRegistry()->getMap() diff --git a/lib/Doctrine/DBAL/Types/TypeRegistry.php b/lib/Doctrine/DBAL/Types/TypeRegistry.php index 7e8093cf749..362a5ccc9a4 100644 --- a/lib/Doctrine/DBAL/Types/TypeRegistry.php +++ b/lib/Doctrine/DBAL/Types/TypeRegistry.php @@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\DBALException; + use function array_search; use function in_array; @@ -24,7 +25,7 @@ final class TypeRegistry * * @throws DBALException */ - public function get(string $name) : Type + public function get(string $name): Type { if (! isset($this->instances[$name])) { throw DBALException::unknownColumnType($name); @@ -38,7 +39,7 @@ public function get(string $name) : Type * * @throws DBALException */ - public function lookupName(Type $type) : string + public function lookupName(Type $type): string { $name = $this->findTypeName($type); @@ -52,7 +53,7 @@ public function lookupName(Type $type) : string /** * Checks if there is a type of the given name. */ - public function has(string $name) : bool + public function has(string $name): bool { return isset($this->instances[$name]); } @@ -62,7 +63,7 @@ public function has(string $name) : bool * * @throws DBALException */ - public function register(string $name, Type $type) : void + public function register(string $name, Type $type): void { if (isset($this->instances[$name])) { throw DBALException::typeExists($name); @@ -80,7 +81,7 @@ public function register(string $name, Type $type) : void * * @throws DBALException */ - public function override(string $name, Type $type) : void + public function override(string $name, Type $type): void { if (! isset($this->instances[$name])) { throw DBALException::typeNotFound($name); @@ -100,12 +101,12 @@ public function override(string $name, Type $type) : void * * @return array */ - public function getMap() : array + public function getMap(): array { return $this->instances; } - private function findTypeName(Type $type) : ?string + private function findTypeName(Type $type): ?string { $name = array_search($type, $this->instances, true); diff --git a/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php b/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php index 38beb3badf6..23f8b572d09 100644 --- a/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php +++ b/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php @@ -4,6 +4,7 @@ use DateTimeImmutable; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function date_create_immutable; /** diff --git a/lib/Doctrine/DBAL/Types/VarDateTimeType.php b/lib/Doctrine/DBAL/Types/VarDateTimeType.php index 1d9dbd3a6c6..20960579afd 100644 --- a/lib/Doctrine/DBAL/Types/VarDateTimeType.php +++ b/lib/Doctrine/DBAL/Types/VarDateTimeType.php @@ -4,6 +4,7 @@ use DateTime; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function date_create; /** diff --git a/phpcs.xml.dist b/phpcs.xml.dist index ad39355ad24..bfbfafd31e4 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -23,6 +23,7 @@ + diff --git a/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php b/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php index 6078fb1ab8c..185fac138c0 100644 --- a/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php +++ b/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\ParameterType; use Doctrine\Tests\DbalTestCase; + use function parse_str; class QueryCacheProfileTest extends DbalTestCase @@ -33,12 +34,12 @@ class QueryCacheProfileTest extends DbalTestCase 'driver' => 'database_driver', ]; - protected function setUp() : void + protected function setUp(): void { $this->queryCacheProfile = new QueryCacheProfile(self::LIFETIME, self::CACHE_KEY); } - public function testShouldUseTheGivenCacheKeyIfPresent() : void + public function testShouldUseTheGivenCacheKeyIfPresent(): void { [$cacheKey] = $this->queryCacheProfile->generateCacheKeys( $this->query, @@ -50,7 +51,7 @@ public function testShouldUseTheGivenCacheKeyIfPresent() : void self::assertEquals(self::CACHE_KEY, $cacheKey, 'The returned cache key should match the given one'); } - public function testShouldGenerateAnAutomaticKeyIfNoKeyHasBeenGiven() : void + public function testShouldGenerateAnAutomaticKeyIfNoKeyHasBeenGiven(): void { $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); @@ -70,7 +71,7 @@ public function testShouldGenerateAnAutomaticKeyIfNoKeyHasBeenGiven() : void self::assertNotEmpty($cacheKey, 'The generated cache key should not be empty'); } - public function testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferentConnections() : void + public function testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferentConnections(): void { $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); @@ -93,7 +94,7 @@ public function testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferent self::assertNotEquals($firstCacheKey, $secondCacheKey, 'Cache keys should be different'); } - public function testConnectionParamsShouldBeHashed() : void + public function testConnectionParamsShouldBeHashed(): void { $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); @@ -114,7 +115,7 @@ public function testConnectionParamsShouldBeHashed() : void } } - public function testShouldGenerateSameKeysIfNoneOfTheParamsChanges() : void + public function testShouldGenerateSameKeysIfNoneOfTheParamsChanges(): void { $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); diff --git a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php index bde98cfa4b5..7ebfc5b1982 100644 --- a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php +++ b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php @@ -17,7 +17,7 @@ class ConfigurationTest extends DbalTestCase */ protected $config; - protected function setUp() : void + protected function setUp(): void { $this->config = new Configuration(); } @@ -27,7 +27,7 @@ protected function setUp() : void * * @group DBAL-81 */ - public function testReturnsDefaultConnectionAutoCommitMode() : void + public function testReturnsDefaultConnectionAutoCommitMode(): void { self::assertTrue($this->config->getAutoCommit()); } @@ -37,7 +37,7 @@ public function testReturnsDefaultConnectionAutoCommitMode() : void * * @group DBAL-81 */ - public function testSetsDefaultConnectionAutoCommitMode() : void + public function testSetsDefaultConnectionAutoCommitMode(): void { $this->config->setAutoCommit(false); diff --git a/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php b/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php index a7b04f94994..7ffc32b6e06 100644 --- a/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php +++ b/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php @@ -12,7 +12,7 @@ final class LoggingTest extends TestCase { - public function testLogExecuteQuery() : void + public function testLogExecuteQuery(): void { $driverConnection = $this->createStub(DriverConnection::class); $driverConnection->method('query') @@ -22,7 +22,7 @@ public function testLogExecuteQuery() : void ->executeQuery('SELECT * FROM table'); } - public function testLogExecuteUpdate() : void + public function testLogExecuteUpdate(): void { $this->createConnection( $this->createStub(DriverConnection::class), @@ -31,7 +31,7 @@ public function testLogExecuteUpdate() : void ->executeUpdate('UPDATE table SET foo = ?'); } - public function testLogPrepareExecute() : void + public function testLogPrepareExecute(): void { $driverConnection = $this->createStub(DriverConnection::class); $driverConnection->method('prepare') @@ -42,7 +42,7 @@ public function testLogPrepareExecute() : void ->execute(); } - private function createConnection(DriverConnection $driverConnection, string $expectedSQL) : Connection + private function createConnection(DriverConnection $driverConnection, string $expectedSQL): Connection { $driver = $this->createStub(Driver::class); $driver->method('connect') diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index fc018fcc072..2cba7534710 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -26,6 +26,7 @@ use Exception; use PHPUnit\Framework\MockObject\MockObject; use stdClass; + use function call_user_func_array; /** @@ -45,7 +46,7 @@ class ConnectionTest extends DbalTestCase 'port' => '1234', ]; - protected function setUp() : void + protected function setUp(): void { $this->connection = DriverManager::getConnection($this->params); } @@ -71,78 +72,78 @@ private function getExecuteUpdateMockConnection() ->getMock(); } - public function testIsConnected() : void + public function testIsConnected(): void { self::assertFalse($this->connection->isConnected()); } - public function testNoTransactionActiveByDefault() : void + public function testNoTransactionActiveByDefault(): void { self::assertFalse($this->connection->isTransactionActive()); } - public function testCommitWithNoActiveTransactionThrowsException() : void + public function testCommitWithNoActiveTransactionThrowsException(): void { $this->expectException(ConnectionException::class); $this->connection->commit(); } - public function testRollbackWithNoActiveTransactionThrowsException() : void + public function testRollbackWithNoActiveTransactionThrowsException(): void { $this->expectException(ConnectionException::class); $this->connection->rollBack(); } - public function testSetRollbackOnlyNoActiveTransactionThrowsException() : void + public function testSetRollbackOnlyNoActiveTransactionThrowsException(): void { $this->expectException(ConnectionException::class); $this->connection->setRollbackOnly(); } - public function testIsRollbackOnlyNoActiveTransactionThrowsException() : void + public function testIsRollbackOnlyNoActiveTransactionThrowsException(): void { $this->expectException(ConnectionException::class); $this->connection->isRollbackOnly(); } - public function testGetConfiguration() : void + public function testGetConfiguration(): void { $config = $this->connection->getConfiguration(); self::assertInstanceOf(Configuration::class, $config); } - public function testGetHost() : void + public function testGetHost(): void { self::assertEquals('localhost', $this->connection->getHost()); } - public function testGetPort() : void + public function testGetPort(): void { self::assertEquals('1234', $this->connection->getPort()); } - public function testGetUsername() : void + public function testGetUsername(): void { self::assertEquals('root', $this->connection->getUsername()); } - public function testGetPassword() : void + public function testGetPassword(): void { self::assertEquals('password', $this->connection->getPassword()); } - public function testGetDriver() : void + public function testGetDriver(): void { self::assertInstanceOf(\Doctrine\DBAL\Driver\PDOMySql\Driver::class, $this->connection->getDriver()); } - public function testGetEventManager() : void + public function testGetEventManager(): void { self::assertInstanceOf(EventManager::class, $this->connection->getEventManager()); } - public function testConnectDispatchEvent() : void + public function testConnectDispatchEvent(): void { $listenerMock = $this->createMock(ConnectDispatchEventListener::class); $listenerMock->expects($this->once())->method('postConnect'); @@ -158,7 +159,7 @@ public function testConnectDispatchEvent() : void $conn->connect(); } - public function testEventManagerPassedToPlatform() : void + public function testEventManagerPassedToPlatform(): void { $eventManager = new EventManager(); @@ -180,7 +181,7 @@ public function testEventManagerPassedToPlatform() : void * @requires extension pdo_sqlite * @dataProvider getQueryMethods */ - public function testDriverExceptionIsWrapped(string $method) : void + public function testDriverExceptionIsWrapped(string $method): void { $this->expectException(DBALException::class); $this->expectExceptionMessage("An exception occurred while executing 'MUUHAAAAHAAAA':\n\nSQLSTATE[HY000]: General error: 1 near \"MUUHAAAAHAAAA\""); @@ -196,7 +197,7 @@ public function testDriverExceptionIsWrapped(string $method) : void /** * @return array> */ - public static function getQueryMethods() : iterable + public static function getQueryMethods(): iterable { return [ ['exec'], @@ -212,7 +213,7 @@ public static function getQueryMethods() : iterable * * @group DBAL-11 */ - public function testEchoSQLLogger() : void + public function testEchoSQLLogger(): void { $logger = new EchoSQLLogger(); $this->connection->getConfiguration()->setSQLLogger($logger); @@ -224,7 +225,7 @@ public function testEchoSQLLogger() : void * * @group DBAL-11 */ - public function testDebugSQLStack() : void + public function testDebugSQLStack(): void { $logger = new DebugStack(); $this->connection->getConfiguration()->setSQLLogger($logger); @@ -234,7 +235,7 @@ public function testDebugSQLStack() : void /** * @group DBAL-81 */ - public function testIsAutoCommit() : void + public function testIsAutoCommit(): void { self::assertTrue($this->connection->isAutoCommit()); } @@ -242,7 +243,7 @@ public function testIsAutoCommit() : void /** * @group DBAL-81 */ - public function testSetAutoCommit() : void + public function testSetAutoCommit(): void { $this->connection->setAutoCommit(false); self::assertFalse($this->connection->isAutoCommit()); @@ -253,7 +254,7 @@ public function testSetAutoCommit() : void /** * @group DBAL-81 */ - public function testConnectStartsTransactionInNoAutoCommitMode() : void + public function testConnectStartsTransactionInNoAutoCommitMode(): void { $driverMock = $this->createMock(Driver::class); $driverMock->expects($this->any()) @@ -275,7 +276,7 @@ public function testConnectStartsTransactionInNoAutoCommitMode() : void /** * @group DBAL-81 */ - public function testCommitStartsTransactionInNoAutoCommitMode() : void + public function testCommitStartsTransactionInNoAutoCommitMode(): void { $driverMock = $this->createMock(Driver::class); $driverMock->expects($this->any()) @@ -295,7 +296,7 @@ public function testCommitStartsTransactionInNoAutoCommitMode() : void /** * @dataProvider resultProvider */ - public function testCommitReturn(bool $expectedResult) : void + public function testCommitReturn(bool $expectedResult): void { $driverConnection = $this->createMock(DriverConnection::class); $driverConnection->expects($this->once()) @@ -317,7 +318,7 @@ public function testCommitReturn(bool $expectedResult) : void /** * @return bool[][] */ - public function resultProvider() : array + public function resultProvider(): array { return [[true], [false]]; } @@ -325,7 +326,7 @@ public function resultProvider() : array /** * @group DBAL-81 */ - public function testRollBackStartsTransactionInNoAutoCommitMode() : void + public function testRollBackStartsTransactionInNoAutoCommitMode(): void { $driverMock = $this->createMock(Driver::class); $driverMock->expects($this->any()) @@ -345,7 +346,7 @@ public function testRollBackStartsTransactionInNoAutoCommitMode() : void /** * @group DBAL-81 */ - public function testSwitchingAutoCommitModeCommitsAllCurrentTransactions() : void + public function testSwitchingAutoCommitModeCommitsAllCurrentTransactions(): void { $driverMock = $this->createMock(Driver::class); $driverMock->expects($this->any()) @@ -369,7 +370,7 @@ public function testSwitchingAutoCommitModeCommitsAllCurrentTransactions() : voi self::assertFalse($conn->isTransactionActive()); } - public function testEmptyInsert() : void + public function testEmptyInsert(): void { $conn = $this->getExecuteUpdateMockConnection(); @@ -383,7 +384,7 @@ public function testEmptyInsert() : void /** * @group DBAL-2511 */ - public function testUpdateWithDifferentColumnsInDataAndIdentifiers() : void + public function testUpdateWithDifferentColumnsInDataAndIdentifiers(): void { $conn = $this->getExecuteUpdateMockConnection(); @@ -427,7 +428,7 @@ public function testUpdateWithDifferentColumnsInDataAndIdentifiers() : void /** * @group DBAL-2511 */ - public function testUpdateWithSameColumnInDataAndIdentifiers() : void + public function testUpdateWithSameColumnInDataAndIdentifiers(): void { $conn = $this->getExecuteUpdateMockConnection(); @@ -470,7 +471,7 @@ public function testUpdateWithSameColumnInDataAndIdentifiers() : void /** * @group DBAL-2688 */ - public function testUpdateWithIsNull() : void + public function testUpdateWithIsNull(): void { $conn = $this->getExecuteUpdateMockConnection(); @@ -512,7 +513,7 @@ public function testUpdateWithIsNull() : void /** * @group DBAL-2688 */ - public function testDeleteWithIsNull() : void + public function testDeleteWithIsNull(): void { $conn = $this->getExecuteUpdateMockConnection(); @@ -537,7 +538,7 @@ public function testDeleteWithIsNull() : void ); } - public function testFetchAssoc() : void + public function testFetchAssoc(): void { $statement = 'SELECT * FROM foo WHERE bar = ?'; $params = [666]; @@ -572,7 +573,7 @@ public function testFetchAssoc() : void self::assertSame($result, $conn->fetchAssoc($statement, $params, $types)); } - public function testFetchArray() : void + public function testFetchArray(): void { $statement = 'SELECT * FROM foo WHERE bar = ?'; $params = [666]; @@ -607,7 +608,7 @@ public function testFetchArray() : void self::assertSame($result, $conn->fetchArray($statement, $params, $types)); } - public function testFetchColumn() : void + public function testFetchColumn(): void { $statement = 'SELECT * FROM foo WHERE bar = ?'; $params = [666]; @@ -643,7 +644,7 @@ public function testFetchColumn() : void self::assertSame($result, $conn->fetchColumn($statement, $params, $column, $types)); } - public function testFetchAll() : void + public function testFetchAll(): void { $statement = 'SELECT * FROM foo WHERE bar = ?'; $params = [666]; @@ -677,7 +678,7 @@ public function testFetchAll() : void self::assertSame($result, $conn->fetchAll($statement, $params, $types)); } - public function testConnectionDoesNotMaintainTwoReferencesToExternalPDO() : void + public function testConnectionDoesNotMaintainTwoReferencesToExternalPDO(): void { $params['pdo'] = new stdClass(); @@ -688,7 +689,7 @@ public function testConnectionDoesNotMaintainTwoReferencesToExternalPDO() : void self::assertArrayNotHasKey('pdo', $conn->getParams(), 'Connection is maintaining additional reference to the PDO connection'); } - public function testPassingExternalPDOMeansConnectionIsConnected() : void + public function testPassingExternalPDOMeansConnectionIsConnected(): void { $params['pdo'] = new stdClass(); @@ -699,7 +700,7 @@ public function testPassingExternalPDOMeansConnectionIsConnected() : void self::assertTrue($conn->isConnected(), 'Connection is not connected after passing external PDO'); } - public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentException() : void + public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentException(): void { $driver = $this->createMock(Driver::class); $pdoMock = $this->createMock(\Doctrine\DBAL\Driver\Connection::class); @@ -717,7 +718,7 @@ public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentE /** * @return array> */ - public static function dataCallConnectOnce() : iterable + public static function dataCallConnectOnce(): iterable { return [ ['delete', ['tbl', ['id' => 12345]]], @@ -733,7 +734,7 @@ public static function dataCallConnectOnce() : iterable * * @dataProvider dataCallConnectOnce */ - public function testCallConnectOnce(string $method, array $params) : void + public function testCallConnectOnce(string $method, array $params): void { $driverMock = $this->createMock(Driver::class); $pdoMock = $this->createMock(Connection::class); @@ -757,7 +758,7 @@ public function testCallConnectOnce(string $method, array $params) : void /** * @group DBAL-1127 */ - public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() : void + public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform(): void { $driverMock = $this->createMock(FutureVersionAwarePlatformDriver::class); @@ -787,7 +788,7 @@ public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() : v self::assertSame($platformMock, $connection->getDatabasePlatform()); } - public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCacheQuery() : void + public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCacheQuery(): void { $resultCacheDriverMock = $this->createMock(Cache::class); @@ -826,7 +827,7 @@ public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCach /** * @group #2821 */ - public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecuteCacheQuery() : void + public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecuteCacheQuery(): void { $resultCacheDriverMock = $this->createMock(Cache::class); @@ -863,7 +864,7 @@ public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecute /** * @group #2821 */ - public function testThrowsExceptionWhenInValidPlatformSpecified() : void + public function testThrowsExceptionWhenInValidPlatformSpecified(): void { $connectionParams = $this->params; $connectionParams['platform'] = new stdClass(); @@ -878,7 +879,7 @@ public function testThrowsExceptionWhenInValidPlatformSpecified() : void /** * @group DBAL-990 */ - public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase() : void + public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase(): void { $driverMock = $this->createMock(FutureVersionAwarePlatformDriver::class); @@ -902,7 +903,7 @@ public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnecting /** * @group #3194 */ - public function testExecuteCacheQueryStripsPlatformFromConnectionParamsBeforeGeneratingCacheKeys() : void + public function testExecuteCacheQueryStripsPlatformFromConnectionParamsBeforeGeneratingCacheKeys(): void { $driver = $this->createMock(Driver::class); @@ -949,5 +950,5 @@ public function testExecuteCacheQueryStripsPlatformFromConnectionParamsBeforeGen interface ConnectDispatchEventListener { - public function postConnect() : void; + public function postConnect(): void; } diff --git a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php index de37397dd91..386614d78ec 100644 --- a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php @@ -9,27 +9,28 @@ use Doctrine\Tests\DbalTestCase; use Exception; use stdClass; + use function chr; use function fopen; use function sprintf; class DBALExceptionTest extends DbalTestCase { - public function testDriverExceptionDuringQueryAcceptsBinaryData() : void + public function testDriverExceptionDuringQueryAcceptsBinaryData(): void { $driver = $this->createMock(Driver::class); $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), '', ['ABC', chr(128)]); self::assertStringContainsString('with params ["ABC", "\x80"]', $e->getMessage()); } - public function testDriverExceptionDuringQueryAcceptsResource() : void + public function testDriverExceptionDuringQueryAcceptsResource(): void { $driver = $this->createMock(Driver::class); $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), 'INSERT INTO file (`content`) VALUES (?)', [1 => fopen(__FILE__, 'r')]); self::assertStringContainsString('Resource', $e->getMessage()); } - public function testAvoidOverWrappingOnDriverException() : void + public function testAvoidOverWrappingOnDriverException(): void { $driver = $this->createMock(Driver::class); @@ -40,7 +41,7 @@ public function testAvoidOverWrappingOnDriverException() : void self::assertSame($ex, $e); } - public function testDriverRequiredWithUrl() : void + public function testDriverRequiredWithUrl(): void { $url = 'mysql://localhost'; $exception = DBALException::driverRequired($url); @@ -59,7 +60,7 @@ public function testDriverRequiredWithUrl() : void /** * @group #2821 */ - public function testInvalidPlatformTypeObject() : void + public function testInvalidPlatformTypeObject(): void { $exception = DBALException::invalidPlatformType(new stdClass()); @@ -72,7 +73,7 @@ public function testInvalidPlatformTypeObject() : void /** * @group #2821 */ - public function testInvalidPlatformTypeScalar() : void + public function testInvalidPlatformTypeScalar(): void { $exception = DBALException::invalidPlatformType('some string'); diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php index 7038f5f8340..25133b6394a 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php @@ -12,17 +12,17 @@ class AbstractDB2DriverTest extends AbstractDriverTest { - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractDB2Driver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new DB2Platform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new DB2SchemaManager($connection); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php index 5c8a5dd29ba..29a8441f646 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php @@ -30,6 +30,7 @@ use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; + use function array_merge; use function get_class; use function sprintf; @@ -61,7 +62,7 @@ abstract class AbstractDriverTest extends DbalTestCase */ protected $driver; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -73,7 +74,7 @@ protected function setUp() : void * * @dataProvider exceptionConversionProvider */ - public function testConvertsException($errorCode, ?string $sqlState, ?string $message, string $expectedClass) : void + public function testConvertsException($errorCode, ?string $sqlState, ?string $message, string $expectedClass): void { if (! $this->driver instanceof ExceptionConverterDriver) { $this->markTestSkipped('This test is only intended for exception converter drivers.'); @@ -98,7 +99,7 @@ public function testConvertsException($errorCode, ?string $sqlState, ?string $me self::assertSame($dbalMessage, $dbalException->getMessage()); } - public function testCreatesDatabasePlatformForVersion() : void + public function testCreatesDatabasePlatformForVersion(): void { if (! $this->driver instanceof VersionAwarePlatformDriver) { $this->markTestSkipped('This test is only intended for version aware platform drivers.'); @@ -131,7 +132,7 @@ public function testCreatesDatabasePlatformForVersion() : void } } - public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion() : void + public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion(): void { if (! $this->driver instanceof VersionAwarePlatformDriver) { $this->markTestSkipped('This test is only intended for version aware platform drivers.'); @@ -141,7 +142,7 @@ public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion( $this->driver->createDatabasePlatformForVersion('foo'); } - public function testReturnsDatabaseName() : void + public function testReturnsDatabaseName(): void { $params = [ 'user' => 'foo', @@ -158,12 +159,12 @@ public function testReturnsDatabaseName() : void self::assertSame($params['dbname'], $this->driver->getDatabase($connection)); } - public function testReturnsDatabasePlatform() : void + public function testReturnsDatabasePlatform(): void { self::assertEquals($this->createPlatform(), $this->driver->getDatabasePlatform()); } - public function testReturnsSchemaManager() : void + public function testReturnsSchemaManager(): void { $connection = $this->getConnectionMock(); $schemaManager = $this->driver->getSchemaManager($connection); @@ -179,7 +180,7 @@ public function testReturnsSchemaManager() : void /** * Factory method for creating the driver instance under test. */ - abstract protected function createDriver() : Driver; + abstract protected function createDriver(): Driver; /** * Factory method for creating the the platform instance return by the driver under test. @@ -187,7 +188,7 @@ abstract protected function createDriver() : Driver; * The platform instance returned by this method must be the same as returned by * the driver's getDatabasePlatform() method. */ - abstract protected function createPlatform() : AbstractPlatform; + abstract protected function createPlatform(): AbstractPlatform; /** * Factory method for creating the the schema manager instance return by the driver under test. @@ -197,12 +198,12 @@ abstract protected function createPlatform() : AbstractPlatform; * * @param Connection $connection The underlying connection to use. */ - abstract protected function createSchemaManager(Connection $connection) : AbstractSchemaManager; + abstract protected function createSchemaManager(Connection $connection): AbstractSchemaManager; /** * @return Connection&MockObject */ - protected function getConnectionMock() : Connection + protected function getConnectionMock(): Connection { return $this->createMock(Connection::class); } @@ -210,7 +211,7 @@ protected function getConnectionMock() : Connection /** * @return array> */ - protected function getDatabasePlatformsForVersions() : array + protected function getDatabasePlatformsForVersions(): array { return []; } @@ -218,7 +219,7 @@ protected function getDatabasePlatformsForVersions() : array /** * @return iterable */ - public static function exceptionConversionProvider() : iterable + public static function exceptionConversionProvider(): iterable { foreach (static::getExceptionConversionData() as $expectedClass => $items) { foreach ($items as $item) { @@ -232,7 +233,7 @@ public static function exceptionConversionProvider() : iterable /** * @return array */ - protected static function getExceptionConversionData() : array + protected static function getExceptionConversionData(): array { return []; } diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php index 4982a189e05..094c7506f87 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php @@ -16,7 +16,7 @@ class AbstractMySQLDriverTest extends AbstractDriverTest { - public function testReturnsDatabaseName() : void + public function testReturnsDatabaseName(): void { parent::testReturnsDatabaseName(); @@ -45,17 +45,17 @@ public function testReturnsDatabaseName() : void self::assertSame($database, $this->driver->getDatabase($connection)); } - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractMySQLDriver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new MySqlPlatform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new MySqlSchemaManager($connection); } @@ -63,7 +63,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected function getDatabasePlatformsForVersions() : array + protected function getDatabasePlatformsForVersions(): array { return [ ['5.6.9', MySqlPlatform::class], @@ -89,7 +89,7 @@ protected function getDatabasePlatformsForVersions() : array /** * {@inheritDoc} */ - protected static function getExceptionConversionData() : array + protected static function getExceptionConversionData(): array { return [ self::EXCEPTION_CONNECTION => [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriver/EasyConnectStringTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriver/EasyConnectStringTest.php index efb250d1ac7..a549477ae98 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriver/EasyConnectStringTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriver/EasyConnectStringTest.php @@ -12,7 +12,7 @@ class EasyConnectStringTest extends TestCase * * @dataProvider connectionParametersProvider */ - public function testFromConnectionParameters(array $params, string $expected) : void + public function testFromConnectionParameters(array $params, string $expected): void { $string = EasyConnectString::fromConnectionParameters($params); @@ -22,7 +22,7 @@ public function testFromConnectionParameters(array $params, string $expected) : /** * @return mixed[] */ - public static function connectionParametersProvider() : iterable + public static function connectionParametersProvider(): iterable { return [ 'empty-params' => [[],''], diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php index f95705a8a88..390607696da 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php @@ -12,7 +12,7 @@ class AbstractOracleDriverTest extends AbstractDriverTest { - public function testReturnsDatabaseName() : void + public function testReturnsDatabaseName(): void { $params = [ 'user' => 'foo', @@ -29,7 +29,7 @@ public function testReturnsDatabaseName() : void self::assertSame($params['user'], $this->driver->getDatabase($connection)); } - public function testReturnsDatabaseNameWithConnectDescriptor() : void + public function testReturnsDatabaseNameWithConnectDescriptor(): void { $params = [ 'user' => 'foo', @@ -48,17 +48,17 @@ public function testReturnsDatabaseNameWithConnectDescriptor() : void self::assertSame($params['user'], $this->driver->getDatabase($connection)); } - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractOracleDriver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new OraclePlatform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new OracleSchemaManager($connection); } @@ -66,7 +66,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected static function getExceptionConversionData() : array + protected static function getExceptionConversionData(): array { return [ self::EXCEPTION_CONNECTION => [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php index 2ba6a732bd4..4276ee9f447 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php @@ -17,7 +17,7 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest { - public function testReturnsDatabaseName() : void + public function testReturnsDatabaseName(): void { parent::testReturnsDatabaseName(); @@ -46,17 +46,17 @@ public function testReturnsDatabaseName() : void self::assertSame($database, $this->driver->getDatabase($connection)); } - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractPostgreSQLDriver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new PostgreSqlPlatform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new PostgreSqlSchemaManager($connection); } @@ -64,7 +64,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected function getDatabasePlatformsForVersions() : array + protected function getDatabasePlatformsForVersions(): array { return [ ['9.0.9', PostgreSqlPlatform::class], @@ -86,7 +86,7 @@ protected function getDatabasePlatformsForVersions() : array /** * {@inheritDoc} */ - protected static function getExceptionConversionData() : array + protected static function getExceptionConversionData(): array { return [ self::EXCEPTION_CONNECTION => [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php index 4c51e7cb35f..e57daa2b66a 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php @@ -15,17 +15,17 @@ class AbstractSQLAnywhereDriverTest extends AbstractDriverTest { - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractSQLAnywhereDriver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new SQLAnywhere12Platform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new SQLAnywhereSchemaManager($connection); } @@ -33,7 +33,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected function getDatabasePlatformsForVersions() : array + protected function getDatabasePlatformsForVersions(): array { return [ ['10', SQLAnywherePlatform::class], @@ -71,7 +71,7 @@ protected function getDatabasePlatformsForVersions() : array /** * {@inheritDoc} */ - protected static function getExceptionConversionData() : array + protected static function getExceptionConversionData(): array { return [ self::EXCEPTION_CONNECTION => [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php index 30f23f19bb2..bd9b8b6b11e 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php @@ -14,12 +14,12 @@ abstract class AbstractSQLServerDriverTest extends AbstractDriverTest { - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new SQLServer2008Platform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new SQLServerSchemaManager($connection); } @@ -27,7 +27,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected function getDatabasePlatformsForVersions() : array + protected function getDatabasePlatformsForVersions(): array { return [ ['9', SQLServerPlatform::class], @@ -59,7 +59,7 @@ protected function getDatabasePlatformsForVersions() : array ]; } - public function testPortWithoutHost() : void + public function testPortWithoutHost(): void { $this->expectException(PortWithoutHost::class); $this->driver->connect(['port' => 1433]); diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php index 338f9126077..c5f2f353207 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php @@ -12,7 +12,7 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest { - public function testReturnsDatabaseName() : void + public function testReturnsDatabaseName(): void { $params = [ 'user' => 'foo', @@ -30,17 +30,17 @@ public function testReturnsDatabaseName() : void self::assertSame($params['path'], $this->driver->getDatabase($connection)); } - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractSQLiteDriver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new SqlitePlatform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new SqliteSchemaManager($connection); } @@ -48,7 +48,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected static function getExceptionConversionData() : array + protected static function getExceptionConversionData(): array { return [ self::EXCEPTION_CONNECTION => [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php index 3dbd5c64691..0f382d7febc 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php @@ -13,27 +13,27 @@ class DriverTest extends PDOMySQLDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('drizzle_pdo_mysql', $this->driver->getName()); } - public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion() : void + public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion(): void { $this->markTestSkipped('This test does not work on Drizzle as it is not version aware.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new DrizzlePlatform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new DrizzleSchemaManager($connection); } @@ -41,7 +41,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected function getDatabasePlatformsForVersions() : array + protected function getDatabasePlatformsForVersions(): array { return [ ['foo', DrizzlePlatform::class], diff --git a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php index 2f07209b1bc..e8b08f745e5 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php @@ -18,7 +18,7 @@ class DB2ConnectionTest extends DbalTestCase */ private $connectionMock; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -27,7 +27,7 @@ protected function setUp() : void ->getMockForAbstractClass(); } - public function testDoesNotRequireQueryForServerVersion() : void + public function testDoesNotRequireQueryForServerVersion(): void { self::assertFalse($this->connectionMock->requiresQueryForServerVersion()); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php index dcf9f6083e3..e48d3c40b66 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php @@ -8,12 +8,12 @@ class DB2DriverTest extends AbstractDB2DriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('ibm_db2', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new DB2Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DataSourceNameTest.php b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DataSourceNameTest.php index 5f5297dd159..aad029a435d 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DataSourceNameTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DataSourceNameTest.php @@ -12,7 +12,7 @@ class DataSourceNameTest extends TestCase * * @dataProvider connectionParametersProvider */ - public function testFromConnectionParameters(array $params, string $expected) : void + public function testFromConnectionParameters(array $params, string $expected): void { $dsn = DataSourceName::fromConnectionParameters($params); @@ -22,9 +22,9 @@ public function testFromConnectionParameters(array $params, string $expected) : /** * @return iterable> */ - public static function connectionParametersProvider() : iterable + public static function connectionParametersProvider(): iterable { - yield 'empty-params' => [[],'']; + yield 'empty-params' => [[], '']; yield 'cataloged-database' => [ [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php index bbe16b34717..0a5265cf9c7 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractMySQLDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('mysqli', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php index 517332f71c1..9611da063cd 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\Tests\DbalFunctionalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function restore_error_handler; use function set_error_handler; @@ -22,7 +23,7 @@ class MysqliConnectionTest extends DbalFunctionalTestCase */ private $connectionMock; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -35,14 +36,14 @@ protected function setUp() : void ->getMockForAbstractClass(); } - public function testDoesNotRequireQueryForServerVersion() : void + public function testDoesNotRequireQueryForServerVersion(): void { self::assertFalse($this->connectionMock->requiresQueryForServerVersion()); } - public function testRestoresErrorHandlerOnException() : void + public function testRestoresErrorHandlerOnException(): void { - $handler = static function () : bool { + $handler = static function (): bool { self::fail('Never expected this to be called'); }; diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php index 7b6ed1d5a55..eedfdec6844 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractOracleDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('oci8', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php index d953613a5a4..12cd8ef7af4 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php @@ -18,7 +18,7 @@ class OCI8ConnectionTest extends DbalTestCase */ private $connectionMock; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -27,7 +27,7 @@ protected function setUp() : void ->getMockForAbstractClass(); } - public function testDoesNotRequireQueryForServerVersion() : void + public function testDoesNotRequireQueryForServerVersion(): void { self::assertFalse($this->connectionMock->requiresQueryForServerVersion()); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php index 8141b61348f..ed8d0d88b6b 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php @@ -26,7 +26,7 @@ class OCI8StatementTest extends DbalTestCase * * @dataProvider executeDataProvider */ - public function testExecute(array $params) : void + public function testExecute(array $params): void { $statement = $this->getMockBuilder(OCI8Statement::class) ->onlyMethods(['bindValue', 'errorInfo']) @@ -77,7 +77,7 @@ public function testExecute(array $params) : void /** * @return array> */ - public static function executeDataProvider() : iterable + public static function executeDataProvider(): iterable { return [ // $hasZeroIndex = isset($params[0]); == true @@ -94,7 +94,7 @@ public static function executeDataProvider() : iterable /** * @dataProvider nonTerminatedLiteralProvider */ - public function testConvertNonTerminatedLiteral(string $sql, string $message) : void + public function testConvertNonTerminatedLiteral(string $sql, string $message): void { $this->expectException(OCI8Exception::class); $this->expectExceptionMessageRegExp($message); @@ -104,7 +104,7 @@ public function testConvertNonTerminatedLiteral(string $sql, string $message) : /** * @return array> */ - public static function nonTerminatedLiteralProvider() : iterable + public static function nonTerminatedLiteralProvider(): iterable { return [ 'no-matching-quote' => [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php index c8c3b92b017..98189453df1 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php @@ -31,7 +31,7 @@ class PDOExceptionTest extends DbalTestCase */ private $wrappedException; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -42,27 +42,27 @@ protected function setUp() : void $this->exception = new PDOException($this->wrappedException); } - public function testReturnsCode() : void + public function testReturnsCode(): void { self::assertSame(self::SQLSTATE, $this->exception->getCode()); } - public function testReturnsErrorCode() : void + public function testReturnsErrorCode(): void { self::assertSame(self::ERROR_CODE, $this->exception->getErrorCode()); } - public function testReturnsMessage() : void + public function testReturnsMessage(): void { self::assertSame(self::MESSAGE, $this->exception->getMessage()); } - public function testReturnsSQLState() : void + public function testReturnsSQLState(): void { self::assertSame(self::SQLSTATE, $this->exception->getSQLState()); } - public function testOriginalExceptionIsInChain() : void + public function testOriginalExceptionIsInChain(): void { self::assertSame($this->wrappedException, $this->exception->getPrevious()); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php index 9eeeafb78aa..bd9ea3f2080 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractDB2DriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('pdo_ibm', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php index 6e3ef7d5a03..e67a0673402 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractMySQLDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('pdo_mysql', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php index 42353be376d..ae647cbe0cd 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractOracleDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('pdo_oracle', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php index 3bee808cd89..5e3d24583f7 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php @@ -12,7 +12,7 @@ class DriverTest extends AbstractPostgreSQLDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('pdo_pgsql', $this->driver->getName()); } @@ -20,7 +20,7 @@ public function testReturnsName() : void /** * @group DBAL-920 */ - public function testConnectionDisablesPreparesOnPhp56() : void + public function testConnectionDisablesPreparesOnPhp56(): void { $this->skipWhenNotUsingPdoPgsql(); @@ -37,7 +37,7 @@ public function testConnectionDisablesPreparesOnPhp56() : void /** * @group DBAL-920 */ - public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined() : void + public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined(): void { $this->skipWhenNotUsingPdoPgsql(); @@ -56,7 +56,7 @@ public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined( /** * @group DBAL-920 */ - public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplicitlyDefined() : void + public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplicitlyDefined(): void { $this->skipWhenNotUsingPdoPgsql(); @@ -72,12 +72,12 @@ public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplici } } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } - private function skipWhenNotUsingPdoPgsql() : void + private function skipWhenNotUsingPdoPgsql(): void { if (isset($GLOBALS['db_driver']) && $GLOBALS['db_driver'] === 'pdo_pgsql') { return; @@ -89,7 +89,7 @@ private function skipWhenNotUsingPdoPgsql() : void /** * @param array $driverOptions */ - private function connect(array $driverOptions) : PDOConnection + private function connect(array $driverOptions): PDOConnection { $params = TestUtil::getConnectionParams(); diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php index 9092b091e3a..b360a46cba6 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractSQLiteDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('pdo_sqlite', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php index c92dc86d5ba..e3ee50ff293 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractSQLServerDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('pdo_sqlsrv', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php index d6f1595a45e..a1bebb72b25 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractSQLAnywhereDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('sqlanywhere', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php index 72e5e25ec4f..b2d1ddef6fc 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php @@ -18,7 +18,7 @@ class SQLAnywhereConnectionTest extends DbalTestCase */ private $connectionMock; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -27,7 +27,7 @@ protected function setUp() : void ->getMockForAbstractClass(); } - public function testRequiresQueryForServerVersion() : void + public function testRequiresQueryForServerVersion(): void { self::assertTrue($this->connectionMock->requiresQueryForServerVersion()); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php index 9ab6635ecf4..d2549a6e344 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractSQLServerDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('sqlsrv', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php index ecac3f60d91..8d424ee21b6 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php @@ -18,7 +18,7 @@ class SQLSrvConnectionTest extends DbalTestCase /** * @requires extension sqlsrv */ - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -27,7 +27,7 @@ protected function setUp() : void ->getMockForAbstractClass(); } - public function testDoesNotRequireQueryForServerVersion() : void + public function testDoesNotRequireQueryForServerVersion(): void { self::assertFalse($this->connectionMock->requiresQueryForServerVersion()); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php b/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php index 0e01efb80d5..89d88c8349e 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php @@ -15,6 +15,7 @@ use IteratorIterator; use PHPUnit\Framework\MockObject\MockObject; use Traversable; + use function extension_loaded; class StatementIteratorTest extends DbalTestCase @@ -24,7 +25,7 @@ class StatementIteratorTest extends DbalTestCase * * @dataProvider statementProvider() */ - public function testGettingIteratorDoesNotCallFetch(string $class) : void + public function testGettingIteratorDoesNotCallFetch(string $class): void { $stmt = $this->createPartialMock($class, ['fetch', 'fetchAll', 'fetchColumn']); @@ -35,7 +36,7 @@ public function testGettingIteratorDoesNotCallFetch(string $class) : void new IteratorIterator($stmt); } - public function testIteratorIterationCallsFetchOncePerStep() : void + public function testIteratorIterationCallsFetchOncePerStep(): void { $stmt = $this->createMock(Statement::class); @@ -52,7 +53,7 @@ public function testIteratorIterationCallsFetchOncePerStep() : void * * @dataProvider statementProvider() */ - public function testStatementIterationCallsFetchOncePerStep(string $class) : void + public function testStatementIterationCallsFetchOncePerStep(string $class): void { $stmt = $this->createPartialMock($class, ['fetch']); @@ -61,7 +62,7 @@ public function testStatementIterationCallsFetchOncePerStep(string $class) : voi $this->assertIterationCallsFetchOncePerStep($stmt, $calls); } - private function configureStatement(MockObject $stmt, int &$calls) : void + private function configureStatement(MockObject $stmt, int &$calls): void { $values = ['foo', '', 'bar', '0', 'baz', 0, 'qux', null, 'quz', false, 'impossible']; $calls = 0; @@ -79,7 +80,7 @@ private function configureStatement(MockObject $stmt, int &$calls) : void /** * @param Traversable $iterator */ - private function assertIterationCallsFetchOncePerStep(Traversable $iterator, int &$calls) : void + private function assertIterationCallsFetchOncePerStep(Traversable $iterator, int &$calls): void { foreach ($iterator as $i => $_) { $this->assertEquals($i + 1, $calls); @@ -89,7 +90,7 @@ private function assertIterationCallsFetchOncePerStep(Traversable $iterator, int /** * @return iterable}> */ - public static function statementProvider() : iterable + public static function statementProvider(): iterable { if (extension_loaded('ibm_db2')) { yield [DB2Statement::class]; diff --git a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php index 7577d5504b6..524e03031c4 100644 --- a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php @@ -17,6 +17,7 @@ use Doctrine\Tests\DbalTestCase; use PDO; use stdClass; + use function extension_loaded; use function get_class; use function in_array; @@ -27,7 +28,7 @@ class DriverManagerTest extends DbalTestCase /** * @requires extension pdo_sqlite */ - public function testInvalidPdoInstance() : void + public function testInvalidPdoInstance(): void { $this->expectException(DBALException::class); DriverManager::getConnection(['pdo' => 'test']); @@ -36,7 +37,7 @@ public function testInvalidPdoInstance() : void /** * @requires extension pdo_sqlite */ - public function testValidPdoInstance() : void + public function testValidPdoInstance(): void { $conn = DriverManager::getConnection([ 'pdo' => new PDO('sqlite::memory:'), @@ -49,7 +50,7 @@ public function testValidPdoInstance() : void * @group DBAL-32 * @requires extension pdo_sqlite */ - public function testPdoInstanceSetErrorMode() : void + public function testPdoInstanceSetErrorMode(): void { $pdo = new PDO('sqlite::memory:'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); @@ -59,14 +60,14 @@ public function testPdoInstanceSetErrorMode() : void self::assertEquals(PDO::ERRMODE_EXCEPTION, $pdo->getAttribute(PDO::ATTR_ERRMODE)); } - public function testCheckParams() : void + public function testCheckParams(): void { $this->expectException(DBALException::class); DriverManager::getConnection([]); } - public function testInvalidDriver() : void + public function testInvalidDriver(): void { $this->expectException(DBALException::class); @@ -76,7 +77,7 @@ public function testInvalidDriver() : void /** * @requires extension pdo_sqlite */ - public function testCustomPlatform() : void + public function testCustomPlatform(): void { $platform = $this->createMock(AbstractPlatform::class); $options = [ @@ -91,7 +92,7 @@ public function testCustomPlatform() : void /** * @requires extension pdo_sqlite */ - public function testCustomWrapper() : void + public function testCustomWrapper(): void { $wrapper = $this->createMock(Connection::class); $wrapperClass = get_class($wrapper); @@ -109,7 +110,7 @@ public function testCustomWrapper() : void * @requires extension pdo_sqlite * @psalm-suppress InvalidArgument */ - public function testInvalidWrapperClass() : void + public function testInvalidWrapperClass(): void { $this->expectException(DBALException::class); @@ -121,7 +122,7 @@ public function testInvalidWrapperClass() : void DriverManager::getConnection($options); } - public function testInvalidDriverClass() : void + public function testInvalidDriverClass(): void { $this->expectException(DBALException::class); @@ -130,7 +131,7 @@ public function testInvalidDriverClass() : void DriverManager::getConnection($options); } - public function testValidDriverClass() : void + public function testValidDriverClass(): void { $options = ['driverClass' => PDOMySQLDriver::class]; @@ -138,7 +139,7 @@ public function testValidDriverClass() : void self::assertInstanceOf(PDOMySQLDriver::class, $conn->getDriver()); } - public function testDatabaseUrlMasterSlave() : void + public function testDatabaseUrlMasterSlave(): void { $options = [ 'driver' => 'pdo_mysql', @@ -170,7 +171,7 @@ public function testDatabaseUrlMasterSlave() : void self::assertEquals('baz_slave', $params['slaves']['slave1']['dbname']); } - public function testDatabaseUrlShard() : void + public function testDatabaseUrlShard(): void { $options = [ 'driver' => 'pdo_mysql', @@ -212,7 +213,7 @@ public function testDatabaseUrlShard() : void * * @dataProvider databaseUrls */ - public function testDatabaseUrl($url, $expected) : void + public function testDatabaseUrl($url, $expected): void { $options = is_array($url) ? $url : ['url' => $url]; @@ -245,7 +246,7 @@ public function testDatabaseUrl($url, $expected) : void /** * @return array> */ - public function databaseUrls() : iterable + public function databaseUrls(): iterable { $driver = $this->createMock(Driver::class); $driverClass = get_class($driver); diff --git a/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php index daea3a754c6..73df349a832 100644 --- a/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php +++ b/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php @@ -10,7 +10,7 @@ class MysqlSessionInitTest extends DbalTestCase { - public function testPostConnect() : void + public function testPostConnect(): void { $connectionMock = $this->createMock(Connection::class); $connectionMock->expects($this->once()) @@ -23,7 +23,7 @@ public function testPostConnect() : void $listener->postConnect($eventArgs); } - public function testGetSubscribedEvents() : void + public function testGetSubscribedEvents(): void { $listener = new MysqlSessionInit(); self::assertEquals([Events::postConnect], $listener->getSubscribedEvents()); diff --git a/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php index 998b1dc916e..a9dc64b8855 100644 --- a/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php +++ b/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php @@ -7,11 +7,12 @@ use Doctrine\DBAL\Event\Listeners\OracleSessionInit; use Doctrine\DBAL\Events; use Doctrine\Tests\DbalTestCase; + use function sprintf; class OracleSessionInitTest extends DbalTestCase { - public function testPostConnect() : void + public function testPostConnect(): void { $connectionMock = $this->createMock(Connection::class); $connectionMock->expects($this->once()) @@ -28,7 +29,7 @@ public function testPostConnect() : void * @group DBAL-1824 * @dataProvider getPostConnectWithSessionParameterValuesData */ - public function testPostConnectQuotesSessionParameterValues(string $name, string $value) : void + public function testPostConnectQuotesSessionParameterValues(string $name, string $value): void { $connectionMock = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() @@ -46,14 +47,14 @@ public function testPostConnectQuotesSessionParameterValues(string $name, string /** * @return array> */ - public static function getPostConnectWithSessionParameterValuesData() : iterable + public static function getPostConnectWithSessionParameterValuesData(): iterable { return [ ['CURRENT_SCHEMA', 'foo'], ]; } - public function testGetSubscribedEvents() : void + public function testGetSubscribedEvents(): void { $listener = new OracleSessionInit(); self::assertEquals([Events::postConnect], $listener->getSubscribedEvents()); diff --git a/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php index c69b2996827..efa098a2b22 100644 --- a/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php +++ b/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php @@ -13,7 +13,7 @@ */ class SQLSessionInitTest extends DbalTestCase { - public function testPostConnect() : void + public function testPostConnect(): void { $connectionMock = $this->createMock(Connection::class); $connectionMock->expects($this->once()) @@ -26,7 +26,7 @@ public function testPostConnect() : void $listener->postConnect($eventArgs); } - public function testGetSubscribedEvents() : void + public function testGetSubscribedEvents(): void { $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"); self::assertEquals([Events::postConnect], $listener->getSubscribedEvents()); diff --git a/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php b/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php index 7718a6bc9d8..024b0bb20cc 100644 --- a/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php @@ -12,7 +12,7 @@ */ class InvalidArgumentExceptionTest extends TestCase { - public function testFromEmptyCriteria() : void + public function testFromEmptyCriteria(): void { $exception = InvalidArgumentException::fromEmptyCriteria(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php index a12d0600201..20ea0870476 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; + use function fopen; use function str_repeat; use function stream_get_contents; @@ -18,7 +19,7 @@ */ class BlobTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -38,7 +39,7 @@ protected function setUp() : void $sm->dropAndCreateTable($table); } - public function testInsert() : void + public function testInsert(): void { $ret = $this->connection->insert('blob_table', [ 'id' => 1, @@ -53,7 +54,7 @@ public function testInsert() : void self::assertEquals(1, $ret); } - public function testInsertProcessesStream() : void + public function testInsertProcessesStream(): void { // https://github.com/doctrine/dbal/issues/3290 if ($this->connection->getDriver() instanceof OCI8Driver) { @@ -74,7 +75,7 @@ public function testInsertProcessesStream() : void $this->assertBlobContains($longBlob); } - public function testSelect() : void + public function testSelect(): void { $this->connection->insert('blob_table', [ 'id' => 1, @@ -89,7 +90,7 @@ public function testSelect() : void $this->assertBlobContains('test'); } - public function testUpdate() : void + public function testUpdate(): void { $this->connection->insert('blob_table', [ 'id' => 1, @@ -109,7 +110,7 @@ public function testUpdate() : void $this->assertBlobContains('test2'); } - public function testUpdateProcessesStream() : void + public function testUpdateProcessesStream(): void { // https://github.com/doctrine/dbal/issues/3290 if ($this->connection->getDriver() instanceof OCI8Driver) { @@ -137,7 +138,7 @@ public function testUpdateProcessesStream() : void $this->assertBlobContains('test2'); } - public function testBindParamProcessesStream() : void + public function testBindParamProcessesStream(): void { if ($this->connection->getDriver() instanceof OCI8Driver) { $this->markTestIncomplete('The oci8 driver does not support stream resources as parameters'); @@ -156,7 +157,7 @@ public function testBindParamProcessesStream() : void $this->assertBlobContains('test'); } - private function assertBlobContains(string $text) : void + private function assertBlobContains(string $text): void { $rows = $this->connection->query('SELECT blobfield FROM blob_table')->fetchAll(FetchMode::COLUMN); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php index 5ea675c9e1a..8573ecab686 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php @@ -15,19 +15,20 @@ use PDO; use RuntimeException; use Throwable; + use function file_exists; use function in_array; use function unlink; class ConnectionTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { $this->resetSharedConn(); parent::setUp(); } - protected function tearDown() : void + protected function tearDown(): void { if (file_exists('/tmp/test_nesting.sqlite')) { unlink('/tmp/test_nesting.sqlite'); @@ -37,12 +38,12 @@ protected function tearDown() : void $this->resetSharedConn(); } - public function testGetWrappedConnection() : void + public function testGetWrappedConnection(): void { self::assertInstanceOf(DriverConnection::class, $this->connection->getWrappedConnection()); } - public function testCommitWithRollbackOnlyThrowsException() : void + public function testCommitWithRollbackOnlyThrowsException(): void { $this->connection->beginTransaction(); $this->connection->setRollbackOnly(); @@ -51,7 +52,7 @@ public function testCommitWithRollbackOnlyThrowsException() : void $this->connection->commit(); } - public function testTransactionNestingBehavior() : void + public function testTransactionNestingBehavior(): void { try { $this->connection->beginTransaction(); @@ -86,7 +87,7 @@ public function testTransactionNestingBehavior() : void self::assertEquals(1, $this->connection->getTransactionNestingLevel()); } - public function testTransactionNestingLevelIsResetOnReconnect() : void + public function testTransactionNestingLevelIsResetOnReconnect(): void { if ($this->connection->getDatabasePlatform()->getName() === 'sqlite') { $params = $this->connection->getParams(); @@ -115,7 +116,7 @@ public function testTransactionNestingLevelIsResetOnReconnect() : void self::assertEquals(0, $connection->fetchColumn('select count(*) from test_nesting')); } - public function testTransactionNestingBehaviorWithSavepoints() : void + public function testTransactionNestingBehaviorWithSavepoints(): void { if (! $this->connection->getDatabasePlatform()->supportsSavepoints()) { $this->markTestSkipped('This test requires the platform to support savepoints.'); @@ -158,7 +159,7 @@ public function testTransactionNestingBehaviorWithSavepoints() : void } } - public function testTransactionNestingBehaviorCantBeChangedInActiveTransaction() : void + public function testTransactionNestingBehaviorCantBeChangedInActiveTransaction(): void { if (! $this->connection->getDatabasePlatform()->supportsSavepoints()) { $this->markTestSkipped('This test requires the platform to support savepoints.'); @@ -169,7 +170,7 @@ public function testTransactionNestingBehaviorCantBeChangedInActiveTransaction() $this->connection->setNestTransactionsWithSavepoints(true); } - public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsException() : void + public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsException(): void { if ($this->connection->getDatabasePlatform()->supportsSavepoints()) { $this->markTestSkipped('This test requires the platform not to support savepoints.'); @@ -181,7 +182,7 @@ public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsExce $this->connection->setNestTransactionsWithSavepoints(true); } - public function testCreateSavepointsNotSupportedThrowsException() : void + public function testCreateSavepointsNotSupportedThrowsException(): void { if ($this->connection->getDatabasePlatform()->supportsSavepoints()) { $this->markTestSkipped('This test requires the platform not to support savepoints.'); @@ -193,7 +194,7 @@ public function testCreateSavepointsNotSupportedThrowsException() : void $this->connection->createSavepoint('foo'); } - public function testReleaseSavepointsNotSupportedThrowsException() : void + public function testReleaseSavepointsNotSupportedThrowsException(): void { if ($this->connection->getDatabasePlatform()->supportsSavepoints()) { $this->markTestSkipped('This test requires the platform not to support savepoints.'); @@ -205,7 +206,7 @@ public function testReleaseSavepointsNotSupportedThrowsException() : void $this->connection->releaseSavepoint('foo'); } - public function testRollbackSavepointsNotSupportedThrowsException() : void + public function testRollbackSavepointsNotSupportedThrowsException(): void { if ($this->connection->getDatabasePlatform()->supportsSavepoints()) { $this->markTestSkipped('This test requires the platform not to support savepoints.'); @@ -217,7 +218,7 @@ public function testRollbackSavepointsNotSupportedThrowsException() : void $this->connection->rollbackSavepoint('foo'); } - public function testTransactionBehaviorWithRollback() : void + public function testTransactionBehaviorWithRollback(): void { try { $this->connection->beginTransaction(); @@ -233,7 +234,7 @@ public function testTransactionBehaviorWithRollback() : void } } - public function testTransactionBehaviour() : void + public function testTransactionBehaviour(): void { try { $this->connection->beginTransaction(); @@ -247,10 +248,10 @@ public function testTransactionBehaviour() : void self::assertEquals(0, $this->connection->getTransactionNestingLevel()); } - public function testTransactionalWithException() : void + public function testTransactionalWithException(): void { try { - $this->connection->transactional(static function ($conn) : void { + $this->connection->transactional(static function ($conn): void { /** @var Connection $conn */ $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); @@ -262,10 +263,10 @@ public function testTransactionalWithException() : void } } - public function testTransactionalWithThrowable() : void + public function testTransactionalWithThrowable(): void { try { - $this->connection->transactional(static function ($conn) : void { + $this->connection->transactional(static function ($conn): void { /** @var Connection $conn */ $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); @@ -277,9 +278,9 @@ public function testTransactionalWithThrowable() : void } } - public function testTransactional() : void + public function testTransactional(): void { - $res = $this->connection->transactional(static function ($conn) : void { + $res = $this->connection->transactional(static function ($conn): void { /** @var Connection $conn */ $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); }); @@ -287,7 +288,7 @@ public function testTransactional() : void self::assertNull($res); } - public function testTransactionalReturnValue() : void + public function testTransactionalReturnValue(): void { $res = $this->connection->transactional(static function () { return 42; @@ -299,7 +300,7 @@ public function testTransactionalReturnValue() : void /** * Tests that the quote function accepts DBAL and PDO types. */ - public function testQuote() : void + public function testQuote(): void { self::assertEquals( $this->connection->quote('foo', Types::STRING), @@ -307,7 +308,7 @@ public function testQuote() : void ); } - public function testPingDoesTriggersConnect() : void + public function testPingDoesTriggersConnect(): void { self::assertTrue($this->connection->ping()); self::assertTrue($this->connection->isConnected()); @@ -316,7 +317,7 @@ public function testPingDoesTriggersConnect() : void /** * @group DBAL-1025 */ - public function testConnectWithoutExplicitDatabaseName() : void + public function testConnectWithoutExplicitDatabaseName(): void { if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) { $this->markTestSkipped('Platform does not support connecting without database name.'); @@ -339,7 +340,7 @@ public function testConnectWithoutExplicitDatabaseName() : void /** * @group DBAL-990 */ - public function testDeterminesDatabasePlatformWhenConnectingToNonExistentDatabase() : void + public function testDeterminesDatabasePlatformWhenConnectingToNonExistentDatabase(): void { if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) { $this->markTestSkipped('Platform does not support connecting without database name.'); @@ -365,7 +366,7 @@ public function testDeterminesDatabasePlatformWhenConnectingToNonExistentDatabas /** * @requires extension pdo_sqlite */ - public function testUserProvidedPDOConnection() : void + public function testUserProvidedPDOConnection(): void { self::assertTrue( DriverManager::getConnection([ diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index 29d82fdbe19..1fe74ad4075 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -19,6 +19,7 @@ use Doctrine\DBAL\Types\Types; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; + use function array_change_key_case; use function array_filter; use function array_keys; @@ -30,6 +31,7 @@ use function property_exists; use function sprintf; use function strtotime; + use const CASE_LOWER; use const PHP_EOL; @@ -38,7 +40,7 @@ class DataAccessTest extends DbalFunctionalTestCase /** @var bool */ private static $generated = false; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -59,7 +61,7 @@ protected function setUp() : void self::$generated = true; } - public function testPrepareWithBindValue() : void + public function testPrepareWithBindValue(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $stmt = $this->connection->prepare($sql); @@ -74,7 +76,7 @@ public function testPrepareWithBindValue() : void self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $row); } - public function testPrepareWithBindParam() : void + public function testPrepareWithBindParam(): void { $paramInt = 1; $paramStr = 'foo'; @@ -92,7 +94,7 @@ public function testPrepareWithBindParam() : void self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $row); } - public function testPrepareWithFetchAll() : void + public function testPrepareWithFetchAll(): void { $paramInt = 1; $paramStr = 'foo'; @@ -113,7 +115,7 @@ public function testPrepareWithFetchAll() : void /** * @group DBAL-228 */ - public function testPrepareWithFetchAllBoth() : void + public function testPrepareWithFetchAllBoth(): void { $paramInt = 1; $paramStr = 'foo'; @@ -131,7 +133,7 @@ public function testPrepareWithFetchAllBoth() : void self::assertEquals(['test_int' => 1, 'test_string' => 'foo', 0 => 1, 1 => 'foo'], $rows[0]); } - public function testPrepareWithFetchColumn() : void + public function testPrepareWithFetchColumn(): void { $paramInt = 1; $paramStr = 'foo'; @@ -148,7 +150,7 @@ public function testPrepareWithFetchColumn() : void self::assertEquals(1, $column); } - public function testPrepareWithIterator() : void + public function testPrepareWithIterator(): void { $paramInt = 1; $paramStr = 'foo'; @@ -170,7 +172,7 @@ public function testPrepareWithIterator() : void self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $rows[0]); } - public function testPrepareWithQuoted() : void + public function testPrepareWithQuoted(): void { $table = 'fetch_table'; $paramInt = 1; @@ -185,7 +187,7 @@ public function testPrepareWithQuoted() : void self::assertInstanceOf(Statement::class, $stmt); } - public function testPrepareWithExecuteParams() : void + public function testPrepareWithExecuteParams(): void { $paramInt = 1; $paramStr = 'foo'; @@ -201,7 +203,7 @@ public function testPrepareWithExecuteParams() : void self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $row); } - public function testFetchAll() : void + public function testFetchAll(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $data = $this->connection->fetchAll($sql, [1, 'foo']); @@ -219,7 +221,7 @@ public function testFetchAll() : void /** * @group DBAL-209 */ - public function testFetchAllWithTypes() : void + public function testFetchAllWithTypes(): void { $datetimeString = '2010-01-01 10:10:10'; $datetime = new DateTime($datetimeString); @@ -244,10 +246,12 @@ public function testFetchAllWithTypes() : void /** * @group DBAL-209 */ - public function testFetchAllWithMissingTypes() : void + public function testFetchAllWithMissingTypes(): void { - if ($this->connection->getDriver() instanceof MySQLiDriver || - $this->connection->getDriver() instanceof SQLSrvDriver) { + if ( + $this->connection->getDriver() instanceof MySQLiDriver || + $this->connection->getDriver() instanceof SQLSrvDriver + ) { $this->markTestSkipped('mysqli and sqlsrv actually supports this'); } @@ -260,7 +264,7 @@ public function testFetchAllWithMissingTypes() : void $this->connection->fetchAll($sql, [1, $datetime]); } - public function testFetchBoth() : void + public function testFetchBoth(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $row = $this->connection->executeQuery($sql, [1, 'foo'])->fetch(FetchMode::MIXED); @@ -275,14 +279,14 @@ public function testFetchBoth() : void self::assertEquals('foo', $row[1]); } - public function testFetchNoResult() : void + public function testFetchNoResult(): void { self::assertFalse( $this->connection->executeQuery('SELECT test_int FROM fetch_table WHERE test_int = ?', [-1])->fetch() ); } - public function testFetchAssoc() : void + public function testFetchAssoc(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $row = $this->connection->fetchAssoc($sql, [1, 'foo']); @@ -295,7 +299,7 @@ public function testFetchAssoc() : void self::assertEquals('foo', $row['test_string']); } - public function testFetchAssocWithTypes() : void + public function testFetchAssocWithTypes(): void { $datetimeString = '2010-01-01 10:10:10'; $datetime = new DateTime($datetimeString); @@ -315,10 +319,12 @@ public function testFetchAssocWithTypes() : void self::assertStringStartsWith($datetimeString, $row['test_datetime']); } - public function testFetchAssocWithMissingTypes() : void + public function testFetchAssocWithMissingTypes(): void { - if ($this->connection->getDriver() instanceof MySQLiDriver || - $this->connection->getDriver() instanceof SQLSrvDriver) { + if ( + $this->connection->getDriver() instanceof MySQLiDriver || + $this->connection->getDriver() instanceof SQLSrvDriver + ) { $this->markTestSkipped('mysqli and sqlsrv actually supports this'); } @@ -331,7 +337,7 @@ public function testFetchAssocWithMissingTypes() : void $this->connection->fetchAssoc($sql, [1, $datetime]); } - public function testFetchArray() : void + public function testFetchArray(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $row = $this->connection->fetchArray($sql, [1, 'foo']); @@ -340,7 +346,7 @@ public function testFetchArray() : void self::assertEquals('foo', $row[1]); } - public function testFetchArrayWithTypes() : void + public function testFetchArrayWithTypes(): void { $datetimeString = '2010-01-01 10:10:10'; $datetime = new DateTime($datetimeString); @@ -360,10 +366,12 @@ public function testFetchArrayWithTypes() : void self::assertStringStartsWith($datetimeString, $row[1]); } - public function testFetchArrayWithMissingTypes() : void + public function testFetchArrayWithMissingTypes(): void { - if ($this->connection->getDriver() instanceof MySQLiDriver || - $this->connection->getDriver() instanceof SQLSrvDriver) { + if ( + $this->connection->getDriver() instanceof MySQLiDriver || + $this->connection->getDriver() instanceof SQLSrvDriver + ) { $this->markTestSkipped('mysqli and sqlsrv actually supports this'); } @@ -376,7 +384,7 @@ public function testFetchArrayWithMissingTypes() : void $this->connection->fetchArray($sql, [1, $datetime]); } - public function testFetchColumn() : void + public function testFetchColumn(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $testInt = $this->connection->fetchColumn($sql, [1, 'foo'], 0); @@ -389,7 +397,7 @@ public function testFetchColumn() : void self::assertEquals('foo', $testString); } - public function testFetchColumnWithTypes() : void + public function testFetchColumnWithTypes(): void { $datetimeString = '2010-01-01 10:10:10'; $datetime = new DateTime($datetimeString); @@ -407,10 +415,12 @@ public function testFetchColumnWithTypes() : void self::assertStringStartsWith($datetimeString, $column); } - public function testFetchColumnWithMissingTypes() : void + public function testFetchColumnWithMissingTypes(): void { - if ($this->connection->getDriver() instanceof MySQLiDriver || - $this->connection->getDriver() instanceof SQLSrvDriver) { + if ( + $this->connection->getDriver() instanceof MySQLiDriver || + $this->connection->getDriver() instanceof SQLSrvDriver + ) { $this->markTestSkipped('mysqli and sqlsrv actually supports this'); } @@ -426,7 +436,7 @@ public function testFetchColumnWithMissingTypes() : void /** * @group DDC-697 */ - public function testExecuteQueryBindDateTimeType() : void + public function testExecuteQueryBindDateTimeType(): void { $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'; $stmt = $this->connection->executeQuery( @@ -441,7 +451,7 @@ public function testExecuteQueryBindDateTimeType() : void /** * @group DDC-697 */ - public function testExecuteUpdateBindDateTimeType() : void + public function testExecuteUpdateBindDateTimeType(): void { $datetime = new DateTime('2010-02-02 20:20:20'); @@ -467,7 +477,7 @@ public function testExecuteUpdateBindDateTimeType() : void /** * @group DDC-697 */ - public function testPrepareQueryBindValueDateTimeType() : void + public function testPrepareQueryBindValueDateTimeType(): void { $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'; $stmt = $this->connection->prepare($sql); @@ -480,7 +490,7 @@ public function testPrepareQueryBindValueDateTimeType() : void /** * @group DBAL-78 */ - public function testNativeArrayListSupport() : void + public function testNativeArrayListSupport(): void { for ($i = 100; $i < 110; $i++) { $this->connection->insert('fetch_table', ['test_int' => $i, 'test_string' => 'foo' . $i, 'test_datetime' => '2010-01-01 10:10:10']); @@ -512,7 +522,7 @@ public function testNativeArrayListSupport() : void * * @dataProvider getTrimExpressionData */ - public function testTrimExpression(string $value, int $position, $char, string $expectedResult) : void + public function testTrimExpression(string $value, int $position, $char, string $expectedResult): void { $sql = 'SELECT ' . $this->connection->getDatabasePlatform()->getTrimExpression($value, $position, $char) . ' AS trimmed ' . @@ -527,7 +537,7 @@ public function testTrimExpression(string $value, int $position, $char, string $ /** * @return array> */ - public static function getTrimExpressionData() : iterable + public static function getTrimExpressionData(): iterable { return [ ['test_string', TrimMode::UNSPECIFIED, false, 'foo'], @@ -572,7 +582,7 @@ public static function getTrimExpressionData() : iterable /** * @group DDC-1014 */ - public function testDateArithmetics() : void + public function testDateArithmetics(): void { $p = $this->connection->getDatabasePlatform(); $sql = 'SELECT '; @@ -615,7 +625,7 @@ public function testDateArithmetics() : void self::assertEquals('2004-01-01', date('Y-m-d', strtotime($row['sub_years'])), 'Subtracting years should end up on 2004-01-01'); } - public function testSqliteDateArithmeticWithDynamicInterval() : void + public function testSqliteDateArithmeticWithDynamicInterval(): void { $platform = $this->connection->getDatabasePlatform(); @@ -642,7 +652,7 @@ public function testSqliteDateArithmeticWithDynamicInterval() : void $this->assertEquals(1, $rowCount); } - public function testLocateExpression() : void + public function testLocateExpression(): void { $platform = $this->connection->getDatabasePlatform(); @@ -672,7 +682,7 @@ public function testLocateExpression() : void self::assertEquals(0, $row['locate9']); } - public function testQuoteSQLInjection() : void + public function testQuoteSQLInjection(): void { $sql = 'SELECT * FROM fetch_table WHERE test_string = ' . $this->connection->quote("bar' OR '1'='1"); $rows = $this->connection->fetchAll($sql); @@ -683,7 +693,7 @@ public function testQuoteSQLInjection() : void /** * @group DDC-1213 */ - public function testBitComparisonExpressionSupport() : void + public function testBitComparisonExpressionSupport(): void { $this->connection->exec('DELETE FROM fetch_table'); $platform = $this->connection->getDatabasePlatform(); @@ -731,7 +741,7 @@ public function testBitComparisonExpressionSupport() : void } } - public function testSetDefaultFetchMode() : void + public function testSetDefaultFetchMode(): void { $stmt = $this->connection->query('SELECT * FROM fetch_table'); $stmt->setFetchMode(FetchMode::NUMERIC); @@ -745,7 +755,7 @@ public function testSetDefaultFetchMode() : void /** * @group DBAL-1091 */ - public function testFetchAllStyleObject() : void + public function testFetchAllStyleObject(): void { $this->setupFixture(); @@ -776,7 +786,7 @@ public function testFetchAllStyleObject() : void /** * @group DBAL-196 */ - public function testFetchAllSupportFetchClass() : void + public function testFetchAllSupportFetchClass(): void { $this->beforeFetchClassTest(); $this->setupFixture(); @@ -801,7 +811,7 @@ public function testFetchAllSupportFetchClass() : void /** * @group DBAL-241 */ - public function testFetchAllStyleColumn() : void + public function testFetchAllStyleColumn(): void { $sql = 'DELETE FROM fetch_table'; $this->connection->executeUpdate($sql); @@ -818,7 +828,7 @@ public function testFetchAllStyleColumn() : void /** * @group DBAL-214 */ - public function testSetFetchModeClassFetchAll() : void + public function testSetFetchModeClassFetchAll(): void { $this->beforeFetchClassTest(); $this->setupFixture(); @@ -840,7 +850,7 @@ public function testSetFetchModeClassFetchAll() : void /** * @group DBAL-214 */ - public function testSetFetchModeClassFetch() : void + public function testSetFetchModeClassFetch(): void { $this->beforeFetchClassTest(); $this->setupFixture(); @@ -865,7 +875,7 @@ public function testSetFetchModeClassFetch() : void /** * @group DBAL-257 */ - public function testEmptyFetchColumnReturnsFalse() : void + public function testEmptyFetchColumnReturnsFalse(): void { $this->connection->beginTransaction(); $this->connection->exec('DELETE FROM fetch_table'); @@ -877,7 +887,7 @@ public function testEmptyFetchColumnReturnsFalse() : void /** * @group DBAL-339 */ - public function testSetFetchModeOnDbalStatement() : void + public function testSetFetchModeOnDbalStatement(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $stmt = $this->connection->executeQuery($sql, [1, 'foo']); @@ -893,7 +903,7 @@ public function testSetFetchModeOnDbalStatement() : void /** * @group DBAL-435 */ - public function testEmptyParameters() : void + public function testEmptyParameters(): void { $sql = 'SELECT * FROM fetch_table WHERE test_int IN (?)'; $stmt = $this->connection->executeQuery($sql, [[]], [Connection::PARAM_INT_ARRAY]); @@ -905,7 +915,7 @@ public function testEmptyParameters() : void /** * @group DBAL-1028 */ - public function testFetchColumnNullValue() : void + public function testFetchColumnNullValue(): void { $this->connection->executeUpdate( 'INSERT INTO fetch_table (test_int, test_string) VALUES (?, ?)', @@ -920,14 +930,14 @@ public function testFetchColumnNullValue() : void /** * @group DBAL-1028 */ - public function testFetchColumnNoResult() : void + public function testFetchColumnNoResult(): void { self::assertFalse( $this->connection->fetchColumn('SELECT test_int FROM fetch_table WHERE test_int = ?', [-1]) ); } - private function setupFixture() : void + private function setupFixture(): void { $this->connection->exec('DELETE FROM fetch_table'); $this->connection->insert('fetch_table', [ @@ -937,7 +947,7 @@ private function setupFixture() : void ]); } - private function beforeFetchClassTest() : void + private function beforeFetchClassTest(): void { $driver = $this->connection->getDriver(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php index 3adf3c2bb89..61ef8ffc8ee 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php @@ -16,7 +16,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase */ protected $driver; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -26,7 +26,7 @@ protected function setUp() : void /** * @group DBAL-1215 */ - public function testConnectsWithoutDatabaseNameParameter() : void + public function testConnectsWithoutDatabaseNameParameter(): void { $params = $this->connection->getParams(); unset($params['dbname']); @@ -42,7 +42,7 @@ public function testConnectsWithoutDatabaseNameParameter() : void /** * @group DBAL-1215 */ - public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void + public function testReturnsDatabaseNameWithoutDatabaseNameParameter(): void { $params = $this->connection->getParams(); unset($params['dbname']); @@ -60,9 +60,9 @@ public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void ); } - abstract protected function createDriver() : Driver; + abstract protected function createDriver(): Driver; - protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string + protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter(): ?string { return null; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php index 9f66e1a577f..81606b2d58a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php @@ -11,7 +11,7 @@ */ class DB2DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -22,17 +22,17 @@ protected function setUp() : void $this->markTestSkipped('ibm_db2 only test.'); } - public function testConnectsWithoutDatabaseNameParameter() : void + public function testConnectsWithoutDatabaseNameParameter(): void { $this->markTestSkipped('IBM DB2 does not support connecting without database name.'); } - public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void + public function testReturnsDatabaseNameWithoutDatabaseNameParameter(): void { $this->markTestSkipped('IBM DB2 does not support connecting without database name.'); } - protected function createDriver() : Driver + protected function createDriver(): Driver { return new DB2Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php index b17e39b7576..9ffe5d7c06e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php @@ -13,7 +13,7 @@ */ class DB2StatementTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -24,7 +24,7 @@ protected function setUp() : void $this->markTestSkipped('ibm_db2 only test.'); } - public function testExecutionErrorsAreNotSuppressed() : void + public function testExecutionErrorsAreNotSuppressed(): void { $stmt = $this->connection->prepare('SELECT * FROM SYSIBM.SYSDUMMY1 WHERE \'foo\' = ?'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php index 1c30241adda..ecfc7f8e691 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\TestUtil; + use const MYSQLI_OPT_CONNECT_TIMEOUT; /** @@ -14,7 +15,7 @@ */ class ConnectionTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -25,12 +26,12 @@ protected function setUp() : void $this->markTestSkipped('MySQLi only test.'); } - protected function tearDown() : void + protected function tearDown(): void { parent::tearDown(); } - public function testDriverOptions() : void + public function testDriverOptions(): void { $driverOptions = [MYSQLI_OPT_CONNECT_TIMEOUT => 1]; @@ -38,14 +39,14 @@ public function testDriverOptions() : void self::assertInstanceOf(MysqliConnection::class, $connection); } - public function testUnsupportedDriverOption() : void + public function testUnsupportedDriverOption(): void { $this->expectException(MysqliException::class); $this->getConnection(['hello' => 'world']); // use local infile } - public function testPing() : void + public function testPing(): void { $conn = $this->getConnection([]); self::assertTrue($conn->ping()); @@ -54,7 +55,7 @@ public function testPing() : void /** * @param mixed[] $driverOptions */ - private function getConnection(array $driverOptions) : MysqliConnection + private function getConnection(array $driverOptions): MysqliConnection { $params = TestUtil::getConnectionParams(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php index 58b74e3f5a7..ed95bd6047e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php @@ -11,7 +11,7 @@ */ class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -22,7 +22,7 @@ protected function setUp() : void $this->markTestSkipped('MySQLi only test.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php index 28ac0698004..80f0f65e68e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php @@ -11,7 +11,7 @@ */ class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -22,17 +22,17 @@ protected function setUp() : void $this->markTestSkipped('oci8 only test.'); } - public function testConnectsWithoutDatabaseNameParameter() : void + public function testConnectsWithoutDatabaseNameParameter(): void { $this->markTestSkipped('Oracle does not support connecting without database name.'); } - public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void + public function testReturnsDatabaseNameWithoutDatabaseNameParameter(): void { $this->markTestSkipped('Oracle does not support connecting without database name.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php index f5b0cc95e9d..a362689b061 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php @@ -15,7 +15,7 @@ class OCI8ConnectionTest extends DbalFunctionalTestCase /** @var OCI8Connection */ protected $driverConnection; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -29,7 +29,7 @@ protected function setUp() : void /** * @group DBAL-2595 */ - public function testLastInsertIdAcceptsFqn() : void + public function testLastInsertIdAcceptsFqn(): void { $platform = $this->connection->getDatabasePlatform(); $schemaManager = $this->connection->getSchemaManager(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php index 9cf08f942e2..80c6aec27bb 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php @@ -10,7 +10,7 @@ */ class StatementTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -27,7 +27,7 @@ protected function setUp() : void * * @dataProvider queryConversionProvider */ - public function testQueryConversion(string $query, array $params, array $expected) : void + public function testQueryConversion(string $query, array $params, array $expected): void { self::assertEquals( $expected, @@ -43,7 +43,7 @@ public function testQueryConversion(string $query, array $params, array $expecte * * @dataProvider queryConversionProvider */ - public function testStatementBindParameters(string $query, array $params, array $expected) : void + public function testStatementBindParameters(string $query, array $params, array $expected): void { $stmt = $this->connection->prepare($query); $stmt->execute($params); @@ -57,7 +57,7 @@ public function testStatementBindParameters(string $query, array $params, array /** * @return array> */ - public static function queryConversionProvider() : iterable + public static function queryConversionProvider(): iterable { return [ 'positional' => [ diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php index 7d22a091ed7..7c72b9fa9e5 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSRVDriver; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; + use function get_class; use function sprintf; @@ -24,7 +25,7 @@ class PDOConnectionTest extends DbalFunctionalTestCase */ protected $driverConnection; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -37,19 +38,19 @@ protected function setUp() : void $this->markTestSkipped('PDO connection only test.'); } - protected function tearDown() : void + protected function tearDown(): void { $this->resetSharedConn(); parent::tearDown(); } - public function testDoesNotRequireQueryForServerVersion() : void + public function testDoesNotRequireQueryForServerVersion(): void { self::assertFalse($this->driverConnection->requiresQueryForServerVersion()); } - public function testThrowsWrappedExceptionOnConstruct() : void + public function testThrowsWrappedExceptionOnConstruct(): void { $this->expectException(PDOException::class); @@ -59,14 +60,14 @@ public function testThrowsWrappedExceptionOnConstruct() : void /** * @group DBAL-1022 */ - public function testThrowsWrappedExceptionOnExec() : void + public function testThrowsWrappedExceptionOnExec(): void { $this->expectException(PDOException::class); $this->driverConnection->exec('foo'); } - public function testThrowsWrappedExceptionOnPrepare() : void + public function testThrowsWrappedExceptionOnPrepare(): void { $driver = $this->connection->getDriver(); @@ -77,7 +78,8 @@ public function testThrowsWrappedExceptionOnPrepare() : void // Some PDO adapters do not check the query server-side // even though emulated prepared statements are disabled, // so an exception is thrown only eventually. - if ($driver instanceof PDOOracleDriver + if ( + $driver instanceof PDOOracleDriver || $driver instanceof PDOPgSQLDriver ) { self::markTestSkipped(sprintf( @@ -95,7 +97,7 @@ public function testThrowsWrappedExceptionOnPrepare() : void $this->driverConnection->prepare('foo'); } - public function testThrowsWrappedExceptionOnQuery() : void + public function testThrowsWrappedExceptionOnQuery(): void { $this->expectException(PDOException::class); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php index aede96dfa32..597cc0918fe 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php @@ -11,7 +11,7 @@ */ class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -22,7 +22,7 @@ protected function setUp() : void $this->markTestSkipped('pdo_mysql only test.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php index 84588f0a778..546307bb5bc 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php @@ -11,7 +11,7 @@ */ class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -22,17 +22,17 @@ protected function setUp() : void $this->markTestSkipped('PDO_OCI only test.'); } - public function testConnectsWithoutDatabaseNameParameter() : void + public function testConnectsWithoutDatabaseNameParameter(): void { $this->markTestSkipped('Oracle does not support connecting without database name.'); } - public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void + public function testReturnsDatabaseNameWithoutDatabaseNameParameter(): void { $this->markTestSkipped('Oracle does not support connecting without database name.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php index c7131b7b3c6..554be999ff3 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\PDOPgSql\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use Doctrine\Tests\TestUtil; + use function array_key_exists; use function microtime; use function sprintf; @@ -16,7 +17,7 @@ */ class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -30,7 +31,7 @@ protected function setUp() : void /** * @dataProvider getDatabaseParameter */ - public function testDatabaseParameters(?string $databaseName, ?string $defaultDatabaseName, ?string $expectedDatabaseName) : void + public function testDatabaseParameters(?string $databaseName, ?string $defaultDatabaseName, ?string $expectedDatabaseName): void { $params = $this->connection->getParams(); $params['dbname'] = $databaseName; @@ -52,7 +53,7 @@ public function testDatabaseParameters(?string $databaseName, ?string $defaultDa /** * @return mixed[][] */ - public static function getDatabaseParameter() : iterable + public static function getDatabaseParameter(): iterable { $params = TestUtil::getConnectionParams(); $realDatabaseName = $params['dbname'] ?? ''; @@ -70,7 +71,7 @@ public static function getDatabaseParameter() : iterable /** * @group DBAL-1146 */ - public function testConnectsWithApplicationNameParameter() : void + public function testConnectsWithApplicationNameParameter(): void { $parameters = $this->connection->getParams(); $parameters['application_name'] = 'doctrine'; @@ -99,12 +100,12 @@ public function testConnectsWithApplicationNameParameter() : void $this->fail(sprintf('Query result does not contain a record where column "query" equals "%s".', $sql)); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } - protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string + protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter(): ?string { return 'postgres'; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php index f7575c694aa..e5ac053f58d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php @@ -12,7 +12,7 @@ */ class PDOPgsqlConnectionTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -28,7 +28,7 @@ protected function setUp() : void * @group DBAL-1189 * @dataProvider getValidCharsets */ - public function testConnectsWithValidCharsetOption(string $charset) : void + public function testConnectsWithValidCharsetOption(string $charset): void { $params = $this->connection->getParams(); $params['charset'] = $charset; @@ -49,7 +49,7 @@ public function testConnectsWithValidCharsetOption(string $charset) : void /** * @return mixed[][] */ - public static function getValidCharsets() : iterable + public static function getValidCharsets(): iterable { return [ ['UTF8'], diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php index 2548b463a8d..141beb2bfec 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php @@ -11,7 +11,7 @@ */ class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -22,7 +22,7 @@ protected function setUp() : void $this->markTestSkipped('pdo_sqlite only test.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php index de156ec8b5c..c8e9c383e66 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php @@ -14,7 +14,7 @@ */ class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -25,12 +25,12 @@ protected function setUp() : void $this->markTestSkipped('pdo_sqlsrv only test.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } - protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string + protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter(): ?string { return 'master'; } @@ -38,7 +38,7 @@ protected static function getDatabaseNameForConnectionWithoutDatabaseNameParamet /** * @param int[]|string[] $driverOptions */ - private function getConnection(array $driverOptions) : PDOConnection + private function getConnection(array $driverOptions): PDOConnection { $params = TestUtil::getConnectionParams(); @@ -50,7 +50,7 @@ private function getConnection(array $driverOptions) : PDOConnection ); } - public function testConnectionOptions() : void + public function testConnectionOptions(): void { $connection = $this->getConnection(['APP' => 'APP_NAME']); $result = $connection->query('SELECT APP_NAME()')->fetchColumn(); @@ -58,7 +58,7 @@ public function testConnectionOptions() : void self::assertSame('APP_NAME', $result); } - public function testDriverOptions() : void + public function testDriverOptions(): void { $connection = $this->getConnection([PDO::ATTR_CASE => PDO::CASE_UPPER]); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php index bb27cb80b27..915f535961a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php @@ -11,7 +11,7 @@ */ class ConnectionTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -22,7 +22,7 @@ protected function setUp() : void $this->markTestSkipped('sqlanywhere only test.'); } - public function testNonPersistentConnection() : void + public function testNonPersistentConnection(): void { $params = $this->connection->getParams(); $params['persistent'] = false; @@ -34,7 +34,7 @@ public function testNonPersistentConnection() : void self::assertTrue($conn->isConnected(), 'No SQLAnywhere-nonpersistent connection established'); } - public function testPersistentConnection() : void + public function testPersistentConnection(): void { $params = $this->connection->getParams(); $params['persistent'] = true; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php index 1f239286891..e7c1c9870b6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php @@ -12,7 +12,7 @@ */ class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -23,7 +23,7 @@ protected function setUp() : void $this->markTestSkipped('sqlanywhere only test.'); } - public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void + public function testReturnsDatabaseNameWithoutDatabaseNameParameter(): void { $params = $this->connection->getParams(); unset($params['dbname']); @@ -40,7 +40,7 @@ public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void self::assertIsString($this->driver->getDatabase($connection)); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php index aa718d6149a..3d43b9a6c09 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php @@ -11,7 +11,7 @@ */ class StatementTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -22,7 +22,7 @@ protected function setUp() : void $this->markTestSkipped('sqlanywhere only test.'); } - public function testNonPersistentStatement() : void + public function testNonPersistentStatement(): void { $params = $this->connection->getParams(); $params['persistent'] = false; @@ -37,7 +37,7 @@ public function testNonPersistentStatement() : void self::assertTrue($prepStmt->execute(), ' Statement non-persistent failed'); } - public function testPersistentStatement() : void + public function testPersistentStatement(): void { $params = $this->connection->getParams(); $params['persistent'] = true; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php index 2dcc90f034c..8cd5af998bd 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php @@ -11,7 +11,7 @@ */ class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -22,12 +22,12 @@ protected function setUp() : void $this->markTestSkipped('sqlsrv only test.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } - protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string + protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter(): ?string { return 'master'; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php index b6a7864e6f1..3b7de6c8b49 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php @@ -11,7 +11,7 @@ */ class StatementTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -22,7 +22,7 @@ protected function setUp() : void self::markTestSkipped('sqlsrv only test'); } - public function testFailureToPrepareResultsInException() : void + public function testFailureToPrepareResultsInException(): void { // use the driver connection directly to avoid having exception wrapped $stmt = $this->connection->getWrappedConnection()->prepare(''); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php index 46950e7db80..70ce747fca1 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; + use function array_merge; use function assert; use function chmod; @@ -26,11 +27,12 @@ use function touch; use function unlink; use function version_compare; + use const PHP_OS; class ExceptionTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -41,7 +43,7 @@ protected function setUp() : void $this->markTestSkipped('Driver does not support special exception handling.'); } - public function testPrimaryConstraintViolationException() : void + public function testPrimaryConstraintViolationException(): void { $table = new Table('duplicatekey_table'); $table->addColumn('id', 'integer', []); @@ -55,7 +57,7 @@ public function testPrimaryConstraintViolationException() : void $this->connection->insert('duplicatekey_table', ['id' => 1]); } - public function testTableNotFoundException() : void + public function testTableNotFoundException(): void { $sql = 'SELECT * FROM unknown_table'; @@ -63,7 +65,7 @@ public function testTableNotFoundException() : void $this->connection->executeQuery($sql); } - public function testTableExistsException() : void + public function testTableExistsException(): void { $schemaManager = $this->connection->getSchemaManager(); $table = new Table('alreadyexist_table'); @@ -75,7 +77,7 @@ public function testTableExistsException() : void $schemaManager->createTable($table); } - public function testForeignKeyConstraintViolationExceptionOnInsert() : void + public function testForeignKeyConstraintViolationExceptionOnInsert(): void { if ($this->connection->getDatabasePlatform()->getName() === 'sqlite') { $this->connection->exec('PRAGMA foreign_keys=ON'); @@ -109,7 +111,7 @@ public function testForeignKeyConstraintViolationExceptionOnInsert() : void $this->tearDownForeignKeyConstraintViolationExceptionTest(); } - public function testForeignKeyConstraintViolationExceptionOnUpdate() : void + public function testForeignKeyConstraintViolationExceptionOnUpdate(): void { if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Only fails on platforms with foreign key constraints.'); @@ -143,7 +145,7 @@ public function testForeignKeyConstraintViolationExceptionOnUpdate() : void $this->tearDownForeignKeyConstraintViolationExceptionTest(); } - public function testForeignKeyConstraintViolationExceptionOnDelete() : void + public function testForeignKeyConstraintViolationExceptionOnDelete(): void { if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Only fails on platforms with foreign key constraints.'); @@ -177,7 +179,7 @@ public function testForeignKeyConstraintViolationExceptionOnDelete() : void $this->tearDownForeignKeyConstraintViolationExceptionTest(); } - public function testForeignKeyConstraintViolationExceptionOnTruncate() : void + public function testForeignKeyConstraintViolationExceptionOnTruncate(): void { $platform = $this->connection->getDatabasePlatform(); @@ -213,7 +215,7 @@ public function testForeignKeyConstraintViolationExceptionOnTruncate() : void $this->tearDownForeignKeyConstraintViolationExceptionTest(); } - public function testNotNullConstraintViolationException() : void + public function testNotNullConstraintViolationException(): void { $schema = new Schema(); @@ -230,7 +232,7 @@ public function testNotNullConstraintViolationException() : void $this->connection->insert('notnull_table', ['id' => 1, 'value' => null]); } - public function testInvalidFieldNameException() : void + public function testInvalidFieldNameException(): void { $schema = new Schema(); @@ -245,7 +247,7 @@ public function testInvalidFieldNameException() : void $this->connection->insert('bad_fieldname_table', ['name' => 5]); } - public function testNonUniqueFieldNameException() : void + public function testNonUniqueFieldNameException(): void { $schema = new Schema(); @@ -264,7 +266,7 @@ public function testNonUniqueFieldNameException() : void $this->connection->executeQuery($sql); } - public function testUniqueConstraintViolationException() : void + public function testUniqueConstraintViolationException(): void { $schema = new Schema(); @@ -281,7 +283,7 @@ public function testUniqueConstraintViolationException() : void $this->connection->insert('unique_field_table', ['id' => 5]); } - public function testSyntaxErrorException() : void + public function testSyntaxErrorException(): void { $table = new Table('syntax_error_table'); $table->addColumn('id', 'integer', []); @@ -294,7 +296,7 @@ public function testSyntaxErrorException() : void $this->connection->executeQuery($sql); } - public function testConnectionExceptionSqLite() : void + public function testConnectionExceptionSqLite(): void { if (! ($this->connection->getDatabasePlatform() instanceof SqlitePlatform)) { $this->markTestSkipped('Only fails this way on sqlite'); @@ -349,7 +351,7 @@ public function testConnectionExceptionSqLite() : void * * @dataProvider getConnectionParams */ - public function testConnectionException(array $params) : void + public function testConnectionException(array $params): void { $platform = $this->connection->getDatabasePlatform(); @@ -393,7 +395,7 @@ public function testConnectionException(array $params) : void /** * @return array> */ - public static function getConnectionParams() : iterable + public static function getConnectionParams(): iterable { return [ [['user' => 'not_existing']], @@ -402,7 +404,7 @@ public static function getConnectionParams() : iterable ]; } - private function setUpForeignKeyConstraintViolationExceptionTest() : void + private function setUpForeignKeyConstraintViolationExceptionTest(): void { $schemaManager = $this->connection->getSchemaManager(); @@ -420,7 +422,7 @@ private function setUpForeignKeyConstraintViolationExceptionTest() : void $schemaManager->createTable($owningTable); } - private function tearDownForeignKeyConstraintViolationExceptionTest() : void + private function tearDownForeignKeyConstraintViolationExceptionTest(): void { $schemaManager = $this->connection->getSchemaManager(); @@ -428,12 +430,12 @@ private function tearDownForeignKeyConstraintViolationExceptionTest() : void $schemaManager->dropTable('constraint_error_table'); } - private function isLinuxRoot() : bool + private function isLinuxRoot(): bool { return PHP_OS === 'Linux' && posix_getpwuid(posix_geteuid())['name'] === 'root'; } - private function cleanupReadOnlyFile(string $filename) : void + private function cleanupReadOnlyFile(string $filename): void { if ($this->isLinuxRoot()) { exec(sprintf('chattr -i %s', $filename)); diff --git a/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php b/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php index e172816f2af..f6852c3dc34 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php @@ -3,11 +3,12 @@ namespace Doctrine\Tests\DBAL\Functional; use Doctrine\Tests\DbalFunctionalTestCase; + use function sprintf; final class LikeWildcardsEscapingTest extends DbalFunctionalTestCase { - public function testFetchLikeExpressionResult() : void + public function testFetchLikeExpressionResult(): void { $string = '_25% off_ your next purchase \o/ [$̲̅(̲̅5̲̅)̲̅$̲̅] (^̮^)'; $escapeChar = '!'; diff --git a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php index 8315c18c37a..ac7d84d030e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php @@ -8,11 +8,13 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; + use function array_change_key_case; use function sprintf; use function strlen; use function strtolower; use function substr; + use const CASE_LOWER; /** @@ -20,7 +22,7 @@ */ class MasterSlaveConnectionTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -45,7 +47,7 @@ protected function setUp() : void $this->connection->insert('master_slave_table', ['test_int' => 1]); } - private function createMasterSlaveConnection(bool $keepSlave = false) : MasterSlaveConnection + private function createMasterSlaveConnection(bool $keepSlave = false): MasterSlaveConnection { return DriverManager::getConnection($this->createMasterSlaveConnectionParams($keepSlave)); } @@ -53,7 +55,7 @@ private function createMasterSlaveConnection(bool $keepSlave = false) : MasterSl /** * @return mixed[] */ - private function createMasterSlaveConnectionParams(bool $keepSlave = false) : array + private function createMasterSlaveConnectionParams(bool $keepSlave = false): array { $params = $this->connection->getParams(); $params['master'] = $params; @@ -64,7 +66,7 @@ private function createMasterSlaveConnectionParams(bool $keepSlave = false) : ar return $params; } - public function testInheritCharsetFromMaster() : void + public function testInheritCharsetFromMaster(): void { $charsets = [ 'utf8', @@ -98,7 +100,7 @@ public function testInheritCharsetFromMaster() : void } } - public function testMasterOnConnect() : void + public function testMasterOnConnect(): void { $conn = $this->createMasterSlaveConnection(); @@ -109,7 +111,7 @@ public function testMasterOnConnect() : void self::assertTrue($conn->isConnectedToMaster()); } - public function testNoMasterOnExecuteQuery() : void + public function testNoMasterOnExecuteQuery(): void { $conn = $this->createMasterSlaveConnection(); @@ -121,7 +123,7 @@ public function testNoMasterOnExecuteQuery() : void self::assertFalse($conn->isConnectedToMaster()); } - public function testMasterOnWriteOperation() : void + public function testMasterOnWriteOperation(): void { $conn = $this->createMasterSlaveConnection(); $conn->insert('master_slave_table', ['test_int' => 30]); @@ -139,7 +141,7 @@ public function testMasterOnWriteOperation() : void /** * @group DBAL-335 */ - public function testKeepSlaveBeginTransactionStaysOnMaster() : void + public function testKeepSlaveBeginTransactionStaysOnMaster(): void { $conn = $this->createMasterSlaveConnection($keepSlave = true); $conn->connect('slave'); @@ -160,7 +162,7 @@ public function testKeepSlaveBeginTransactionStaysOnMaster() : void /** * @group DBAL-335 */ - public function testKeepSlaveInsertStaysOnMaster() : void + public function testKeepSlaveInsertStaysOnMaster(): void { $conn = $this->createMasterSlaveConnection($keepSlave = true); $conn->connect('slave'); @@ -176,7 +178,7 @@ public function testKeepSlaveInsertStaysOnMaster() : void self::assertFalse($conn->isConnectedToMaster()); } - public function testMasterSlaveConnectionCloseAndReconnect() : void + public function testMasterSlaveConnectionCloseAndReconnect(): void { $conn = $this->createMasterSlaveConnection(); $conn->connect('master'); @@ -189,7 +191,7 @@ public function testMasterSlaveConnectionCloseAndReconnect() : void self::assertTrue($conn->isConnectedToMaster()); } - public function testQueryOnMaster() : void + public function testQueryOnMaster(): void { $conn = $this->createMasterSlaveConnection(); @@ -213,7 +215,7 @@ public function testQueryOnMaster() : void self::assertEquals(1, $data[0]['num']); } - public function testQueryOnSlave() : void + public function testQueryOnSlave(): void { $conn = $this->createMasterSlaveConnection(); $conn->connect('slave'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php b/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php index 73d258b31d9..3ab1efb1b6b 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php @@ -4,8 +4,10 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; + use function array_change_key_case; use function count; + use const CASE_LOWER; class ModifyLimitQueryTest extends DbalFunctionalTestCase @@ -13,7 +15,7 @@ class ModifyLimitQueryTest extends DbalFunctionalTestCase /** @var bool */ private static $tableCreated = false; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -37,7 +39,7 @@ protected function setUp() : void $this->connection->exec($this->connection->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table2')); } - public function testModifyLimitQuerySimpleQuery() : void + public function testModifyLimitQuerySimpleQuery(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -52,7 +54,7 @@ public function testModifyLimitQuerySimpleQuery() : void $this->assertLimitResult([2, 3, 4], $sql, null, 1); } - public function testModifyLimitQueryJoinQuery() : void + public function testModifyLimitQueryJoinQuery(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -70,7 +72,7 @@ public function testModifyLimitQueryJoinQuery() : void $this->assertLimitResult([2, 2], $sql, 2, 0); } - public function testModifyLimitQueryNonDeterministic() : void + public function testModifyLimitQueryNonDeterministic(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -84,7 +86,7 @@ public function testModifyLimitQueryNonDeterministic() : void $this->assertLimitResult([2, 1], $sql, 2, 2, false); } - public function testModifyLimitQueryGroupBy() : void + public function testModifyLimitQueryGroupBy(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -104,7 +106,7 @@ public function testModifyLimitQueryGroupBy() : void $this->assertLimitResult([2], $sql, 1, 1); } - public function testModifyLimitQuerySubSelect() : void + public function testModifyLimitQuerySubSelect(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -118,7 +120,7 @@ public function testModifyLimitQuerySubSelect() : void $this->assertLimitResult([2, 1], $sql, 2, 2); } - public function testModifyLimitQueryFromSubSelect() : void + public function testModifyLimitQueryFromSubSelect(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -132,7 +134,7 @@ public function testModifyLimitQueryFromSubSelect() : void $this->assertLimitResult([2, 1], $sql, 2, 2); } - public function testModifyLimitQueryLineBreaks() : void + public function testModifyLimitQueryLineBreaks(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -152,7 +154,7 @@ public function testModifyLimitQueryLineBreaks() : void $this->assertLimitResult([2], $sql, 1, 1); } - public function testModifyLimitQueryZeroOffsetNoLimit() : void + public function testModifyLimitQueryZeroOffsetNoLimit(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -165,7 +167,7 @@ public function testModifyLimitQueryZeroOffsetNoLimit() : void /** * @param array $expectedResults */ - private function assertLimitResult(array $expectedResults, string $sql, ?int $limit, int $offset, bool $deterministic = true) : void + private function assertLimitResult(array $expectedResults, string $sql, ?int $limit, int $offset, bool $deterministic = true): void { $p = $this->connection->getDatabasePlatform(); $data = []; diff --git a/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php b/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php index 8946db53308..59404a2a2a6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php @@ -8,7 +8,9 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; + use function array_change_key_case; + use const CASE_LOWER; /** @@ -19,7 +21,7 @@ class NamedParametersTest extends DbalFunctionalTestCase /** * @return iterable> */ - public static function ticketProvider() : iterable + public static function ticketProvider(): iterable { return [ [ @@ -150,7 +152,7 @@ public static function ticketProvider() : iterable ]; } - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -210,7 +212,7 @@ protected function setUp() : void * * @dataProvider ticketProvider */ - public function testTicket(string $query, array $params, array $types, array $expected) : void + public function testTicket(string $query, array $params, array $types, array $expected): void { $stmt = $this->connection->executeQuery($query, $params, $types); $result = $stmt->fetchAll(FetchMode::ASSOCIATIVE); diff --git a/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php index 51f1da91157..ee215d7ae6e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php @@ -12,7 +12,7 @@ */ class PDOStatementTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -30,7 +30,7 @@ protected function setUp() : void * @group legacy * @expectedDeprecation Using a PDO fetch mode or their combination (%d given) is deprecated and will cause an error in Doctrine DBAL 3.0 */ - public function testPDOSpecificModeIsAccepted() : void + public function testPDOSpecificModeIsAccepted(): void { $this->connection->insert('stmt_test', [ 'id' => 1, diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/DateExpressionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/DateExpressionTest.php index 5c1789e192d..36f2a071f90 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Platform/DateExpressionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/DateExpressionTest.php @@ -5,6 +5,7 @@ use DateTimeImmutable; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; + use function sprintf; class DateExpressionTest extends DbalFunctionalTestCase @@ -12,7 +13,7 @@ class DateExpressionTest extends DbalFunctionalTestCase /** * @dataProvider differenceProvider */ - public function testDifference(string $date1, string $date2, int $expected) : void + public function testDifference(string $date1, string $date2, int $expected): void { $table = new Table('date_expr_test'); $table->addColumn('date1', 'datetime'); @@ -34,7 +35,7 @@ public function testDifference(string $date1, string $date2, int $expected) : vo /** * @return string[][]|int[][] */ - public static function differenceProvider() : iterable + public static function differenceProvider(): iterable { $date1 = new DateTimeImmutable(); $date2 = new DateTimeImmutable('2018-04-10 10:10:10'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/DefaultExpressionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/DefaultExpressionTest.php index 5365693af43..38fa03fb7b9 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Platform/DefaultExpressionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/DefaultExpressionTest.php @@ -11,11 +11,12 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Types; use Doctrine\Tests\DbalFunctionalTestCase; + use function sprintf; class DefaultExpressionTest extends DbalFunctionalTestCase { - public function testCurrentDate() : void + public function testCurrentDate(): void { $platform = $this->connection->getDatabasePlatform(); @@ -23,12 +24,12 @@ public function testCurrentDate() : void self::markTestSkipped('Not supported on MySQL'); } - $this->assertDefaultExpression(Types::DATE_MUTABLE, static function (AbstractPlatform $platform) : string { + $this->assertDefaultExpression(Types::DATE_MUTABLE, static function (AbstractPlatform $platform): string { return $platform->getCurrentDateSQL(); }); } - public function testCurrentTime() : void + public function testCurrentTime(): void { $platform = $this->connection->getDatabasePlatform(); @@ -40,19 +41,19 @@ public function testCurrentTime() : void self::markTestSkipped('Not supported on Oracle'); } - $this->assertDefaultExpression(Types::TIME_MUTABLE, static function (AbstractPlatform $platform) : string { + $this->assertDefaultExpression(Types::TIME_MUTABLE, static function (AbstractPlatform $platform): string { return $platform->getCurrentTimeSQL(); }); } - public function testCurrentTimestamp() : void + public function testCurrentTimestamp(): void { - $this->assertDefaultExpression(Types::DATETIME_MUTABLE, static function (AbstractPlatform $platform) : string { + $this->assertDefaultExpression(Types::DATETIME_MUTABLE, static function (AbstractPlatform $platform): string { return $platform->getCurrentTimestampSQL(); }); } - private function assertDefaultExpression(string $type, callable $expression) : void + private function assertDefaultExpression(string $type, callable $expression): void { $platform = $this->connection->getDatabasePlatform(); $defaultSql = $expression($platform, $this); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php index faac5f4a6b2..b55751bde63 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php @@ -5,11 +5,12 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Comparator; use Doctrine\Tests\DbalFunctionalTestCase; + use function in_array; final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -28,7 +29,7 @@ protected function setUp() : void * SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto * column and it must be defined as a key */ - public function testAlterPrimaryKeyToAutoIncrementColumn() : void + public function testAlterPrimaryKeyToAutoIncrementColumn(): void { $schemaManager = $this->connection->getSchemaManager(); $schema = $schemaManager->createSchema(); @@ -60,7 +61,7 @@ public function testAlterPrimaryKeyToAutoIncrementColumn() : void $this->assertSame(['new_id'], $validationTable->getPrimaryKeyColumns()); } - private function getPlatform() : AbstractPlatform + private function getPlatform(): AbstractPlatform { return $this->connection->getDatabasePlatform(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/PlatformRestrictionsTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/PlatformRestrictionsTest.php index 5f6deefe3ba..2c3d7d29dcb 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Platform/PlatformRestrictionsTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/PlatformRestrictionsTest.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; + use function str_repeat; /** @@ -16,7 +17,7 @@ class PlatformRestrictionsTest extends DbalFunctionalTestCase * Tests element names that are at the boundary of the identifier length limit. * Ensures generated auto-increment identifier name respects to platform restrictions. */ - public function testMaxIdentifierLengthLimitWithAutoIncrement() : void + public function testMaxIdentifierLengthLimitWithAutoIncrement(): void { $platform = $this->connection->getDatabasePlatform(); $tableName = str_repeat('x', $platform->getMaxIdentifierLength()); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/QuotingTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/QuotingTest.php index 3a1ae7c8440..fee5b33f0c6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Platform/QuotingTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/QuotingTest.php @@ -9,7 +9,7 @@ class QuotingTest extends DbalFunctionalTestCase /** * @dataProvider stringLiteralProvider */ - public function testQuoteStringLiteral(string $string) : void + public function testQuoteStringLiteral(string $string): void { $platform = $this->connection->getDatabasePlatform(); $query = $platform->getDummySelectSQL( @@ -22,7 +22,7 @@ public function testQuoteStringLiteral(string $string) : void /** * @return mixed[][] */ - public static function stringLiteralProvider() : iterable + public static function stringLiteralProvider(): iterable { return [ 'backslash' => ['\\'], diff --git a/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php b/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php index 72fb9dd2213..981120a8d24 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; + use function strlen; /** @@ -20,7 +21,7 @@ class PortabilityTest extends DbalFunctionalTestCase /** @var Connection */ private $portableConnection; - protected function tearDown() : void + protected function tearDown(): void { if ($this->portableConnection) { $this->portableConnection->close(); @@ -32,7 +33,7 @@ protected function tearDown() : void private function getPortableConnection( int $portabilityMode = ConnectionPortability::PORTABILITY_ALL, int $case = ColumnCase::LOWER - ) : Connection { + ): Connection { if (! $this->portableConnection) { $params = $this->connection->getParams(); @@ -61,7 +62,7 @@ private function getPortableConnection( return $this->portableConnection; } - public function testFullFetchMode() : void + public function testFullFetchMode(): void { $rows = $this->getPortableConnection()->fetchAll('SELECT * FROM portability_table'); $this->assertFetchResultRows($rows); @@ -87,7 +88,7 @@ public function testFullFetchMode() : void } } - public function testConnFetchMode() : void + public function testConnFetchMode(): void { $conn = $this->getPortableConnection(); $conn->setFetchMode(FetchMode::ASSOCIATIVE); @@ -115,7 +116,7 @@ public function testConnFetchMode() : void /** * @param array> $rows */ - private function assertFetchResultRows(array $rows) : void + private function assertFetchResultRows(array $rows): void { self::assertCount(2, $rows); foreach ($rows as $row) { @@ -126,7 +127,7 @@ private function assertFetchResultRows(array $rows) : void /** * @param array $row */ - public function assertFetchResultRow(array $row) : void + public function assertFetchResultRow(array $row): void { self::assertContains($row['test_int'], [1, 2], 'Primary key test_int should either be 1 or 2.'); self::assertArrayHasKey('test_string', $row, 'Case should be lowered.'); @@ -140,7 +141,7 @@ public function assertFetchResultRow(array $row) : void * * @dataProvider fetchAllColumnProvider */ - public function testFetchAllColumn(string $field, array $expected) : void + public function testFetchAllColumn(string $field, array $expected): void { $conn = $this->getPortableConnection(); $stmt = $conn->query('SELECT ' . $field . ' FROM portability_table'); @@ -152,7 +153,7 @@ public function testFetchAllColumn(string $field, array $expected) : void /** * @return iterable> */ - public static function fetchAllColumnProvider() : iterable + public static function fetchAllColumnProvider(): iterable { return [ 'int' => [ @@ -166,7 +167,7 @@ public static function fetchAllColumnProvider() : iterable ]; } - public function testFetchAllNullColumn() : void + public function testFetchAllNullColumn(): void { $conn = $this->getPortableConnection(); $stmt = $conn->query('SELECT Test_Null FROM portability_table'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php index 05548da1dbd..1e06f8c5f44 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php @@ -9,11 +9,13 @@ use Doctrine\DBAL\Logging\DebugStack; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; + use function array_change_key_case; use function array_merge; use function array_shift; use function array_values; use function is_array; + use const CASE_LOWER; /** @@ -27,7 +29,7 @@ class ResultCacheTest extends DbalFunctionalTestCase /** @var DebugStack */ private $sqlLogger; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -50,14 +52,14 @@ protected function setUp() : void $config->setResultCacheImpl($cache); } - protected function tearDown() : void + protected function tearDown(): void { $this->connection->getSchemaManager()->dropTable('caching'); parent::tearDown(); } - public function testCacheFetchAssoc() : void + public function testCacheFetchAssoc(): void { $this->assertCacheNonCacheSelectSameFetchModeAreEqual( $this->expectedResult, @@ -65,7 +67,7 @@ public function testCacheFetchAssoc() : void ); } - public function testFetchNum() : void + public function testFetchNum(): void { $expectedResult = []; foreach ($this->expectedResult as $v) { @@ -75,7 +77,7 @@ public function testFetchNum() : void $this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, FetchMode::NUMERIC); } - public function testFetchBoth() : void + public function testFetchBoth(): void { $expectedResult = []; foreach ($this->expectedResult as $v) { @@ -85,7 +87,7 @@ public function testFetchBoth() : void $this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, FetchMode::MIXED); } - public function testFetchColumn() : void + public function testFetchColumn(): void { $expectedResult = []; foreach ($this->expectedResult as $v) { @@ -95,7 +97,7 @@ public function testFetchColumn() : void $this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, FetchMode::COLUMN); } - public function testMixingFetch() : void + public function testMixingFetch(): void { $numExpectedResult = []; foreach ($this->expectedResult as $v) { @@ -115,14 +117,14 @@ public function testMixingFetch() : void self::assertEquals($numExpectedResult, $data); } - public function testIteratorFetch() : void + public function testIteratorFetch(): void { self::assertStandardAndIteratorFetchAreEqual(FetchMode::MIXED); self::assertStandardAndIteratorFetchAreEqual(FetchMode::ASSOCIATIVE); self::assertStandardAndIteratorFetchAreEqual(FetchMode::NUMERIC); } - private function assertStandardAndIteratorFetchAreEqual(int $fetchMode) : void + private function assertStandardAndIteratorFetchAreEqual(int $fetchMode): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); $data = $this->hydrateStmt($stmt, $fetchMode); @@ -133,7 +135,7 @@ private function assertStandardAndIteratorFetchAreEqual(int $fetchMode) : void self::assertEquals($data, $dataIterator); } - public function testDontCloseNoCache() : void + public function testDontCloseNoCache(): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); @@ -154,7 +156,7 @@ public function testDontCloseNoCache() : void self::assertCount(2, $this->sqlLogger->queries); } - public function testDontFinishNoCache() : void + public function testDontFinishNoCache(): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); @@ -168,7 +170,7 @@ public function testDontFinishNoCache() : void self::assertCount(2, $this->sqlLogger->queries); } - public function testFetchAllAndFinishSavesCache() : void + public function testFetchAllAndFinishSavesCache(): void { $layerCache = new ArrayCache(); $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'testcachekey', $layerCache)); @@ -178,7 +180,7 @@ public function testFetchAllAndFinishSavesCache() : void self::assertCount(1, $layerCache->fetch('testcachekey')); } - public function testFetchAllColumn() : void + public function testFetchAllColumn(): void { $query = $this->connection->getDatabasePlatform() ->getDummySelectSQL('1'); @@ -197,7 +199,7 @@ public function testFetchAllColumn() : void /** * @param array>|list $expectedResult */ - private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedResult, int $fetchMode) : void + private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedResult, int $fetchMode): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); @@ -213,7 +215,7 @@ private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedR self::assertCount(1, $this->sqlLogger->queries, 'just one dbal hit'); } - public function testEmptyResultCache() : void + public function testEmptyResultCache(): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey')); $data = $this->hydrateStmt($stmt); @@ -224,7 +226,7 @@ public function testEmptyResultCache() : void self::assertCount(1, $this->sqlLogger->queries, 'just one dbal hit'); } - public function testChangeCacheImpl() : void + public function testChangeCacheImpl(): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey')); $data = $this->hydrateStmt($stmt); @@ -240,7 +242,7 @@ public function testChangeCacheImpl() : void /** * @return array */ - private function hydrateStmt(ResultStatement $stmt, int $fetchMode = FetchMode::ASSOCIATIVE) : array + private function hydrateStmt(ResultStatement $stmt, int $fetchMode = FetchMode::ASSOCIATIVE): array { $data = []; while ($row = $stmt->fetch($fetchMode)) { @@ -255,7 +257,7 @@ private function hydrateStmt(ResultStatement $stmt, int $fetchMode = FetchMode:: /** * @return array */ - private function hydrateStmtIterator(ResultStatement $stmt, int $fetchMode = FetchMode::ASSOCIATIVE) : array + private function hydrateStmtIterator(ResultStatement $stmt, int $fetchMode = FetchMode::ASSOCIATIVE): array { $data = []; $stmt->setFetchMode($fetchMode); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php index 13503e3187b..e909995fcae 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php @@ -17,7 +17,7 @@ class ComparatorTest extends DbalFunctionalTestCase /** @var Comparator */ private $comparator; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -30,7 +30,7 @@ protected function setUp() : void * * @dataProvider defaultValueProvider */ - public function testDefaultValueComparison(string $type, $value) : void + public function testDefaultValueComparison(string $type, $value): void { $table = new Table('default_value'); $table->addColumn('test', $type, ['default' => $value]); @@ -45,7 +45,7 @@ public function testDefaultValueComparison(string $type, $value) : void /** * @return mixed[][] */ - public static function defaultValueProvider() : iterable + public static function defaultValueProvider(): iterable { return [ ['integer', 1], diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php index 330198e9ca9..b8814b15680 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php @@ -10,7 +10,7 @@ class Db2SchemaManagerTest extends SchemaManagerFunctionalTestCase /** * @group DBAL-939 */ - public function testGetBooleanColumn() : void + public function testGetBooleanColumn(): void { $table = new Table('boolean_column_test'); $table->addColumn('bool', 'boolean'); @@ -27,7 +27,7 @@ public function testGetBooleanColumn() : void self::assertSame("That's a comment", $columns['bool_commented']->getComment()); } - public function testListTableWithBinary() : void + public function testListTableWithBinary(): void { self::markTestSkipped('Binary data type is currently not supported on DB2 LUW'); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/DefaultValueTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/DefaultValueTest.php index 3dd362e2263..ec408583f7b 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/DefaultValueTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/DefaultValueTest.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; + use function sprintf; class DefaultValueTest extends DbalFunctionalTestCase @@ -13,7 +14,7 @@ class DefaultValueTest extends DbalFunctionalTestCase /** @var bool */ private static $initialized = false; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -44,7 +45,7 @@ protected function setUp() : void * * @dataProvider columnProvider */ - public function testEscapedDefaultValueCanBeIntrospected(string $name, ?string $expectedDefault) : void + public function testEscapedDefaultValueCanBeIntrospected(string $name, ?string $expectedDefault): void { self::assertSame( $expectedDefault, @@ -61,7 +62,7 @@ public function testEscapedDefaultValueCanBeIntrospected(string $name, ?string $ * * @dataProvider columnProvider */ - public function testEscapedDefaultValueCanBeInserted(string $name, ?string $expectedDefault) : void + public function testEscapedDefaultValueCanBeInserted(string $name, ?string $expectedDefault): void { $value = $this->connection->fetchColumn( sprintf('SELECT %s FROM default_value', $name) @@ -79,7 +80,7 @@ public function testEscapedDefaultValueCanBeInserted(string $name, ?string $expe * * @return mixed[][] */ - public static function columnProvider() : iterable + public static function columnProvider(): iterable { return [ 'Single quote' => [ diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php index b1a47bc417c..0943124b86b 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php @@ -7,7 +7,7 @@ class DrizzleSchemaManagerTest extends SchemaManagerFunctionalTestCase { - public function testListTableWithBinary() : void + public function testListTableWithBinary(): void { $tableName = 'test_binary_table'; @@ -28,7 +28,7 @@ public function testListTableWithBinary() : void self::assertFalse($table->getColumn('column_binary')->getFixed()); } - public function testColumnCollation() : void + public function testColumnCollation(): void { $table = new Table('test_collation'); $table->addOption('collate', $collation = 'utf8_unicode_ci'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/ForeignKeyTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/ForeignKeyTest.php index 7f86d8fc254..c0c82286e36 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/ForeignKeyTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/ForeignKeyTest.php @@ -9,7 +9,7 @@ class ForeignKeyTest extends DbalFunctionalTestCase { - public function testCreatingATableWithAForeignKey() : void + public function testCreatingATableWithAForeignKey(): void { $schema = new Schema(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php index 1e3d620c02a..ce175add9de 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php @@ -15,7 +15,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -28,7 +28,7 @@ protected function setUp() : void Type::addType('point', MySqlPointType::class); } - public function testSwitchPrimaryKeyColumns() : void + public function testSwitchPrimaryKeyColumns(): void { $tableOld = new Table('switch_primary_key_columns'); $tableOld->addColumn('foo_id', 'integer'); @@ -50,7 +50,7 @@ public function testSwitchPrimaryKeyColumns() : void self::assertContains('foo_id', $primaryKey); } - public function testDiffTableBug() : void + public function testDiffTableBug(): void { $schema = new Schema(); $table = $schema->createTable('diffbug_routing_translations'); @@ -73,7 +73,7 @@ public function testDiffTableBug() : void self::assertFalse($diff, 'no changes expected.'); } - public function testFulltextIndex() : void + public function testFulltextIndex(): void { $table = new Table('fulltext_index'); $table->addColumn('text', 'text'); @@ -90,7 +90,7 @@ public function testFulltextIndex() : void self::assertTrue($indexes['f_index']->hasFlag('fulltext')); } - public function testSpatialIndex() : void + public function testSpatialIndex(): void { $table = new Table('spatial_index'); $table->addColumn('point', 'point'); @@ -107,7 +107,7 @@ public function testSpatialIndex() : void self::assertTrue($indexes['s_index']->hasFlag('spatial')); } - public function testIndexWithLength() : void + public function testIndexWithLength(): void { $table = new Table('index_length'); $table->addColumn('text', 'string', ['length' => 255]); @@ -123,7 +123,7 @@ public function testIndexWithLength() : void /** * @group DBAL-400 */ - public function testAlterTableAddPrimaryKey() : void + public function testAlterTableAddPrimaryKey(): void { $table = new Table('alter_table_add_pk'); $table->addColumn('id', 'integer'); @@ -149,7 +149,7 @@ public function testAlterTableAddPrimaryKey() : void /** * @group DBAL-464 */ - public function testDropPrimaryKeyWithAutoincrementColumn() : void + public function testDropPrimaryKeyWithAutoincrementColumn(): void { $table = new Table('drop_primary_key'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -175,7 +175,7 @@ public function testDropPrimaryKeyWithAutoincrementColumn() : void /** * @group DBAL-789 */ - public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : void + public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes(): void { if ($this->schemaManager->getDatabasePlatform() instanceof MariaDb1027Platform) { $this->markTestSkipped( @@ -214,7 +214,7 @@ public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : v self::assertFalse($onlineTable->getColumn('def_blob_null')->getNotnull()); } - public function testColumnCharset() : void + public function testColumnCharset(): void { $table = new Table('test_column_charset'); $table->addColumn('id', 'integer'); @@ -231,7 +231,7 @@ public function testColumnCharset() : void self::assertEquals('latin1', $columns['bar']->getPlatformOption('charset')); } - public function testAlterColumnCharset() : void + public function testAlterColumnCharset(): void { $tableName = 'test_alter_column_charset'; @@ -252,7 +252,7 @@ public function testAlterColumnCharset() : void self::assertEquals('ascii', $table->getColumn('col_text')->getPlatformOption('charset')); } - public function testColumnCharsetChange() : void + public function testColumnCharsetChange(): void { $table = new Table('test_column_charset_change'); $table->addColumn('col_string', 'string')->setLength(100)->setNotnull(true)->setPlatformOption('charset', 'utf8'); @@ -267,7 +267,7 @@ public function testColumnCharsetChange() : void self::assertContains('ALTER TABLE test_column_charset_change CHANGE col_string col_string VARCHAR(100) CHARACTER SET ascii NOT NULL', $diff); } - public function testColumnCollation() : void + public function testColumnCollation(): void { $table = new Table('test_collation'); $table->addOption('collate', $collation = 'latin1_swedish_ci'); @@ -291,7 +291,7 @@ public function testColumnCollation() : void /** * @group DBAL-843 */ - public function testListLobTypeColumns() : void + public function testListLobTypeColumns(): void { $tableName = 'lob_type_columns'; $table = new Table($tableName); @@ -350,7 +350,7 @@ public function testListLobTypeColumns() : void /** * @group DBAL-423 */ - public function testDiffListGuidTableColumn() : void + public function testDiffListGuidTableColumn(): void { $offlineTable = new Table('list_guid_table_column'); $offlineTable->addColumn('col_guid', 'guid'); @@ -370,7 +370,7 @@ public function testDiffListGuidTableColumn() : void /** * @group DBAL-1082 */ - public function testListDecimalTypeColumns() : void + public function testListDecimalTypeColumns(): void { $tableName = 'test_list_decimal_columns'; $table = new Table($tableName); @@ -391,7 +391,7 @@ public function testListDecimalTypeColumns() : void /** * @group DBAL-1082 */ - public function testListFloatTypeColumns() : void + public function testListFloatTypeColumns(): void { $tableName = 'test_list_float_columns'; $table = new Table($tableName); @@ -409,7 +409,7 @@ public function testListFloatTypeColumns() : void self::assertTrue($columns['col_unsigned']->getUnsigned()); } - public function testJsonColumnType() : void + public function testJsonColumnType(): void { $table = new Table('test_mysql_json'); $table->addColumn('col_json', 'json'); @@ -420,7 +420,7 @@ public function testJsonColumnType() : void self::assertSame(Types::JSON, $columns['col_json']->getType()->getName()); } - public function testColumnDefaultCurrentTimestamp() : void + public function testColumnDefaultCurrentTimestamp(): void { $platform = $this->schemaManager->getDatabasePlatform(); @@ -443,7 +443,7 @@ public function testColumnDefaultCurrentTimestamp() : void self::assertFalse($diff, 'Tables should be identical with column defaults.'); } - public function testColumnDefaultsAreValid() : void + public function testColumnDefaultsAreValid(): void { $table = new Table('test_column_defaults_are_valid'); @@ -486,7 +486,7 @@ public function testColumnDefaultsAreValid() : void * CURRENT_TIME as 'currtime()' and CURRENT_DATE as 'currdate()'. * This test also ensure proper aliasing to not trigger a table diff. */ - public function testColumnDefaultValuesCurrentTimeAndDate() : void + public function testColumnDefaultValuesCurrentTimeAndDate(): void { if (! $this->schemaManager->getDatabasePlatform() instanceof MariaDb1027Platform) { $this->markTestSkipped('Only relevant for MariaDb102Platform.'); @@ -518,7 +518,7 @@ public function testColumnDefaultValuesCurrentTimeAndDate() : void self::assertFalse($diff, 'Tables should be identical with column defauts time and date.'); } - public function testEnsureTableOptionsAreReflectedInMetadata() : void + public function testEnsureTableOptionsAreReflectedInMetadata(): void { $this->connection->query('DROP TABLE IF EXISTS test_table_metadata'); @@ -547,7 +547,7 @@ public function testEnsureTableOptionsAreReflectedInMetadata() : void ], $onlineTable->getOption('create_options')); } - public function testEnsureTableWithoutOptionsAreReflectedInMetadata() : void + public function testEnsureTableWithoutOptionsAreReflectedInMetadata(): void { $this->connection->query('DROP TABLE IF EXISTS test_table_empty_metadata'); @@ -561,7 +561,7 @@ public function testEnsureTableWithoutOptionsAreReflectedInMetadata() : void self::assertEquals([], $onlineTable->getOption('create_options')); } - public function testParseNullCreateOptions() : void + public function testParseNullCreateOptions(): void { $table = $this->schemaManager->listTableDetails('sys.processlist'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php index c7192a7efec..d23cb3a00af 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Types\BinaryType; use Doctrine\DBAL\Types\Types; use Doctrine\Tests\TestUtil; + use function array_map; class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase @@ -14,7 +15,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase /** @var bool */ private static $privilegesGranted = false; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -32,7 +33,7 @@ protected function setUp() : void self::$privilegesGranted = true; } - public function testRenameTable() : void + public function testRenameTable(): void { $this->schemaManager->tryMethod('DropTable', 'list_tables_test'); $this->schemaManager->tryMethod('DropTable', 'list_tables_test_new_name'); @@ -45,7 +46,7 @@ public function testRenameTable() : void self::assertHasTable($tables, 'list_tables_test_new_name'); } - public function testListTableWithBinary() : void + public function testListTableWithBinary(): void { $tableName = 'test_binary_table'; @@ -70,7 +71,7 @@ public function testListTableWithBinary() : void * @group DBAL-472 * @group DBAL-1001 */ - public function testAlterTableColumnNotNull() : void + public function testAlterTableColumnNotNull(): void { $comparator = new Schema\Comparator(); $tableName = 'list_table_column_notnull'; @@ -102,7 +103,7 @@ public function testAlterTableColumnNotNull() : void self::assertTrue($columns['bar']->getNotnull()); } - public function testListDatabases() : void + public function testListDatabases(): void { // We need a privileged connection to create the database. $sm = TestUtil::getPrivilegedConnection()->getSchemaManager(); @@ -118,7 +119,7 @@ public function testListDatabases() : void /** * @group DBAL-831 */ - public function testListTableDetailsWithDifferentIdentifierQuotingRequirements() : void + public function testListTableDetailsWithDifferentIdentifierQuotingRequirements(): void { $primaryTableName = '"Primary_Table"'; $offlinePrimaryTable = new Schema\Table($primaryTableName); @@ -226,7 +227,7 @@ public function testListTableDetailsWithDifferentIdentifierQuotingRequirements() ); } - public function testListTableColumnsSameTableNamesInDifferentSchemas() : void + public function testListTableColumnsSameTableNamesInDifferentSchemas(): void { $table = $this->createListTableColumns(); $this->schemaManager->dropAndCreateTable($table); @@ -242,7 +243,7 @@ public function testListTableColumnsSameTableNamesInDifferentSchemas() : void /** * @group DBAL-1234 */ - public function testListTableIndexesPrimaryKeyConstraintNameDiffersFromIndexName() : void + public function testListTableIndexesPrimaryKeyConstraintNameDiffersFromIndexName(): void { $table = new Table('list_table_indexes_pk_id_test'); $table->setSchemaConfig($this->schemaManager->createSchemaConfig()); @@ -265,7 +266,7 @@ public function testListTableIndexesPrimaryKeyConstraintNameDiffersFromIndexName /** * @group DBAL-2555 */ - public function testListTableDateTypeColumns() : void + public function testListTableDateTypeColumns(): void { $table = new Table('tbl_date'); $table->addColumn('col_date', 'date'); @@ -281,7 +282,7 @@ public function testListTableDateTypeColumns() : void self::assertSame('datetimetz', $columns['col_datetimetz']->getType()->getName()); } - public function testCreateAndListSequences() : void + public function testCreateAndListSequences(): void { self::markTestSkipped("Skipped for uppercase letters are contained in sequences' names. Fix the schema manager in 3.0."); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php index 956192fe661..09e8b04c8c3 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\Types\DecimalType; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; + use function array_map; use function array_pop; use function count; @@ -24,7 +25,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase /** @var PostgreSqlSchemaManager */ protected $schemaManager; - protected function tearDown() : void + protected function tearDown(): void { parent::tearDown(); @@ -38,7 +39,7 @@ protected function tearDown() : void /** * @group DBAL-177 */ - public function testGetSearchPath() : void + public function testGetSearchPath(): void { $params = $this->connection->getParams(); @@ -49,7 +50,7 @@ public function testGetSearchPath() : void /** * @group DBAL-244 */ - public function testGetSchemaNames() : void + public function testGetSchemaNames(): void { $names = $this->schemaManager->getSchemaNames(); @@ -61,7 +62,7 @@ public function testGetSchemaNames() : void /** * @group DBAL-21 */ - public function testSupportDomainTypeFallback() : void + public function testSupportDomainTypeFallback(): void { $createDomainTypeSQL = 'CREATE DOMAIN MyMoney AS DECIMAL(18,2)'; $this->connection->exec($createDomainTypeSQL); @@ -82,7 +83,7 @@ public function testSupportDomainTypeFallback() : void /** * @group DBAL-37 */ - public function testDetectsAutoIncrement() : void + public function testDetectsAutoIncrement(): void { $autoincTable = new Table('autoinc_table'); $column = $autoincTable->addColumn('id', 'integer'); @@ -96,7 +97,7 @@ public function testDetectsAutoIncrement() : void /** * @group DBAL-37 */ - public function testAlterTableAutoIncrementAdd() : void + public function testAlterTableAutoIncrementAdd(): void { $tableFrom = new Table('autoinc_table_add'); $column = $tableFrom->addColumn('id', 'integer'); @@ -125,7 +126,7 @@ public function testAlterTableAutoIncrementAdd() : void /** * @group DBAL-37 */ - public function testAlterTableAutoIncrementDrop() : void + public function testAlterTableAutoIncrementDrop(): void { $tableFrom = new Table('autoinc_table_drop'); $column = $tableFrom->addColumn('id', 'integer'); @@ -150,7 +151,7 @@ public function testAlterTableAutoIncrementDrop() : void /** * @group DBAL-75 */ - public function testTableWithSchema() : void + public function testTableWithSchema(): void { $this->connection->exec('CREATE SCHEMA nested'); @@ -185,7 +186,7 @@ public function testTableWithSchema() : void * @group DBAL-91 * @group DBAL-88 */ - public function testReturnQuotedAssets() : void + public function testReturnQuotedAssets(): void { $sql = 'create table dbal91_something ( id integer CONSTRAINT id_something PRIMARY KEY NOT NULL ,"table" integer );'; $this->connection->exec($sql); @@ -207,7 +208,7 @@ public function testReturnQuotedAssets() : void /** * @group DBAL-204 */ - public function testFilterSchemaExpression() : void + public function testFilterSchemaExpression(): void { $testTable = new Table('dbal204_test_prefix'); $column = $testTable->addColumn('id', 'integer'); @@ -225,13 +226,13 @@ public function testFilterSchemaExpression() : void self::assertCount(1, $names); } - public function testListForeignKeys() : void + public function testListForeignKeys(): void { if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Does not support foreign key constraints.'); } - $fkOptions = ['SET NULL', 'SET DEFAULT', 'NO ACTION','CASCADE', 'RESTRICT']; + $fkOptions = ['SET NULL', 'SET DEFAULT', 'NO ACTION', 'CASCADE', 'RESTRICT']; $foreignKeys = []; $fkTable = $this->getTestTable('test_create_fk1'); for ($i = 0; $i < count($fkOptions); $i++) { @@ -269,7 +270,7 @@ public function testListForeignKeys() : void /** * @group DBAL-511 */ - public function testDefaultValueCharacterVarying() : void + public function testDefaultValueCharacterVarying(): void { $testTable = new Table('dbal511_default'); $testTable->addColumn('id', 'integer'); @@ -286,7 +287,7 @@ public function testDefaultValueCharacterVarying() : void /** * @group DDC-2843 */ - public function testBooleanDefault() : void + public function testBooleanDefault(): void { $table = new Table('ddc2843_bools'); $table->addColumn('id', 'integer'); @@ -302,7 +303,7 @@ public function testBooleanDefault() : void self::assertFalse($diff); } - public function testListTableWithBinary() : void + public function testListTableWithBinary(): void { $tableName = 'test_binary_table'; @@ -323,7 +324,7 @@ public function testListTableWithBinary() : void self::assertFalse($table->getColumn('column_binary')->getFixed()); } - public function testListQuotedTable() : void + public function testListQuotedTable(): void { $offlineTable = new Schema\Table('user'); $offlineTable->addColumn('id', 'integer'); @@ -341,7 +342,7 @@ public function testListQuotedTable() : void self::assertFalse($comparator->diffTable($offlineTable, $onlineTable)); } - public function testListTableDetailsWhenCurrentSchemaNameQuoted() : void + public function testListTableDetailsWhenCurrentSchemaNameQuoted(): void { $this->connection->exec('CREATE SCHEMA "001_test"'); $this->connection->exec('SET search_path TO "001_test"'); @@ -353,7 +354,7 @@ public function testListTableDetailsWhenCurrentSchemaNameQuoted() : void } } - public function testListTablesExcludesViews() : void + public function testListTablesExcludesViews(): void { $this->createTestTable('list_tables_excludes_views'); @@ -382,7 +383,7 @@ public function testListTablesExcludesViews() : void /** * @group DBAL-1033 */ - public function testPartialIndexes() : void + public function testPartialIndexes(): void { $offlineTable = new Schema\Table('person'); $offlineTable->addColumn('id', 'integer'); @@ -405,7 +406,7 @@ public function testPartialIndexes() : void /** * @dataProvider jsonbColumnTypeProvider */ - public function testJsonbColumn(string $type) : void + public function testJsonbColumn(string $type): void { if (! $this->schemaManager->getDatabasePlatform() instanceof PostgreSQL94Platform) { $this->markTestSkipped('Requires PostgresSQL 9.4+'); @@ -426,7 +427,7 @@ public function testJsonbColumn(string $type) : void /** * @return mixed[][] */ - public function jsonbColumnTypeProvider() : array + public function jsonbColumnTypeProvider(): array { return [ [Types::JSON], @@ -437,7 +438,7 @@ public function jsonbColumnTypeProvider() : array /** * @group DBAL-2427 */ - public function testListNegativeColumnDefaultValue() : void + public function testListNegativeColumnDefaultValue(): void { $table = new Schema\Table('test_default_negative'); $table->addColumn('col_smallint', 'smallint', ['default' => -1]); @@ -462,7 +463,7 @@ public function testListNegativeColumnDefaultValue() : void /** * @return mixed[][] */ - public static function serialTypes() : iterable + public static function serialTypes(): iterable { return [ ['integer'], @@ -474,7 +475,7 @@ public static function serialTypes() : iterable * @dataProvider serialTypes * @group 2906 */ - public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValue(string $type) : void + public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValue(string $type): void { $tableName = 'test_serial_type_' . $type; @@ -492,7 +493,7 @@ public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValue(stri * @dataProvider serialTypes * @group 2906 */ - public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValueEvenWhenDefaultIsSet(string $type) : void + public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValueEvenWhenDefaultIsSet(string $type): void { $tableName = 'test_serial_type_with_default_' . $type; @@ -510,7 +511,7 @@ public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValueEvenW * @group 2916 * @dataProvider autoIncrementTypeMigrations */ - public function testAlterTableAutoIncrementIntToBigInt(string $from, string $to, string $expected) : void + public function testAlterTableAutoIncrementIntToBigInt(string $from, string $to, string $expected): void { $tableFrom = new Table('autoinc_type_modification'); $column = $tableFrom->addColumn('id', $from); @@ -536,7 +537,7 @@ public function testAlterTableAutoIncrementIntToBigInt(string $from, string $to, /** * @return mixed[][] */ - public static function autoIncrementTypeMigrations() : iterable + public static function autoIncrementTypeMigrations(): iterable { return [ 'int->bigint' => ['integer', 'bigint', 'BIGINT'], diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php index ab5db98eff9..5a2bb2f42a4 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php @@ -8,7 +8,7 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase { - public function testCreateAndListViews() : void + public function testCreateAndListViews(): void { $this->createTestTable('view_test_table'); @@ -27,7 +27,7 @@ public function testCreateAndListViews() : void self::assertRegExp('/^SELECT \* from "?DBA"?\."?view_test_table"?$/', $views[$name]->getSql()); } - public function testDropAndCreateAdvancedIndex() : void + public function testDropAndCreateAdvancedIndex(): void { $table = $this->getTestTable('test_create_advanced_index'); $this->schemaManager->dropAndCreateTable($table); @@ -47,7 +47,7 @@ public function testDropAndCreateAdvancedIndex() : void self::assertTrue($tableIndexes['test']->hasFlag('for_olap_workload')); } - public function testListTableColumnsWithFixedStringTypeColumn() : void + public function testListTableColumnsWithFixedStringTypeColumn(): void { $table = new Table('list_table_columns_char'); $table->addColumn('id', 'integer', ['notnull' => true]); @@ -62,7 +62,7 @@ public function testListTableColumnsWithFixedStringTypeColumn() : void self::assertTrue($columns['test']->getFixed()); } - public function testCommentInTable() : void + public function testCommentInTable(): void { self::markTestSkipped('Table level comments are not supported on SQLAnywhere'); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php index f8b3b66c15c..657fd9c392e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php @@ -7,11 +7,12 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Types\Type; + use function current; class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase { - protected function getPlatformName() : string + protected function getPlatformName(): string { return 'mssql'; } @@ -19,7 +20,7 @@ protected function getPlatformName() : string /** * @group DBAL-255 */ - public function testDropColumnConstraints() : void + public function testDropColumnConstraints(): void { $table = new Table('sqlsrv_drop_column'); $table->addColumn('id', 'integer'); @@ -34,7 +35,7 @@ public function testDropColumnConstraints() : void self::assertCount(1, $columns); } - public function testColumnCollation() : void + public function testColumnCollation(): void { $table = new Table($tableName = 'test_collation'); $column = $table->addColumn($columnName = 'test', 'string'); @@ -52,7 +53,7 @@ public function testColumnCollation() : void self::assertEquals($collation, $columns[$columnName]->getPlatformOption('collation')); } - public function testDefaultConstraints() : void + public function testDefaultConstraints(): void { $table = new Table('sqlsrv_default_constraints'); $table->addColumn('no_default', 'string'); @@ -157,7 +158,7 @@ public function testDefaultConstraints() : void /** * @group DBAL-543 */ - public function testColumnComments() : void + public function testColumnComments(): void { $table = new Table('sqlsrv_column_comment'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -319,7 +320,7 @@ public function testColumnComments() : void self::assertEquals('666', $columns['added_commented_type_with_comment']->getComment()); } - public function testPkOrdering() : void + public function testPkOrdering(): void { // SQL Server stores index column information in a system table with two // columns that almost always have the same value: index_column_id and key_ordinal. diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php index cf93304fae6..54d7df5abbb 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -31,6 +31,7 @@ use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; + use function array_filter; use function array_keys; use function array_map; @@ -54,7 +55,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase /** @var AbstractSchemaManager */ protected $schemaManager; - protected function getPlatformName() : string + protected function getPlatformName(): string { $class = static::class; $e = explode('\\', $class); @@ -63,7 +64,7 @@ protected function getPlatformName() : string return strtolower(str_replace('SchemaManagerTest', '', $testClass)); } - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -76,7 +77,7 @@ protected function setUp() : void $this->schemaManager = $this->connection->getSchemaManager(); } - protected function tearDown() : void + protected function tearDown(): void { parent::tearDown(); @@ -94,7 +95,7 @@ protected function tearDown() : void /** * @group DBAL-1220 */ - public function testDropsDatabaseWithActiveConnections() : void + public function testDropsDatabaseWithActiveConnections(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsCreateDropDatabase()) { $this->markTestSkipped('Cannot drop Database client side with this Driver.'); @@ -131,7 +132,7 @@ public function testDropsDatabaseWithActiveConnections() : void /** * @group DBAL-195 */ - public function testDropAndCreateSequence() : void + public function testDropAndCreateSequence(): void { $platform = $this->connection->getDatabasePlatform(); @@ -151,11 +152,11 @@ public function testDropAndCreateSequence() : void /** * @param AbstractAsset[] $items */ - private function hasElementWithName(array $items, string $name) : bool + private function hasElementWithName(array $items, string $name): bool { $filteredList = array_filter( $items, - static function (AbstractAsset $item) use ($name) : bool { + static function (AbstractAsset $item) use ($name): bool { return $item->getShortestName($item->getNamespaceName()) === $name; } ); @@ -163,7 +164,7 @@ static function (AbstractAsset $item) use ($name) : bool { return count($filteredList) === 1; } - public function testListSequences() : void + public function testListSequences(): void { $platform = $this->connection->getDatabasePlatform(); @@ -195,7 +196,7 @@ public function testListSequences() : void self::assertSame(10, $foundSequence->getInitialValue(), 'Initial Value is expected to be 10.'); } - public function testListDatabases() : void + public function testListDatabases(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsCreateDropDatabase()) { $this->markTestSkipped('Cannot drop Database client side with this Driver.'); @@ -212,7 +213,7 @@ public function testListDatabases() : void /** * @group DBAL-1058 */ - public function testListNamespaceNames() : void + public function testListNamespaceNames(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsSchemas()) { $this->markTestSkipped('Platform does not support schemas.'); @@ -232,7 +233,7 @@ public function testListNamespaceNames() : void self::assertContains('test_create_schema', $namespaces); } - public function testListTables() : void + public function testListTables(): void { $this->createTestTable('list_tables_test'); $tables = $this->schemaManager->listTables(); @@ -257,7 +258,7 @@ public function testListTables() : void self::assertTrue($foundTable, "The 'list_tables_test' table has to be found."); } - public function createListTableColumns() : Table + public function createListTableColumns(): Table { $table = new Table('list_table_columns'); $table->addColumn('id', 'integer', ['notnull' => true]); @@ -272,7 +273,7 @@ public function createListTableColumns() : Table return $table; } - public function testListTableColumns() : void + public function testListTableColumns(): void { $table = $this->createListTableColumns(); @@ -346,7 +347,7 @@ public function testListTableColumns() : void /** * @group DBAL-1078 */ - public function testListTableColumnsWithFixedStringColumn() : void + public function testListTableColumnsWithFixedStringColumn(): void { $tableName = 'test_list_table_fixed_string'; @@ -363,7 +364,7 @@ public function testListTableColumnsWithFixedStringColumn() : void self::assertSame(2, $columns['column_char']->getLength()); } - public function testListTableColumnsDispatchEvent() : void + public function testListTableColumnsDispatchEvent(): void { $table = $this->createListTableColumns(); @@ -386,7 +387,7 @@ public function testListTableColumnsDispatchEvent() : void $this->schemaManager->getDatabasePlatform()->setEventManager($oldEventManager); } - public function testListTableIndexesDispatchEvent() : void + public function testListTableIndexesDispatchEvent(): void { $table = $this->getTestTable('list_table_indexes_test'); $table->addUniqueIndex(['test'], 'test_index_name'); @@ -411,7 +412,7 @@ public function testListTableIndexesDispatchEvent() : void $this->schemaManager->getDatabasePlatform()->setEventManager($oldEventManager); } - public function testDiffListTableColumns() : void + public function testDiffListTableColumns(): void { if ($this->schemaManager->getDatabasePlatform()->getName() === 'oracle') { $this->markTestSkipped('Does not work with Oracle, since it cannot detect DateTime, Date and Time differenecs (at the moment).'); @@ -427,7 +428,7 @@ public function testDiffListTableColumns() : void self::assertFalse($diff, 'No differences should be detected with the offline vs online schema.'); } - public function testListTableIndexes() : void + public function testListTableIndexes(): void { $table = $this->getTestCompositeTable('list_table_indexes_test'); $table->addUniqueIndex(['test'], 'test_index_name'); @@ -455,7 +456,7 @@ public function testListTableIndexes() : void self::assertFalse($tableIndexes['test_composite_idx']->isPrimary()); } - public function testDropAndCreateIndex() : void + public function testDropAndCreateIndex(): void { $table = $this->getTestTable('test_create_index'); $table->addUniqueIndex(['test'], 'test'); @@ -471,7 +472,7 @@ public function testDropAndCreateIndex() : void self::assertFalse($tableIndexes['test']->isPrimary()); } - public function testCreateTableWithForeignKeys() : void + public function testCreateTableWithForeignKeys(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Platform does not support foreign keys.'); @@ -499,7 +500,7 @@ public function testCreateTableWithForeignKeys() : void self::assertTrue($fkTable->columnsAreIndexed($fkConstraint->getColumns()), 'The columns of a foreign key constraint should always be indexed.'); } - public function testListForeignKeys() : void + public function testListForeignKeys(): void { if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Does not support foreign key constraints.'); @@ -534,12 +535,12 @@ public function testListForeignKeys() : void self::assertEquals('CASCADE', $fkeys[0]->getOption('onDelete')); } - protected function getCreateExampleViewSql() : void + protected function getCreateExampleViewSql(): void { $this->markTestSkipped('No Create Example View SQL was defined for this SchemaManager'); } - public function testCreateSchema() : void + public function testCreateSchema(): void { $this->createTestTable('test_table'); @@ -547,7 +548,7 @@ public function testCreateSchema() : void self::assertTrue($schema->hasTable('test_table')); } - public function testAlterTableScenario() : void + public function testAlterTableScenario(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsAlterTable()) { $this->markTestSkipped('Alter Table is not supported by this platform.'); @@ -636,7 +637,7 @@ public function testAlterTableScenario() : void self::assertEquals(['id'], array_map('strtolower', $foreignKey->getForeignColumns())); } - public function testTableInNamespace() : void + public function testTableInNamespace(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsSchemas()) { $this->markTestSkipped('Schema definition is not supported by this platform.'); @@ -660,7 +661,7 @@ public function testTableInNamespace() : void self::assertContains('my_table_not_in_namespace', $this->schemaManager->listTableNames()); } - public function testCreateAndListViews() : void + public function testCreateAndListViews(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsViews()) { $this->markTestSkipped('Views is not supported by this platform.'); @@ -678,7 +679,7 @@ public function testCreateAndListViews() : void self::assertTrue($this->hasElementWithName($this->schemaManager->listViews(), $name)); } - public function testAutoincrementDetection() : void + public function testAutoincrementDetection(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsIdentityColumns()) { $this->markTestSkipped('This test is only supported on platforms that have autoincrement'); @@ -699,7 +700,7 @@ public function testAutoincrementDetection() : void /** * @group DBAL-792 */ - public function testAutoincrementDetectionMulticolumns() : void + public function testAutoincrementDetectionMulticolumns(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsIdentityColumns()) { $this->markTestSkipped('This test is only supported on platforms that have autoincrement'); @@ -721,7 +722,7 @@ public function testAutoincrementDetectionMulticolumns() : void /** * @group DDC-887 */ - public function testUpdateSchemaWithForeignKeyRenaming() : void + public function testUpdateSchemaWithForeignKeyRenaming(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('This test is only supported on platforms that have foreign keys.'); @@ -766,7 +767,7 @@ public function testUpdateSchemaWithForeignKeyRenaming() : void /** * @group DBAL-1062 */ - public function testRenameIndexUsedInForeignKeyConstraint() : void + public function testRenameIndexUsedInForeignKeyConstraint(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('This test is only supported on platforms that have foreign keys.'); @@ -807,11 +808,13 @@ public function testRenameIndexUsedInForeignKeyConstraint() : void /** * @group DBAL-42 */ - public function testGetColumnComment() : void + public function testGetColumnComment(): void { - if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && + if ( + ! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() && - $this->connection->getDatabasePlatform()->getName() !== 'mssql') { + $this->connection->getDatabasePlatform()->getName() !== 'mssql' + ) { $this->markTestSkipped('Database does not support column comments.'); } @@ -851,11 +854,13 @@ public function testGetColumnComment() : void /** * @group DBAL-42 */ - public function testAutomaticallyAppendCommentOnMarkedColumns() : void + public function testAutomaticallyAppendCommentOnMarkedColumns(): void { - if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && + if ( + ! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() && - $this->connection->getDatabasePlatform()->getName() !== 'mssql') { + $this->connection->getDatabasePlatform()->getName() !== 'mssql' + ) { $this->markTestSkipped('Database does not support column comments.'); } @@ -879,11 +884,13 @@ public function testAutomaticallyAppendCommentOnMarkedColumns() : void /** * @group DBAL-1228 */ - public function testCommentHintOnDateIntervalTypeColumn() : void + public function testCommentHintOnDateIntervalTypeColumn(): void { - if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && + if ( + ! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() && - $this->connection->getDatabasePlatform()->getName() !== 'mssql') { + $this->connection->getDatabasePlatform()->getName() !== 'mssql' + ) { $this->markTestSkipped('Database does not support column comments.'); } @@ -904,7 +911,7 @@ public function testCommentHintOnDateIntervalTypeColumn() : void /** * @group DBAL-825 */ - public function testChangeColumnsTypeWithDefaultValue() : void + public function testChangeColumnsTypeWithDefaultValue(): void { $tableName = 'column_def_change_type'; $table = new Table($tableName); @@ -944,7 +951,7 @@ public function testChangeColumnsTypeWithDefaultValue() : void /** * @group DBAL-197 */ - public function testListTableWithBlob() : void + public function testListTableWithBlob(): void { $table = new Table('test_blob_table'); $table->addColumn('id', 'integer', ['comment' => 'This is a comment']); @@ -963,7 +970,7 @@ public function testListTableWithBlob() : void /** * @param mixed[] $data */ - protected function createTestTable(string $name = 'test_table', array $data = []) : Table + protected function createTestTable(string $name = 'test_table', array $data = []): Table { $options = $data['options'] ?? []; @@ -977,7 +984,7 @@ protected function createTestTable(string $name = 'test_table', array $data = [] /** * @param mixed[] $options */ - protected function getTestTable(string $name, array $options = []) : Table + protected function getTestTable(string $name, array $options = []): Table { $table = new Table($name, [], [], [], false, $options); $table->setSchemaConfig($this->schemaManager->createSchemaConfig()); @@ -989,7 +996,7 @@ protected function getTestTable(string $name, array $options = []) : Table return $table; } - protected function getTestCompositeTable(string $name) : Table + protected function getTestCompositeTable(string $name): Table { $table = new Table($name, [], [], [], false, []); $table->setSchemaConfig($this->schemaManager->createSchemaConfig()); @@ -1004,7 +1011,7 @@ protected function getTestCompositeTable(string $name) : Table /** * @param Table[] $tables */ - protected function assertHasTable(array $tables) : void + protected function assertHasTable(array $tables): void { $foundTable = false; foreach ($tables as $table) { @@ -1019,7 +1026,7 @@ protected function assertHasTable(array $tables) : void self::assertTrue($foundTable, 'Could not find new table'); } - public function testListForeignKeysComposite() : void + public function testListForeignKeysComposite(): void { if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Does not support foreign key constraints.'); @@ -1049,7 +1056,7 @@ public function testListForeignKeysComposite() : void /** * @group DBAL-44 */ - public function testColumnDefaultLifecycle() : void + public function testColumnDefaultLifecycle(): void { $table = new Table('col_def_lifecycle'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -1100,7 +1107,7 @@ public function testColumnDefaultLifecycle() : void self::assertNull($columns['column7']->getDefault()); } - public function testListTableWithBinary() : void + public function testListTableWithBinary(): void { $tableName = 'test_binary_table'; @@ -1121,7 +1128,7 @@ public function testListTableWithBinary() : void self::assertTrue($table->getColumn('column_binary')->getFixed()); } - public function testListTableDetailsWithFullQualifiedTableName() : void + public function testListTableDetailsWithFullQualifiedTableName(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsSchemas()) { $this->markTestSkipped('Test only works on platforms that support schemas.'); @@ -1161,11 +1168,13 @@ public function testListTableDetailsWithFullQualifiedTableName() : void ); } - public function testCommentStringsAreQuoted() : void + public function testCommentStringsAreQuoted(): void { - if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && + if ( + ! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() && - $this->connection->getDatabasePlatform()->getName() !== 'mssql') { + $this->connection->getDatabasePlatform()->getName() !== 'mssql' + ) { $this->markTestSkipped('Database does not support column comments.'); } @@ -1179,7 +1188,7 @@ public function testCommentStringsAreQuoted() : void self::assertEquals("It's a comment with a quote", $columns['id']->getComment()); } - public function testCommentNotDuplicated() : void + public function testCommentNotDuplicated(): void { if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments()) { $this->markTestSkipped('Database does not support column comments.'); @@ -1210,10 +1219,12 @@ public function testAlterColumnComment( ?string $expectedComment1, ?string $comment2, ?string $expectedComment2 - ) : void { - if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && + ): void { + if ( + ! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() && - $this->connection->getDatabasePlatform()->getName() !== 'mssql') { + $this->connection->getDatabasePlatform()->getName() !== 'mssql' + ) { $this->markTestSkipped('Database does not support column comments.'); } @@ -1255,7 +1266,7 @@ public function testAlterColumnComment( /** * @return mixed[][] */ - public static function getAlterColumnComment() : iterable + public static function getAlterColumnComment(): iterable { return [ [null, null, ' ', ' '], @@ -1276,7 +1287,7 @@ public static function getAlterColumnComment() : iterable /** * @group DBAL-1095 */ - public function testDoesNotListIndexesImplicitlyCreatedByForeignKeys() : void + public function testDoesNotListIndexesImplicitlyCreatedByForeignKeys(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('This test is only supported on platforms that have foreign keys.'); @@ -1306,7 +1317,7 @@ public function testDoesNotListIndexesImplicitlyCreatedByForeignKeys() : void /** * @after */ - public function removeJsonArrayTable() : void + public function removeJsonArrayTable(): void { if (! $this->schemaManager->tablesExist(['json_array_test'])) { return; @@ -1319,7 +1330,7 @@ public function removeJsonArrayTable() : void * @group 2782 * @group 6654 */ - public function testComparatorShouldReturnFalseWhenLegacyJsonArrayColumnHasComment() : void + public function testComparatorShouldReturnFalseWhenLegacyJsonArrayColumnHasComment(): void { $table = new Table('json_array_test'); $table->addColumn('parameters', 'json_array'); @@ -1336,7 +1347,7 @@ public function testComparatorShouldReturnFalseWhenLegacyJsonArrayColumnHasComme * @group 2782 * @group 6654 */ - public function testComparatorShouldModifyOnlyTheCommentWhenUpdatingFromJsonArrayTypeOnLegacyPlatforms() : void + public function testComparatorShouldModifyOnlyTheCommentWhenUpdatingFromJsonArrayTypeOnLegacyPlatforms(): void { if ($this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) { $this->markTestSkipped('This test is only supported on platforms that do not have native JSON type.'); @@ -1364,7 +1375,7 @@ public function testComparatorShouldModifyOnlyTheCommentWhenUpdatingFromJsonArra * @group 2782 * @group 6654 */ - public function testComparatorShouldAddCommentToLegacyJsonArrayTypeThatDoesNotHaveIt() : void + public function testComparatorShouldAddCommentToLegacyJsonArrayTypeThatDoesNotHaveIt(): void { if (! $this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) { $this->markTestSkipped('This test is only supported on platforms that have native JSON type.'); @@ -1386,7 +1397,7 @@ public function testComparatorShouldAddCommentToLegacyJsonArrayTypeThatDoesNotHa * @group 2782 * @group 6654 */ - public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayType() : void + public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayType(): void { if (! $this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) { $this->markTestSkipped('This test is only supported on platforms that have native JSON type.'); @@ -1408,7 +1419,7 @@ public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayType * @group 2782 * @group 6654 */ - public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayTypeEvenWhenPlatformHasJsonSupport() : void + public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayTypeEvenWhenPlatformHasJsonSupport(): void { if (! $this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) { $this->markTestSkipped('This test is only supported on platforms that have native JSON type.'); @@ -1430,7 +1441,7 @@ public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayType * @group 2782 * @group 6654 */ - public function testComparatorShouldNotAddCommentToJsonTypeSinceItIsTheDefaultNow() : void + public function testComparatorShouldNotAddCommentToJsonTypeSinceItIsTheDefaultNow(): void { if (! $this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) { $this->markTestSkipped('This test is only supported on platforms that have native JSON type.'); @@ -1451,7 +1462,7 @@ public function testComparatorShouldNotAddCommentToJsonTypeSinceItIsTheDefaultNo * @dataProvider commentsProvider * @group 2596 */ - public function testExtractDoctrineTypeFromComment(string $comment, string $expected, string $currentType) : void + public function testExtractDoctrineTypeFromComment(string $comment, string $expected, string $currentType): void { $result = $this->schemaManager->extractDoctrineTypeFromComment($comment, $currentType); @@ -1461,7 +1472,7 @@ public function testExtractDoctrineTypeFromComment(string $comment, string $expe /** * @return string[][] */ - public function commentsProvider() : array + public function commentsProvider(): array { $currentType = 'current type'; @@ -1475,7 +1486,7 @@ public function commentsProvider() : array ]; } - public function testCreateAndListSequences() : void + public function testCreateAndListSequences(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsSequences()) { self::markTestSkipped('This test is only supported on platforms that support sequences.'); @@ -1514,7 +1525,7 @@ public function testCreateAndListSequences() : void /** * @group #3086 */ - public function testComparisonWithAutoDetectedSequenceDefinition() : void + public function testComparisonWithAutoDetectedSequenceDefinition(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsSequences()) { self::markTestSkipped('This test is only supported on platforms that support sequences.'); @@ -1530,7 +1541,7 @@ public function testComparisonWithAutoDetectedSequenceDefinition() : void $createdSequence = array_values( array_filter( $this->schemaManager->listSequences(), - static function (Sequence $sequence) use ($sequenceName) : bool { + static function (Sequence $sequence) use ($sequenceName): bool { return strcasecmp($sequence->getName(), $sequenceName) === 0; } ) @@ -1547,7 +1558,7 @@ static function (Sequence $sequence) use ($sequenceName) : bool { /** * @group DBAL-2921 */ - public function testPrimaryKeyAutoIncrement() : void + public function testPrimaryKeyAutoIncrement(): void { $table = new Table('test_pk_auto_increment'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -1572,7 +1583,7 @@ public function testPrimaryKeyAutoIncrement() : void $this->assertGreaterThan($lastUsedIdBeforeDelete, $lastUsedIdAfterDelete); } - public function testGenerateAnIndexWithPartialColumnLength() : void + public function testGenerateAnIndexWithPartialColumnLength(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsColumnLengthIndexes()) { self::markTestSkipped('This test is only supported on platforms that support indexes with column length definitions.'); @@ -1592,7 +1603,7 @@ public function testGenerateAnIndexWithPartialColumnLength() : void self::assertEquals($expected, $onlineTable->getIndexes()); } - public function testCommentInTable() : void + public function testCommentInTable(): void { $table = new Table('table_with_comment'); $table->addColumn('id', 'integer'); @@ -1603,7 +1614,7 @@ public function testCommentInTable() : void self::assertSame('Foo with control characters \'\\', $table->getComment()); } - public function testSchemaDiffForeignKeys() : void + public function testSchemaDiffForeignKeys(): void { $schemaManager = $this->connection->getSchemaManager(); $platform = $this->connection->getDatabasePlatform(); @@ -1651,10 +1662,10 @@ public function testSchemaDiffForeignKeys() : void interface ListTableColumnsDispatchEventListener { - public function onSchemaColumnDefinition() : void; + public function onSchemaColumnDefinition(): void; } interface ListTableIndexesDispatchEventListener { - public function onSchemaIndexDefinition() : void; + public function onSchemaIndexDefinition(): void; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php index 74c79393737..52d4e55b674 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; + use function dirname; class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase @@ -16,14 +17,14 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase /** * SQLITE does not support databases. */ - public function testListDatabases() : void + public function testListDatabases(): void { $this->expectException(DBALException::class); $this->schemaManager->listDatabases(); } - public function testCreateAndDropDatabase() : void + public function testCreateAndDropDatabase(): void { $path = dirname(__FILE__) . '/test_create_and_drop_sqlite_database.sqlite'; @@ -36,7 +37,7 @@ public function testCreateAndDropDatabase() : void /** * @group DBAL-1220 */ - public function testDropsDatabaseWithActiveConnections() : void + public function testDropsDatabaseWithActiveConnections(): void { $this->schemaManager->dropAndCreateDatabase('test_drop_database'); @@ -59,7 +60,7 @@ public function testDropsDatabaseWithActiveConnections() : void unset($connection); } - public function testRenameTable() : void + public function testRenameTable(): void { $this->createTestTable('oldname'); $this->schemaManager->renameTable('oldname', 'newname'); @@ -69,7 +70,7 @@ public function testRenameTable() : void self::assertNotContains('oldname', $tables); } - public function createListTableColumns() : Table + public function createListTableColumns(): Table { $table = parent::createListTableColumns(); $table->getColumn('id')->setAutoincrement(true); @@ -77,7 +78,7 @@ public function createListTableColumns() : Table return $table; } - public function testListForeignKeysFromExistingDatabase() : void + public function testListForeignKeysFromExistingDatabase(): void { $this->connection->exec(<<schemaManager->listTableForeignKeys('user')); } - public function testColumnCollation() : void + public function testColumnCollation(): void { $table = new Schema\Table('test_collation'); $table->addColumn('id', 'integer'); @@ -134,7 +135,7 @@ public function testColumnCollation() : void self::assertEquals('NOCASE', $columns['bar']->getPlatformOption('collation')); } - public function testListTableWithBinary() : void + public function testListTableWithBinary(): void { $tableName = 'test_binary_table'; @@ -158,7 +159,7 @@ public function testListTableWithBinary() : void /** * @group DBAL-1779 */ - public function testListTableColumnsWithWhitespacesInTypeDeclarations() : void + public function testListTableColumnsWithWhitespacesInTypeDeclarations(): void { $sql = <<addColumn('id', 'integer'); @@ -248,7 +249,7 @@ public function testPrimaryKeyNoAutoIncrement() : void $this->assertEquals(1, $lastUsedIdAfterDelete); } - public function testOnlyOwnCommentIsParsed() : void + public function testOnlyOwnCommentIsParsed(): void { $table = new Table('own_column_comment'); $table->addColumn('col1', 'string', ['length' => 16]); diff --git a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php index 392e6d756bc..bf3f4abab67 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php @@ -9,12 +9,13 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; + use function base64_decode; use function stream_get_contents; class StatementTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -24,7 +25,7 @@ protected function setUp() : void $this->connection->getSchemaManager()->dropAndCreateTable($table); } - public function testStatementIsReusableAfterClosingCursor() : void + public function testStatementIsReusableAfterClosingCursor(): void { if ($this->connection->getDriver() instanceof PDOOracleDriver) { $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=77181'); @@ -49,7 +50,7 @@ public function testStatementIsReusableAfterClosingCursor() : void self::assertEquals(2, $id); } - public function testReuseStatementWithLongerResults() : void + public function testReuseStatementWithLongerResults(): void { if ($this->connection->getDriver() instanceof PDOOracleDriver) { $this->markTestIncomplete('PDO_OCI doesn\'t support fetching blobs via PDOStatement::fetchAll()'); @@ -86,7 +87,7 @@ public function testReuseStatementWithLongerResults() : void ], $stmt->fetchAll(FetchMode::NUMERIC)); } - public function testFetchLongBlob() : void + public function testFetchLongBlob(): void { if ($this->connection->getDriver() instanceof PDOOracleDriver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported @@ -134,7 +135,7 @@ public function testFetchLongBlob() : void self::assertSame($contents, stream_get_contents($stream)); } - public function testIncompletelyFetchedStatementDoesNotBlockConnection() : void + public function testIncompletelyFetchedStatementDoesNotBlockConnection(): void { $this->connection->insert('stmt_test', ['id' => 1]); $this->connection->insert('stmt_test', ['id' => 2]); @@ -151,7 +152,7 @@ public function testIncompletelyFetchedStatementDoesNotBlockConnection() : void self::assertEquals(1, $stmt2->fetchColumn()); } - public function testReuseStatementAfterClosingCursor() : void + public function testReuseStatementAfterClosingCursor(): void { if ($this->connection->getDriver() instanceof PDOOracleDriver) { $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=77181'); @@ -173,7 +174,7 @@ public function testReuseStatementAfterClosingCursor() : void self::assertEquals(2, $id); } - public function testReuseStatementWithParameterBoundByReference() : void + public function testReuseStatementWithParameterBoundByReference(): void { $this->connection->insert('stmt_test', ['id' => 1]); $this->connection->insert('stmt_test', ['id' => 2]); @@ -190,7 +191,7 @@ public function testReuseStatementWithParameterBoundByReference() : void self::assertEquals(2, $stmt->fetchColumn()); } - public function testReuseStatementWithReboundValue() : void + public function testReuseStatementWithReboundValue(): void { $this->connection->insert('stmt_test', ['id' => 1]); $this->connection->insert('stmt_test', ['id' => 2]); @@ -206,7 +207,7 @@ public function testReuseStatementWithReboundValue() : void self::assertEquals(2, $stmt->fetchColumn()); } - public function testReuseStatementWithReboundParam() : void + public function testReuseStatementWithReboundParam(): void { $this->connection->insert('stmt_test', ['id' => 1]); $this->connection->insert('stmt_test', ['id' => 2]); @@ -229,14 +230,14 @@ public function testReuseStatementWithReboundParam() : void * * @dataProvider emptyFetchProvider */ - public function testFetchFromNonExecutedStatement(callable $fetch, $expected) : void + public function testFetchFromNonExecutedStatement(callable $fetch, $expected): void { $stmt = $this->connection->prepare('SELECT id FROM stmt_test'); self::assertSame($expected, $fetch($stmt)); } - public function testCloseCursorOnNonExecutedStatement() : void + public function testCloseCursorOnNonExecutedStatement(): void { $stmt = $this->connection->prepare('SELECT id FROM stmt_test'); self::assertTrue($stmt->closeCursor()); @@ -245,7 +246,7 @@ public function testCloseCursorOnNonExecutedStatement() : void /** * @group DBAL-2637 */ - public function testCloseCursorAfterCursorEnd() : void + public function testCloseCursorAfterCursorEnd(): void { $stmt = $this->connection->prepare('SELECT name FROM stmt_test'); @@ -260,7 +261,7 @@ public function testCloseCursorAfterCursorEnd() : void * * @dataProvider emptyFetchProvider */ - public function testFetchFromNonExecutedStatementWithClosedCursor(callable $fetch, $expected) : void + public function testFetchFromNonExecutedStatementWithClosedCursor(callable $fetch, $expected): void { $stmt = $this->connection->prepare('SELECT id FROM stmt_test'); $stmt->closeCursor(); @@ -273,7 +274,7 @@ public function testFetchFromNonExecutedStatementWithClosedCursor(callable $fetc * * @dataProvider emptyFetchProvider */ - public function testFetchFromExecutedStatementWithClosedCursor(callable $fetch, $expected) : void + public function testFetchFromExecutedStatementWithClosedCursor(callable $fetch, $expected): void { $this->connection->insert('stmt_test', ['id' => 1]); @@ -287,7 +288,7 @@ public function testFetchFromExecutedStatementWithClosedCursor(callable $fetch, /** * @return mixed[][] */ - public static function emptyFetchProvider() : iterable + public static function emptyFetchProvider(): iterable { return [ 'fetch' => [ @@ -311,7 +312,7 @@ static function (Statement $stmt) { ]; } - public function testFetchInColumnMode() : void + public function testFetchInColumnMode(): void { $platform = $this->connection->getDatabasePlatform(); $query = $platform->getDummySelectSQL(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php b/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php index 8a52c0503fe..083a7114996 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php @@ -16,7 +16,7 @@ class TableGeneratorTest extends DbalFunctionalTestCase /** @var TableGenerator */ private $generator; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -39,7 +39,7 @@ protected function setUp() : void $this->generator = new TableGenerator($this->connection); } - public function testNextVal() : void + public function testNextVal(): void { $id1 = $this->generator->nextValue('tbl1'); $id2 = $this->generator->nextValue('tbl1'); @@ -50,7 +50,7 @@ public function testNextVal() : void self::assertEquals($id1, $id3, 'First ids from different tables are equal.'); } - public function testNextValNotAffectedByOuterTransactions() : void + public function testNextValNotAffectedByOuterTransactions(): void { $this->connection->beginTransaction(); $id1 = $this->generator->nextValue('tbl1'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php b/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php index e96fd426b3a..7ee7fb23ff9 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php @@ -9,7 +9,7 @@ class TemporaryTableTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); try { @@ -18,7 +18,7 @@ protected function setUp() : void } } - protected function tearDown() : void + protected function tearDown(): void { if ($this->connection) { try { @@ -34,10 +34,12 @@ protected function tearDown() : void /** * @group DDC-1337 */ - public function testDropTemporaryTableNotAutoCommitTransaction() : void + public function testDropTemporaryTableNotAutoCommitTransaction(): void { - if ($this->connection->getDatabasePlatform()->getName() === 'sqlanywhere' || - $this->connection->getDatabasePlatform()->getName() === 'oracle') { + if ( + $this->connection->getDatabasePlatform()->getName() === 'sqlanywhere' || + $this->connection->getDatabasePlatform()->getName() === 'oracle' + ) { $this->markTestSkipped('Test does not work on Oracle and SQL Anywhere.'); } @@ -69,10 +71,12 @@ public function testDropTemporaryTableNotAutoCommitTransaction() : void /** * @group DDC-1337 */ - public function testCreateTemporaryTableNotAutoCommitTransaction() : void + public function testCreateTemporaryTableNotAutoCommitTransaction(): void { - if ($this->connection->getDatabasePlatform()->getName() === 'sqlanywhere' || - $this->connection->getDatabasePlatform()->getName() === 'oracle') { + if ( + $this->connection->getDatabasePlatform()->getName() === 'sqlanywhere' || + $this->connection->getDatabasePlatform()->getName() === 'oracle' + ) { $this->markTestSkipped('Test does not work on Oracle and SQL Anywhere.'); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php index a3133635c0d..9a394ebcdc5 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php @@ -10,7 +10,7 @@ */ class DBAL168Test extends DbalFunctionalTestCase { - public function testDomainsTable() : void + public function testDomainsTable(): void { if ($this->connection->getDatabasePlatform()->getName() !== 'postgresql') { $this->markTestSkipped('PostgreSQL only test'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php index da1fbcbd2f1..99a841a9078 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php @@ -10,7 +10,7 @@ */ class DBAL202Test extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -29,7 +29,7 @@ protected function setUp() : void } } - public function testStatementRollback() : void + public function testStatementRollback(): void { $stmt = $this->connection->prepare('INSERT INTO DBAL202 VALUES (8)'); $this->connection->beginTransaction(); @@ -39,7 +39,7 @@ public function testStatementRollback() : void self::assertEquals(0, $this->connection->query('SELECT COUNT(1) FROM DBAL202')->fetchColumn()); } - public function testStatementCommit() : void + public function testStatementCommit(): void { $stmt = $this->connection->prepare('INSERT INTO DBAL202 VALUES (8)'); $this->connection->beginTransaction(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php index 3ebd3a62f1f..86a061749f4 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional\Ticket; use Doctrine\Tests\DbalFunctionalTestCase; + use function in_array; use function preg_match; @@ -11,7 +12,7 @@ */ class DBAL421Test extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -23,7 +24,7 @@ protected function setUp() : void $this->markTestSkipped('Currently restricted to MySQL and SQLite.'); } - public function testGuidShouldMatchPattern() : void + public function testGuidShouldMatchPattern(): void { $guid = $this->connection->query($this->getSelectGuidSql())->fetchColumn(); $pattern = '/[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[8-9A-B][0-9A-F]{3}\-[0-9A-F]{12}/i'; @@ -34,7 +35,7 @@ public function testGuidShouldMatchPattern() : void * This test does (of course) not proof that all generated GUIDs are * random, it should however provide some basic confidence. */ - public function testGuidShouldBeRandom() : void + public function testGuidShouldBeRandom(): void { $statement = $this->connection->prepare($this->getSelectGuidSql()); $guids = []; @@ -49,7 +50,7 @@ public function testGuidShouldBeRandom() : void $statement->closeCursor(); } - private function getSelectGuidSql() : string + private function getSelectGuidSql(): string { return 'SELECT ' . $this->connection->getDatabasePlatform()->getGuidExpression(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php index e1c0927d852..96b10ebb2fe 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php @@ -14,7 +14,7 @@ */ class DBAL461Test extends TestCase { - public function testIssue() : void + public function testIssue(): void { $conn = $this->createMock(Connection::class); $platform = $this->getMockForAbstractClass(AbstractPlatform::class); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php index 1b3008db65d..0b98eb3cb0c 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php @@ -11,7 +11,7 @@ */ class DBAL510Test extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -22,7 +22,7 @@ protected function setUp() : void $this->markTestSkipped('PostgreSQL Only test'); } - public function testSearchPathSchemaChanges() : void + public function testSearchPathSchemaChanges(): void { $table = new Table('dbal510tbl'); $table->addColumn('id', 'integer'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php index 88f1fa9b569..83e50b16165 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; + use function in_array; /** @@ -17,7 +18,7 @@ class DBAL630Test extends DbalFunctionalTestCase /** @var bool */ private $running = false; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -36,7 +37,7 @@ protected function setUp() : void $this->running = true; } - protected function tearDown() : void + protected function tearDown(): void { if ($this->running) { $this->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); @@ -45,7 +46,7 @@ protected function tearDown() : void parent::tearDown(); } - public function testBooleanConversionSqlLiteral() : void + public function testBooleanConversionSqlLiteral(): void { $this->connection->executeUpdate('INSERT INTO dbal630 (bool_col) VALUES(false)'); $id = $this->connection->lastInsertId('dbal630_id_seq'); @@ -56,7 +57,7 @@ public function testBooleanConversionSqlLiteral() : void self::assertFalse($row['bool_col']); } - public function testBooleanConversionBoolParamRealPrepares() : void + public function testBooleanConversionBoolParamRealPrepares(): void { $this->connection->executeUpdate( 'INSERT INTO dbal630 (bool_col) VALUES(?)', @@ -71,7 +72,7 @@ public function testBooleanConversionBoolParamRealPrepares() : void self::assertFalse($row['bool_col']); } - public function testBooleanConversionBoolParamEmulatedPrepares() : void + public function testBooleanConversionBoolParamEmulatedPrepares(): void { $this->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); @@ -96,7 +97,7 @@ public function testBooleanConversionBoolParamEmulatedPrepares() : void public function testBooleanConversionNullParamEmulatedPrepares( ?bool $statementValue, ?bool $databaseConvertedValue - ) : void { + ): void { $this->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $platform = $this->connection->getDatabasePlatform(); @@ -120,7 +121,7 @@ public function testBooleanConversionNullParamEmulatedPrepares( public function testBooleanConversionNullParamEmulatedPreparesWithBooleanTypeInBindValue( ?bool $statementValue, bool $databaseConvertedValue - ) : void { + ): void { $this->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $platform = $this->connection->getDatabasePlatform(); @@ -147,7 +148,7 @@ public function testBooleanConversionNullParamEmulatedPreparesWithBooleanTypeInB * * @return mixed[][] */ - public static function booleanTypeConversionUsingBooleanTypeProvider() : iterable + public static function booleanTypeConversionUsingBooleanTypeProvider(): iterable { return [ // statement value, database converted value result @@ -162,7 +163,7 @@ public static function booleanTypeConversionUsingBooleanTypeProvider() : iterabl * * @return mixed[][] */ - public static function booleanTypeConversionWithoutPdoTypeProvider() : iterable + public static function booleanTypeConversionWithoutPdoTypeProvider(): iterable { return [ // statement value, database converted value result @@ -172,7 +173,7 @@ public static function booleanTypeConversionWithoutPdoTypeProvider() : iterable ]; } - private function getWrappedConnection() : PDOConnection + private function getWrappedConnection(): PDOConnection { $connection = $this->connection->getWrappedConnection(); self::assertInstanceOf(PDOConnection::class, $connection); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php index 47bc1c3e762..2998d83ec2d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional\Ticket; use Doctrine\Tests\DbalFunctionalTestCase; + use function in_array; /** @@ -10,7 +11,7 @@ */ class DBAL752Test extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -23,7 +24,7 @@ protected function setUp() : void $this->markTestSkipped('Related to SQLite only'); } - public function testUnsignedIntegerDetection() : void + public function testUnsignedIntegerDetection(): void { $this->connection->exec(<<markTestSkipped('Restricted to MySQL.'); } - protected function tearDown() : void + protected function tearDown(): void { $this->resetSharedConn(); parent::tearDown(); } - public function testCommitFalse() : void + public function testCommitFalse(): void { $this->connection->query('SET SESSION wait_timeout=1'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php index 0d034edada2..b987905569e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; use stdClass; + use function str_repeat; class TypeConversionTest extends DbalFunctionalTestCase @@ -15,7 +16,7 @@ class TypeConversionTest extends DbalFunctionalTestCase /** @var int */ private static $typeCounter = 0; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -47,7 +48,7 @@ protected function setUp() : void * * @dataProvider booleanProvider */ - public function testIdempotentConversionToBoolean(string $type, $originalValue) : void + public function testIdempotentConversionToBoolean(string $type, $originalValue): void { $dbValue = $this->processValue($type, $originalValue); @@ -58,7 +59,7 @@ public function testIdempotentConversionToBoolean(string $type, $originalValue) /** * @return mixed[][] */ - public static function booleanProvider() : iterable + public static function booleanProvider(): iterable { return [ 'true' => ['boolean', true], @@ -71,7 +72,7 @@ public static function booleanProvider() : iterable * * @dataProvider integerProvider */ - public function testIdempotentConversionToInteger(string $type, $originalValue) : void + public function testIdempotentConversionToInteger(string $type, $originalValue): void { $dbValue = $this->processValue($type, $originalValue); @@ -82,7 +83,7 @@ public function testIdempotentConversionToInteger(string $type, $originalValue) /** * @return mixed[][] */ - public static function integerProvider() : iterable + public static function integerProvider(): iterable { return [ 'smallint' => ['smallint', 123], @@ -94,7 +95,7 @@ public static function integerProvider() : iterable * * @dataProvider floatProvider */ - public function testIdempotentConversionToFloat(string $type, $originalValue) : void + public function testIdempotentConversionToFloat(string $type, $originalValue): void { $dbValue = $this->processValue($type, $originalValue); @@ -105,7 +106,7 @@ public function testIdempotentConversionToFloat(string $type, $originalValue) : /** * @return mixed[][] */ - public static function floatProvider() : iterable + public static function floatProvider(): iterable { return [ 'float' => ['float', 1.5], @@ -117,7 +118,7 @@ public static function floatProvider() : iterable * * @dataProvider toStringProvider */ - public function testIdempotentConversionToString(string $type, $originalValue) : void + public function testIdempotentConversionToString(string $type, $originalValue): void { if ($type === 'text' && $this->connection->getDriver() instanceof PDOOracleDriver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported @@ -134,7 +135,7 @@ public function testIdempotentConversionToString(string $type, $originalValue) : /** * @return mixed[][] */ - public static function toStringProvider() : iterable + public static function toStringProvider(): iterable { return [ 'string' => ['string', 'ABCDEFGabcdefg'], @@ -149,7 +150,7 @@ public static function toStringProvider() : iterable * * @dataProvider toArrayProvider */ - public function testIdempotentConversionToArray(string $type, $originalValue) : void + public function testIdempotentConversionToArray(string $type, $originalValue): void { $dbValue = $this->processValue($type, $originalValue); @@ -160,7 +161,7 @@ public function testIdempotentConversionToArray(string $type, $originalValue) : /** * @return mixed[][] */ - public static function toArrayProvider() : iterable + public static function toArrayProvider(): iterable { return [ 'array' => ['array', ['foo' => 'bar']], @@ -173,7 +174,7 @@ public static function toArrayProvider() : iterable * * @dataProvider toObjectProvider */ - public function testIdempotentConversionToObject(string $type, $originalValue) : void + public function testIdempotentConversionToObject(string $type, $originalValue): void { $dbValue = $this->processValue($type, $originalValue); @@ -184,7 +185,7 @@ public function testIdempotentConversionToObject(string $type, $originalValue) : /** * @return mixed[][] */ - public static function toObjectProvider() : iterable + public static function toObjectProvider(): iterable { $obj = new stdClass(); $obj->foo = 'bar'; @@ -198,7 +199,7 @@ public static function toObjectProvider() : iterable /** * @dataProvider toDateTimeProvider */ - public function testIdempotentConversionToDateTime(string $type, DateTime $originalValue) : void + public function testIdempotentConversionToDateTime(string $type, DateTime $originalValue): void { $dbValue = $this->processValue($type, $originalValue); @@ -218,7 +219,7 @@ public function testIdempotentConversionToDateTime(string $type, DateTime $origi /** * @return mixed[][] */ - public static function toDateTimeProvider() : iterable + public static function toDateTimeProvider(): iterable { return [ 'datetime' => ['datetime', new DateTime('2010-04-05 10:10:10')], diff --git a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php index 76236acff0c..ff8a503b5a3 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; + use function is_resource; use function random_bytes; use function str_replace; @@ -16,7 +17,7 @@ class BinaryTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -36,7 +37,7 @@ protected function setUp() : void $sm->dropAndCreateTable($table); } - public function testInsertAndSelect() : void + public function testInsertAndSelect(): void { $id1 = random_bytes(16); $id2 = random_bytes(16); @@ -57,7 +58,7 @@ public function testInsertAndSelect() : void $this->assertSame($value2, $this->select($id2)); } - private function insert(string $id, string $value) : void + private function insert(string $id, string $value): void { $result = $this->connection->insert('binary_table', [ 'id' => $id, diff --git a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php index 2f8b19e9f97..5a39a71bef5 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php @@ -11,12 +11,13 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; + use function array_filter; use function strtolower; class WriteTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -37,7 +38,7 @@ protected function setUp() : void /** * @group DBAL-80 */ - public function testExecuteUpdateFirstTypeIsNull() : void + public function testExecuteUpdateFirstTypeIsNull(): void { $sql = 'INSERT INTO write_table (test_string, test_int) VALUES (?, ?)'; $this->connection->executeUpdate($sql, ['text', 1111], [null, ParameterType::INTEGER]); @@ -46,7 +47,7 @@ public function testExecuteUpdateFirstTypeIsNull() : void self::assertTrue((bool) $this->connection->fetchColumn($sql, ['text', 1111])); } - public function testExecuteUpdate() : void + public function testExecuteUpdate(): void { $sql = 'INSERT INTO write_table (test_int) VALUES ( ' . $this->connection->quote(1) . ')'; $affected = $this->connection->executeUpdate($sql); @@ -54,7 +55,7 @@ public function testExecuteUpdate() : void self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!'); } - public function testExecuteUpdateWithTypes() : void + public function testExecuteUpdateWithTypes(): void { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; $affected = $this->connection->executeUpdate( @@ -66,7 +67,7 @@ public function testExecuteUpdateWithTypes() : void self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!'); } - public function testPrepareRowCountReturnsAffectedRows() : void + public function testPrepareRowCountReturnsAffectedRows(): void { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; $stmt = $this->connection->prepare($sql); @@ -78,7 +79,7 @@ public function testPrepareRowCountReturnsAffectedRows() : void self::assertEquals(1, $stmt->rowCount()); } - public function testPrepareWithPdoTypes() : void + public function testPrepareWithPdoTypes(): void { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; $stmt = $this->connection->prepare($sql); @@ -90,7 +91,7 @@ public function testPrepareWithPdoTypes() : void self::assertEquals(1, $stmt->rowCount()); } - public function testPrepareWithDbalTypes() : void + public function testPrepareWithDbalTypes(): void { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; $stmt = $this->connection->prepare($sql); @@ -103,7 +104,7 @@ public function testPrepareWithDbalTypes() : void self::assertEquals(1, $stmt->rowCount()); } - public function testPrepareWithDbalTypeNames() : void + public function testPrepareWithDbalTypeNames(): void { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; $stmt = $this->connection->prepare($sql); @@ -116,18 +117,18 @@ public function testPrepareWithDbalTypeNames() : void self::assertEquals(1, $stmt->rowCount()); } - public function insertRows() : void + public function insertRows(): void { self::assertEquals(1, $this->connection->insert('write_table', ['test_int' => 1, 'test_string' => 'foo'])); self::assertEquals(1, $this->connection->insert('write_table', ['test_int' => 2, 'test_string' => 'bar'])); } - public function testInsert() : void + public function testInsert(): void { $this->insertRows(); } - public function testDelete() : void + public function testDelete(): void { $this->insertRows(); @@ -138,7 +139,7 @@ public function testDelete() : void self::assertCount(0, $this->connection->fetchAll('SELECT * FROM write_table')); } - public function testUpdate() : void + public function testUpdate(): void { $this->insertRows(); @@ -147,7 +148,7 @@ public function testUpdate() : void self::assertEquals(0, $this->connection->update('write_table', ['test_string' => 'baz'], ['test_string' => 'bar'])); } - public function testLastInsertId() : void + public function testLastInsertId(): void { if (! $this->connection->getDatabasePlatform()->prefersIdentityColumns()) { $this->markTestSkipped('Test only works on platforms with identity columns.'); @@ -160,7 +161,7 @@ public function testLastInsertId() : void self::assertGreaterThan(0, $num, 'LastInsertId() should be non-negative number.'); } - public function testLastInsertIdSequence() : void + public function testLastInsertIdSequence(): void { if (! $this->connection->getDatabasePlatform()->supportsSequences()) { $this->markTestSkipped('Test only works on platforms with sequences.'); @@ -186,7 +187,7 @@ public function testLastInsertIdSequence() : void self::assertEquals($nextSequenceVal, $lastInsertId); } - public function testLastInsertIdNoSequenceGiven() : void + public function testLastInsertIdNoSequenceGiven(): void { if (! $this->connection->getDatabasePlatform()->supportsSequences() || $this->connection->getDatabasePlatform()->supportsIdentityColumns()) { $this->markTestSkipped("Test only works consistently on platforms that support sequences and don't support identity columns."); @@ -198,7 +199,7 @@ public function testLastInsertIdNoSequenceGiven() : void /** * @group DBAL-445 */ - public function testInsertWithKeyValueTypes() : void + public function testInsertWithKeyValueTypes(): void { $testString = new DateTime('2013-04-14 10:10:10'); @@ -216,7 +217,7 @@ public function testInsertWithKeyValueTypes() : void /** * @group DBAL-445 */ - public function testUpdateWithKeyValueTypes() : void + public function testUpdateWithKeyValueTypes(): void { $testString = new DateTime('2013-04-14 10:10:10'); @@ -243,7 +244,7 @@ public function testUpdateWithKeyValueTypes() : void /** * @group DBAL-445 */ - public function testDeleteWithKeyValueTypes() : void + public function testDeleteWithKeyValueTypes(): void { $val = new DateTime('2013-04-14 10:10:10'); $this->connection->insert( @@ -259,7 +260,7 @@ public function testDeleteWithKeyValueTypes() : void self::assertFalse($data); } - public function testEmptyIdentityInsert() : void + public function testEmptyIdentityInsert(): void { $platform = $this->connection->getDatabasePlatform(); @@ -302,7 +303,7 @@ public function testEmptyIdentityInsert() : void /** * @group DBAL-2688 */ - public function testUpdateWhereIsNull() : void + public function testUpdateWhereIsNull(): void { $this->connection->insert( 'write_table', @@ -321,7 +322,7 @@ public function testUpdateWhereIsNull() : void self::assertCount(0, $data); } - public function testDeleteWhereIsNull() : void + public function testDeleteWhereIsNull(): void { $this->connection->insert( 'write_table', diff --git a/tests/Doctrine/Tests/DBAL/Internal/DependencyOrderCalculatorTest.php b/tests/Doctrine/Tests/DBAL/Internal/DependencyOrderCalculatorTest.php index 254145f0d18..2c6227a0be6 100644 --- a/tests/Doctrine/Tests/DBAL/Internal/DependencyOrderCalculatorTest.php +++ b/tests/Doctrine/Tests/DBAL/Internal/DependencyOrderCalculatorTest.php @@ -18,12 +18,12 @@ class DependencyOrderCalculatorTest extends DbalTestCase /** @var DependencyOrderCalculator */ private $calculator; - protected function setUp() : void + protected function setUp(): void { $this->calculator = new DependencyOrderCalculator(); } - public function testCommitOrdering1() : void + public function testCommitOrdering1(): void { $table1 = new Table('table1'); $table2 = new Table('table2'); diff --git a/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php b/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php index 26b5a959350..85f760fb83d 100644 --- a/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php +++ b/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php @@ -10,17 +10,17 @@ class DebugStackTest extends DbalTestCase /** @var DebugStack */ private $logger; - protected function setUp() : void + protected function setUp(): void { $this->logger = new DebugStack(); } - protected function tearDown() : void + protected function tearDown(): void { unset($this->logger); } - public function testLoggedQuery() : void + public function testLoggedQuery(): void { $this->logger->startQuery('SELECT column FROM table'); self::assertEquals( @@ -39,7 +39,7 @@ public function testLoggedQuery() : void self::assertGreaterThan(0, $this->logger->queries[1]['executionMS']); } - public function testLoggedQueryDisabled() : void + public function testLoggedQueryDisabled(): void { $this->logger->enabled = false; $this->logger->startQuery('SELECT column FROM table'); diff --git a/tests/Doctrine/Tests/DBAL/Logging/LoggerChainTest.php b/tests/Doctrine/Tests/DBAL/Logging/LoggerChainTest.php index 60d9c669d13..8d956dff234 100644 --- a/tests/Doctrine/Tests/DBAL/Logging/LoggerChainTest.php +++ b/tests/Doctrine/Tests/DBAL/Logging/LoggerChainTest.php @@ -11,7 +11,7 @@ class LoggerChainTest extends TestCase { - public function testStartQuery() : void + public function testStartQuery(): void { $sql = 'SELECT ?'; $params = [1]; @@ -21,7 +21,7 @@ public function testStartQuery() : void $listener->startQuery($sql, $params, $types); } - public function testStopQuery() : void + public function testStopQuery(): void { $listener = $this->createChain('stopQuery'); $listener->stopQuery(); @@ -30,7 +30,7 @@ public function testStopQuery() : void /** * @param mixed ...$args */ - private function createChain(string $method, ...$args) : LoggerChain + private function createChain(string $method, ...$args): LoggerChain { $chain = new LoggerChain([ $this->createLogger($method, ...$args), @@ -44,7 +44,7 @@ private function createChain(string $method, ...$args) : LoggerChain /** * @param mixed ...$args */ - private function createLogger(string $method, ...$args) : SQLLogger + private function createLogger(string $method, ...$args): SQLLogger { $logger = $this->createMock(SQLLogger::class); $logger->expects($this->once()) diff --git a/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php b/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php index fefc973a699..f9367ffe9e6 100644 --- a/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php +++ b/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php @@ -17,7 +17,7 @@ class TypeConversionPerformanceTest extends DbalPerformanceTestCase * * @dataProvider itemCountProvider */ - public function testDateTimeTypeConversionPerformance(int $count) : void + public function testDateTimeTypeConversionPerformance(int $count): void { $value = new DateTime(); $type = Type::getType('datetime'); @@ -33,7 +33,7 @@ public function testDateTimeTypeConversionPerformance(int $count) : void /** * @return mixed[][] */ - public static function itemCountProvider() : iterable + public static function itemCountProvider(): iterable { return [ '100 items' => [100], diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php index 8514ded4c1a..7a12bf61f14 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; + use function array_shift; abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase @@ -17,13 +18,13 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase /** @var MySqlPlatform */ protected $platform; - public function testModifyLimitQueryWitoutLimit() : void + public function testModifyLimitQueryWitoutLimit(): void { $sql = $this->platform->modifyLimitQuery('SELECT n FROM Foo', null, 10); self::assertEquals('SELECT n FROM Foo LIMIT 18446744073709551615 OFFSET 10', $sql); } - public function testGenerateMixedCaseTableCreate() : void + public function testGenerateMixedCaseTableCreate(): void { $table = new Table('Foo'); $table->addColumn('Bar', 'integer'); @@ -32,7 +33,7 @@ public function testGenerateMixedCaseTableCreate() : void self::assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB', array_shift($sql)); } - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'; } @@ -40,7 +41,7 @@ public function getGenerateTableSql() : string /** * @return string[] */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return ['CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA (foo, bar)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB']; } @@ -48,19 +49,19 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return ["ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL, DROP foo, CHANGE bar baz VARCHAR(255) DEFAULT 'def' NOT NULL, CHANGE bloo bloo TINYINT(1) DEFAULT '0' NOT NULL"]; } - public function testGeneratesSqlSnippets() : void + public function testGeneratesSqlSnippets(): void { self::assertEquals('RLIKE', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct'); self::assertEquals('`', $this->platform->getIdentifierQuoteCharacter(), 'Quote character is not correct'); self::assertEquals('CONCAT(column1, column2, column3)', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation function is not correct'); } - public function testGeneratesTransactionsCommands() : void + public function testGeneratesTransactionsCommands(): void { self::assertEquals( 'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', @@ -81,7 +82,7 @@ public function testGeneratesTransactionsCommands() : void ); } - public function testGeneratesDDLSnippets() : void + public function testGeneratesDDLSnippets(): void { self::assertEquals('SHOW DATABASES', $this->platform->getListDatabasesSQL()); self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar')); @@ -89,7 +90,7 @@ public function testGeneratesDDLSnippets() : void self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar')); } - public function testGeneratesTypeDeclarationForIntegers() : void + public function testGeneratesTypeDeclarationForIntegers(): void { self::assertEquals( 'INT', @@ -107,7 +108,7 @@ public function testGeneratesTypeDeclarationForIntegers() : void ); } - public function testGeneratesTypeDeclarationForStrings() : void + public function testGeneratesTypeDeclarationForStrings(): void { self::assertEquals( 'CHAR(10)', @@ -127,32 +128,32 @@ public function testGeneratesTypeDeclarationForStrings() : void ); } - public function testPrefersIdentityColumns() : void + public function testPrefersIdentityColumns(): void { self::assertTrue($this->platform->prefersIdentityColumns()); } - public function testSupportsIdentityColumns() : void + public function testSupportsIdentityColumns(): void { self::assertTrue($this->platform->supportsIdentityColumns()); } - public function testDoesSupportSavePoints() : void + public function testDoesSupportSavePoints(): void { self::assertTrue($this->platform->supportsSavepoints()); } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } - protected function getGenerateForeignKeySql() : string + protected function getGenerateForeignKeySql(): string { return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; } @@ -160,7 +161,7 @@ protected function getGenerateForeignKeySql() : string /** * @group DBAL-126 */ - public function testUniquePrimaryKey() : void + public function testUniquePrimaryKey(): void { $keyTable = new Table('foo'); $keyTable->addColumn('bar', 'integer'); @@ -183,13 +184,13 @@ public function testUniquePrimaryKey() : void ], $sql); } - public function testModifyLimitQuery() : void + public function testModifyLimitQuery(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0); self::assertEquals('SELECT * FROM user LIMIT 10', $sql); } - public function testModifyLimitQueryWithEmptyOffset() : void + public function testModifyLimitQueryWithEmptyOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10); self::assertEquals('SELECT * FROM user LIMIT 10', $sql); @@ -198,7 +199,7 @@ public function testModifyLimitQueryWithEmptyOffset() : void /** * @group DDC-118 */ - public function testGetDateTimeTypeDeclarationSql() : void + public function testGetDateTimeTypeDeclarationSql(): void { self::assertEquals('DATETIME', $this->platform->getDateTimeTypeDeclarationSQL(['version' => false])); self::assertEquals('TIMESTAMP', $this->platform->getDateTimeTypeDeclarationSQL(['version' => true])); @@ -208,7 +209,7 @@ public function testGetDateTimeTypeDeclarationSql() : void /** * {@inheritDoc} */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { return ["CREATE TABLE test (id INT NOT NULL COMMENT 'This is a comment', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB"]; } @@ -216,7 +217,7 @@ public function getCreateTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { return ["ALTER TABLE mytable ADD quota INT NOT NULL COMMENT 'A comment', CHANGE foo foo VARCHAR(255) NOT NULL, CHANGE bar baz VARCHAR(255) NOT NULL COMMENT 'B comment'"]; } @@ -224,7 +225,7 @@ public function getAlterTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { return ["CREATE TABLE test (id INT NOT NULL, data LONGTEXT NOT NULL COMMENT '(DC2Type:array)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB"]; } @@ -232,7 +233,7 @@ public function getCreateTableColumnTypeCommentsSQL() : array /** * @group DBAL-237 */ - public function testChangeIndexWithForeignKeys() : void + public function testChangeIndexWithForeignKeys(): void { $index = new Index('idx', ['col'], false); $unique = new Index('uniq', ['col'], true); @@ -249,7 +250,7 @@ public function testChangeIndexWithForeignKeys() : void /** * @return string[] */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, PRIMARY KEY(`create`)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB']; } @@ -257,7 +258,7 @@ protected function getQuotedColumnInPrimaryKeySQL() : array /** * @return string[] */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return ['CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, INDEX IDX_22660D028FD6E0FB (`create`)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB']; } @@ -265,7 +266,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * @return string[] */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return ['CREATE TABLE test (column1 VARCHAR(255) NOT NULL, INDEX `key` (column1)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB']; } @@ -273,7 +274,7 @@ protected function getQuotedNameInIndexSQL() : array /** * @return string[] */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return [ 'CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, `bar` VARCHAR(255) NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB', @@ -283,7 +284,7 @@ protected function getQuotedColumnInForeignKeySQL() : array ]; } - public function testCreateTableWithFulltextIndex() : void + public function testCreateTableWithFulltextIndex(): void { $table = new Table('fulltext_table'); $table->addOption('engine', 'MyISAM'); @@ -297,7 +298,7 @@ public function testCreateTableWithFulltextIndex() : void self::assertEquals(['CREATE TABLE fulltext_table (text LONGTEXT NOT NULL, FULLTEXT INDEX fulltext_text (text)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = MyISAM'], $sql); } - public function testCreateTableWithSpatialIndex() : void + public function testCreateTableWithSpatialIndex(): void { $table = new Table('spatial_table'); $table->addOption('engine', 'MyISAM'); @@ -311,7 +312,7 @@ public function testCreateTableWithSpatialIndex() : void self::assertEquals(['CREATE TABLE spatial_table (point LONGTEXT NOT NULL, SPATIAL INDEX spatial_text (point)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = MyISAM'], $sql); } - public function testClobTypeDeclarationSQL() : void + public function testClobTypeDeclarationSQL(): void { self::assertEquals('TINYTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 1])); self::assertEquals('TINYTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 255])); @@ -323,7 +324,7 @@ public function testClobTypeDeclarationSQL() : void self::assertEquals('LONGTEXT', $this->platform->getClobTypeDeclarationSQL([])); } - public function testBlobTypeDeclarationSQL() : void + public function testBlobTypeDeclarationSQL(): void { self::assertEquals('TINYBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 1])); self::assertEquals('TINYBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 255])); @@ -338,7 +339,7 @@ public function testBlobTypeDeclarationSQL() : void /** * @group DBAL-400 */ - public function testAlterTableAddPrimaryKey() : void + public function testAlterTableAddPrimaryKey(): void { $table = new Table('alter_table_add_pk'); $table->addColumn('id', 'integer'); @@ -360,7 +361,7 @@ public function testAlterTableAddPrimaryKey() : void /** * @group DBAL-1132 */ - public function testAlterPrimaryKeyWithAutoincrementColumn() : void + public function testAlterPrimaryKeyWithAutoincrementColumn(): void { $table = new Table('alter_primary_key'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -386,7 +387,7 @@ public function testAlterPrimaryKeyWithAutoincrementColumn() : void /** * @group DBAL-464 */ - public function testDropPrimaryKeyWithAutoincrementColumn() : void + public function testDropPrimaryKeyWithAutoincrementColumn(): void { $table = new Table('drop_primary_key'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -411,7 +412,7 @@ public function testDropPrimaryKeyWithAutoincrementColumn() : void /** * @group DBAL-2302 */ - public function testDropNonAutoincrementColumnFromCompositePrimaryKeyWithAutoincrementColumn() : void + public function testDropNonAutoincrementColumnFromCompositePrimaryKeyWithAutoincrementColumn(): void { $table = new Table('tbl'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -438,7 +439,7 @@ public function testDropNonAutoincrementColumnFromCompositePrimaryKeyWithAutoinc /** * @group DBAL-2302 */ - public function testAddNonAutoincrementColumnToPrimaryKeyWithAutoincrementColumn() : void + public function testAddNonAutoincrementColumnToPrimaryKeyWithAutoincrementColumn(): void { $table = new Table('tbl'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -465,7 +466,7 @@ public function testAddNonAutoincrementColumnToPrimaryKeyWithAutoincrementColumn /** * @group DBAL-586 */ - public function testAddAutoIncrementPrimaryKey() : void + public function testAddAutoIncrementPrimaryKey(): void { $keyTable = new Table('foo'); $keyTable->addColumn('id', 'integer', ['autoincrement' => true]); @@ -483,7 +484,7 @@ public function testAddAutoIncrementPrimaryKey() : void self::assertEquals(['ALTER TABLE foo ADD id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)'], $sql); } - public function testNamedPrimaryKey() : void + public function testNamedPrimaryKey(): void { $diff = new TableDiff('mytable'); $diff->changedIndexes['foo_index'] = new Index('foo_index', ['foo'], true, true); @@ -496,7 +497,7 @@ public function testNamedPrimaryKey() : void ], $sql); } - public function testAlterPrimaryKeyWithNewColumn() : void + public function testAlterPrimaryKeyWithNewColumn(): void { $table = new Table('yolo'); $table->addColumn('pkc1', 'integer'); @@ -520,7 +521,7 @@ public function testAlterPrimaryKeyWithNewColumn() : void ); } - public function testInitializesDoctrineTypeMappings() : void + public function testInitializesDoctrineTypeMappings(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('binary')); self::assertSame('binary', $this->platform->getDoctrineTypeMapping('binary')); @@ -529,12 +530,12 @@ public function testInitializesDoctrineTypeMappings() : void self::assertSame('binary', $this->platform->getDoctrineTypeMapping('varbinary')); } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 65535; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('VARBINARY(255)', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('VARBINARY(255)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -551,7 +552,7 @@ public function testReturnsBinaryTypeDeclarationSQL() : void * @expectedDeprecation Binary field length 16777215 is greater than supported by the platform (65535). Reduce the field length or use a BLOB field instead. * @expectedDeprecation Binary field length 16777216 is greater than supported by the platform (65535). Reduce the field length or use a BLOB field instead. */ - public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void + public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL(): void { self::assertSame('MEDIUMBLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 65536])); self::assertSame('MEDIUMBLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 16777215])); @@ -562,7 +563,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void self::assertSame('LONGBLOB', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 16777216])); } - public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines() : void + public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines(): void { $table = new Table('foreign_table'); $table->addColumn('id', 'integer'); @@ -575,7 +576,7 @@ public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines() ['CREATE TABLE foreign_table (id INT NOT NULL, fk_id INT NOT NULL, INDEX IDX_5690FFE2A57719D0 (fk_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = MyISAM'], $this->platform->getCreateTableSQL( $table, - AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS + AbstractPlatform::CREATE_INDEXES | AbstractPlatform::CREATE_FOREIGNKEYS ) ); @@ -589,12 +590,12 @@ public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines() ], $this->platform->getCreateTableSQL( $table, - AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS + AbstractPlatform::CREATE_INDEXES | AbstractPlatform::CREATE_FOREIGNKEYS ) ); } - public function testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines() : void + public function testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines(): void { $table = new Table('foreign_table'); $table->addColumn('id', 'integer'); @@ -639,7 +640,7 @@ public function testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines( * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return [ 'DROP INDEX idx_foo ON mytable', @@ -652,7 +653,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'DROP INDEX `create` ON `table`', @@ -667,7 +668,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return [ 'DROP INDEX idx_foo ON myschema.mytable', @@ -680,7 +681,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'DROP INDEX `create` ON `schema`.`table`', @@ -690,17 +691,17 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array ]; } - protected function getQuotesDropForeignKeySQL() : string + protected function getQuotesDropForeignKeySQL(): string { return 'ALTER TABLE `table` DROP FOREIGN KEY `select`'; } - protected function getQuotesDropConstraintSQL() : string + protected function getQuotesDropConstraintSQL(): string { return 'ALTER TABLE `table` DROP CONSTRAINT `select`'; } - public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : void + public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes(): void { $table = new Table('text_blob_default_value'); $table->addColumn('def_text', 'text', ['default' => 'def']); @@ -727,7 +728,7 @@ public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : v /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return ['ALTER TABLE mytable ' . "CHANGE unquoted1 unquoted INT NOT NULL COMMENT 'Unquoted 1', " . @@ -745,7 +746,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { return ['ALTER TABLE mytable ' . "CHANGE unquoted1 unquoted1 VARCHAR(255) NOT NULL COMMENT 'Unquoted 1', " . @@ -760,7 +761,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -768,7 +769,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return ["ALTER TABLE foo CHANGE bar baz INT DEFAULT 666 NOT NULL COMMENT 'rename test'"]; } @@ -776,7 +777,7 @@ public function getAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'ALTER TABLE `foo` DROP FOREIGN KEY fk1', @@ -791,7 +792,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ "COMMENT ON COLUMN foo.bar IS 'comment'", @@ -800,17 +801,17 @@ protected function getCommentOnColumnSQL() : array ]; } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT `select` UNIQUE (foo)'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return 'INDEX `select` (foo)'; } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'TRUNCATE `select`'; } @@ -818,7 +819,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL() : string /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return ['ALTER TABLE mytable CHANGE name name CHAR(2) NOT NULL']; } @@ -826,7 +827,7 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return [ 'ALTER TABLE mytable DROP FOREIGN KEY fk_foo', @@ -839,7 +840,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : arra /** * {@inheritdoc} */ - public static function getGeneratesDecimalTypeDeclarationSQL() : iterable + public static function getGeneratesDecimalTypeDeclarationSQL(): iterable { return [ [[], 'NUMERIC(10, 0)'], @@ -854,7 +855,7 @@ public static function getGeneratesDecimalTypeDeclarationSQL() : iterable /** * {@inheritdoc} */ - public static function getGeneratesFloatDeclarationSQL() : iterable + public static function getGeneratesFloatDeclarationSQL(): iterable { return [ [[], 'DOUBLE PRECISION'], @@ -869,7 +870,7 @@ public static function getGeneratesFloatDeclarationSQL() : iterable /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -880,7 +881,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInListTableIndexesSQL() : void + public function testQuotesDatabaseNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -891,7 +892,7 @@ public function testQuotesDatabaseNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInListViewsSQL() : void + public function testQuotesDatabaseNameInListViewsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -902,7 +903,7 @@ public function testQuotesDatabaseNameInListViewsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -913,7 +914,7 @@ public function testQuotesTableNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInListTableForeignKeysSQL() : void + public function testQuotesDatabaseNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -924,7 +925,7 @@ public function testQuotesDatabaseNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableColumnsSQL() : void + public function testQuotesTableNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -935,7 +936,7 @@ public function testQuotesTableNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInListTableColumnsSQL() : void + public function testQuotesDatabaseNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -943,7 +944,7 @@ public function testQuotesDatabaseNameInListTableColumnsSQL() : void ); } - public function testListTableForeignKeysSQLEvaluatesDatabase() : void + public function testListTableForeignKeysSQLEvaluatesDatabase(): void { $sql = $this->platform->getListTableForeignKeysSQL('foo'); @@ -955,7 +956,7 @@ public function testListTableForeignKeysSQLEvaluatesDatabase() : void self::assertStringNotContainsString('DATABASE()', $sql); } - public function testColumnCharsetDeclarationSQL() : void + public function testColumnCharsetDeclarationSQL(): void { self::assertSame( 'CHARACTER SET ascii', @@ -963,12 +964,12 @@ public function testColumnCharsetDeclarationSQL() : void ); } - public function testSupportsColumnCollation() : void + public function testSupportsColumnCollation(): void { self::assertTrue($this->platform->supportsColumnCollation()); } - public function testColumnCollationDeclarationSQL() : void + public function testColumnCollationDeclarationSQL(): void { self::assertSame( 'COLLATE `ascii_general_ci`', @@ -976,7 +977,7 @@ public function testColumnCollationDeclarationSQL() : void ); } - public function testGetCreateTableSQLWithColumnCollation() : void + public function testGetCreateTableSQLWithColumnCollation(): void { $table = new Table('foo'); $table->addColumn('no_collation', 'string'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php index c4d5bcdceb9..01a82b875f6 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php @@ -17,6 +17,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\Types\CommentedType; + use function get_class; use function implode; use function sprintf; @@ -27,9 +28,9 @@ abstract class AbstractPlatformTestCase extends DbalTestCase /** @var AbstractPlatform */ protected $platform; - abstract public function createPlatform() : AbstractPlatform; + abstract public function createPlatform(): AbstractPlatform; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createPlatform(); } @@ -37,7 +38,7 @@ protected function setUp() : void /** * @group DDC-1360 */ - public function testQuoteIdentifier() : void + public function testQuoteIdentifier(): void { if ($this->platform->getName() === 'mssql') { $this->markTestSkipped('Not working this way on mssql.'); @@ -52,7 +53,7 @@ public function testQuoteIdentifier() : void /** * @group DDC-1360 */ - public function testQuoteSingleIdentifier() : void + public function testQuoteSingleIdentifier(): void { if ($this->platform->getName() === 'mssql') { $this->markTestSkipped('Not working this way on mssql.'); @@ -68,7 +69,7 @@ public function testQuoteSingleIdentifier() : void * @group DBAL-1029 * @dataProvider getReturnsForeignKeyReferentialActionSQL */ - public function testReturnsForeignKeyReferentialActionSQL(string $action, string $expectedSQL) : void + public function testReturnsForeignKeyReferentialActionSQL(string $action, string $expectedSQL): void { self::assertSame($expectedSQL, $this->platform->getForeignKeyReferentialActionSQL($action)); } @@ -76,7 +77,7 @@ public function testReturnsForeignKeyReferentialActionSQL(string $action, string /** * @return mixed[][] */ - public static function getReturnsForeignKeyReferentialActionSQL() : iterable + public static function getReturnsForeignKeyReferentialActionSQL(): iterable { return [ ['CASCADE', 'CASCADE'], @@ -88,25 +89,25 @@ public static function getReturnsForeignKeyReferentialActionSQL() : iterable ]; } - public function testGetInvalidForeignKeyReferentialActionSQL() : void + public function testGetInvalidForeignKeyReferentialActionSQL(): void { $this->expectException('InvalidArgumentException'); $this->platform->getForeignKeyReferentialActionSQL('unknown'); } - public function testGetUnknownDoctrineMappingType() : void + public function testGetUnknownDoctrineMappingType(): void { $this->expectException(DBALException::class); $this->platform->getDoctrineTypeMapping('foobar'); } - public function testRegisterDoctrineMappingType() : void + public function testRegisterDoctrineMappingType(): void { $this->platform->registerDoctrineTypeMapping('foo', 'integer'); self::assertEquals('integer', $this->platform->getDoctrineTypeMapping('foo')); } - public function testRegisterUnknownDoctrineMappingType() : void + public function testRegisterUnknownDoctrineMappingType(): void { $this->expectException(DBALException::class); $this->platform->registerDoctrineTypeMapping('foo', 'bar'); @@ -115,7 +116,7 @@ public function testRegisterUnknownDoctrineMappingType() : void /** * @group DBAL-2594 */ - public function testRegistersCommentedDoctrineMappingTypeImplicitly() : void + public function testRegistersCommentedDoctrineMappingTypeImplicitly(): void { if (! Type::hasType('my_commented')) { Type::addType('my_commented', CommentedType::class); @@ -131,7 +132,7 @@ public function testRegistersCommentedDoctrineMappingTypeImplicitly() : void * @group DBAL-939 * @dataProvider getIsCommentedDoctrineType */ - public function testIsCommentedDoctrineType(Type $type, bool $commented) : void + public function testIsCommentedDoctrineType(Type $type, bool $commented): void { self::assertSame($commented, $this->platform->isCommentedDoctrineType($type)); } @@ -139,7 +140,7 @@ public function testIsCommentedDoctrineType(Type $type, bool $commented) : void /** * @return mixed[] */ - public function getIsCommentedDoctrineType() : iterable + public function getIsCommentedDoctrineType(): iterable { $this->setUp(); @@ -157,7 +158,7 @@ public function getIsCommentedDoctrineType() : iterable return $data; } - public function testCreateWithNoColumns() : void + public function testCreateWithNoColumns(): void { $table = new Table('test'); @@ -165,7 +166,7 @@ public function testCreateWithNoColumns() : void $sql = $this->platform->getCreateTableSQL($table); } - public function testGeneratesTableCreationSql() : void + public function testGeneratesTableCreationSql(): void { $table = new Table('test'); $table->addColumn('id', 'integer', ['notnull' => true, 'autoincrement' => true]); @@ -176,9 +177,9 @@ public function testGeneratesTableCreationSql() : void self::assertEquals($this->getGenerateTableSql(), $sql[0]); } - abstract public function getGenerateTableSql() : string; + abstract public function getGenerateTableSql(): string; - public function testGenerateTableWithMultiColumnUniqueIndex() : void + public function testGenerateTableWithMultiColumnUniqueIndex(): void { $table = new Table('test'); $table->addColumn('foo', 'string', ['notnull' => false, 'length' => 255]); @@ -192,9 +193,9 @@ public function testGenerateTableWithMultiColumnUniqueIndex() : void /** * @return string[] */ - abstract public function getGenerateTableWithMultiColumnUniqueIndexSql() : array; + abstract public function getGenerateTableWithMultiColumnUniqueIndexSql(): array; - public function testGeneratesIndexCreationSql() : void + public function testGeneratesIndexCreationSql(): void { $indexDef = new Index('my_idx', ['user_name', 'last_login']); @@ -204,9 +205,9 @@ public function testGeneratesIndexCreationSql() : void ); } - abstract public function getGenerateIndexSql() : string; + abstract public function getGenerateIndexSql(): string; - public function testGeneratesUniqueIndexCreationSql() : void + public function testGeneratesUniqueIndexCreationSql(): void { $indexDef = new Index('index_name', ['test', 'test2'], true); @@ -214,9 +215,9 @@ public function testGeneratesUniqueIndexCreationSql() : void self::assertEquals($this->getGenerateUniqueIndexSql(), $sql); } - abstract public function getGenerateUniqueIndexSql() : string; + abstract public function getGenerateUniqueIndexSql(): string; - public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes() : void + public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes(): void { $where = 'test IS NULL AND test2 IS NOT NULL'; $indexDef = new Index('name', ['test', 'test2'], false, false, [], ['where' => $where]); @@ -242,7 +243,7 @@ public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes() } } - public function testGeneratesForeignKeyCreationSql() : void + public function testGeneratesForeignKeyCreationSql(): void { $fk = new ForeignKeyConstraint(['fk_name_id'], 'other_table', ['id'], ''); @@ -250,9 +251,9 @@ public function testGeneratesForeignKeyCreationSql() : void self::assertEquals($sql, $this->getGenerateForeignKeySql()); } - abstract protected function getGenerateForeignKeySql() : string; + abstract protected function getGenerateForeignKeySql(): string; - public function testGeneratesConstraintCreationSql() : void + public function testGeneratesConstraintCreationSql(): void { if (! $this->platform->supportsCreateDropForeignKeyConstraints()) { $this->markTestSkipped('Platform does not support creating or dropping foreign key constraints.'); @@ -271,7 +272,7 @@ public function testGeneratesConstraintCreationSql() : void self::assertEquals($this->getGenerateConstraintForeignKeySql($fk), $sql); } - protected function getBitAndComparisonExpressionSql(string $value1, string $value2) : string + protected function getBitAndComparisonExpressionSql(string $value1, string $value2): string { return '(' . $value1 . ' & ' . $value2 . ')'; } @@ -279,13 +280,13 @@ protected function getBitAndComparisonExpressionSql(string $value1, string $valu /** * @group DDC-1213 */ - public function testGeneratesBitAndComparisonExpressionSql() : void + public function testGeneratesBitAndComparisonExpressionSql(): void { $sql = $this->platform->getBitAndComparisonExpression(2, 4); self::assertEquals($this->getBitAndComparisonExpressionSql(2, 4), $sql); } - protected function getBitOrComparisonExpressionSql(string $value1, string $value2) : string + protected function getBitOrComparisonExpressionSql(string $value1, string $value2): string { return '(' . $value1 . ' | ' . $value2 . ')'; } @@ -293,23 +294,23 @@ protected function getBitOrComparisonExpressionSql(string $value1, string $value /** * @group DDC-1213 */ - public function testGeneratesBitOrComparisonExpressionSql() : void + public function testGeneratesBitOrComparisonExpressionSql(): void { $sql = $this->platform->getBitOrComparisonExpression(2, 4); self::assertEquals($this->getBitOrComparisonExpressionSql(2, 4), $sql); } - public function getGenerateConstraintUniqueIndexSql() : string + public function getGenerateConstraintUniqueIndexSql(): string { return 'ALTER TABLE test ADD CONSTRAINT constraint_name UNIQUE (test)'; } - public function getGenerateConstraintPrimaryIndexSql() : string + public function getGenerateConstraintPrimaryIndexSql(): string { return 'ALTER TABLE test ADD CONSTRAINT constraint_name PRIMARY KEY (test)'; } - public function getGenerateConstraintForeignKeySql(ForeignKeyConstraint $fk) : string + public function getGenerateConstraintForeignKeySql(ForeignKeyConstraint $fk): string { $quotedForeignTable = $fk->getQuotedForeignTableName($this->platform); @@ -322,9 +323,9 @@ public function getGenerateConstraintForeignKeySql(ForeignKeyConstraint $fk) : s /** * @return string[] */ - abstract public function getGenerateAlterTableSql() : array; + abstract public function getGenerateAlterTableSql(): array; - public function testGeneratesTableAlterationSql() : void + public function testGeneratesTableAlterationSql(): void { $expectedSql = $this->getGenerateAlterTableSql(); @@ -364,13 +365,13 @@ public function testGeneratesTableAlterationSql() : void self::assertEquals($expectedSql, $sql); } - public function testGetCustomColumnDeclarationSql() : void + public function testGetCustomColumnDeclarationSql(): void { $field = ['columnDefinition' => 'MEDIUMINT(6) UNSIGNED']; self::assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->platform->getColumnDeclarationSQL('foo', $field)); } - public function testGetCreateTableSqlDispatchEvent() : void + public function testGetCreateTableSqlDispatchEvent(): void { $listenerMock = $this->createMock(GetCreateTableSqlDispatchEventListener::class); $listenerMock @@ -392,7 +393,7 @@ public function testGetCreateTableSqlDispatchEvent() : void $this->platform->getCreateTableSQL($table); } - public function testGetDropTableSqlDispatchEvent() : void + public function testGetDropTableSqlDispatchEvent(): void { $listenerMock = $this->createMock(GetDropTableSqlDispatchEventListener::class); $listenerMock @@ -407,7 +408,7 @@ public function testGetDropTableSqlDispatchEvent() : void $this->platform->getDropTableSQL('TABLE'); } - public function testGetAlterTableSqlDispatchEvent() : void + public function testGetAlterTableSqlDispatchEvent(): void { $listenerMock = $this->createMock(GetAlterTableSqlDispatchEventListener::class); $listenerMock @@ -464,7 +465,7 @@ public function testGetAlterTableSqlDispatchEvent() : void /** * @group DBAL-42 */ - public function testCreateTableColumnComments() : void + public function testCreateTableColumnComments(): void { $table = new Table('test'); $table->addColumn('id', 'integer', ['comment' => 'This is a comment']); @@ -476,7 +477,7 @@ public function testCreateTableColumnComments() : void /** * @group DBAL-42 */ - public function testAlterTableColumnComments() : void + public function testAlterTableColumnComments(): void { $tableDiff = new TableDiff('mytable'); $tableDiff->addedColumns['quota'] = new Column('quota', Type::getType('integer'), ['comment' => 'A comment']); @@ -501,7 +502,7 @@ public function testAlterTableColumnComments() : void self::assertEquals($this->getAlterTableColumnCommentsSQL(), $this->platform->getAlterTableSQL($tableDiff)); } - public function testCreateTableColumnTypeComments() : void + public function testCreateTableColumnTypeComments(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -514,7 +515,7 @@ public function testCreateTableColumnTypeComments() : void /** * @return string[] */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { $this->markTestSkipped('Platform does not support Column comments.'); } @@ -522,7 +523,7 @@ public function getCreateTableColumnCommentsSQL() : array /** * @return string[] */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { $this->markTestSkipped('Platform does not support Column comments.'); } @@ -530,12 +531,12 @@ public function getAlterTableColumnCommentsSQL() : array /** * @return string[] */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { $this->markTestSkipped('Platform does not support Column comments.'); } - public function testGetDefaultValueDeclarationSQL() : void + public function testGetDefaultValueDeclarationSQL(): void { // non-timestamp value will get single quotes $field = [ @@ -549,7 +550,7 @@ public function testGetDefaultValueDeclarationSQL() : void /** * @group 2859 */ - public function testGetDefaultValueDeclarationSQLDateTime() : void + public function testGetDefaultValueDeclarationSQLDateTime(): void { // timestamps on datetime types should not be quoted foreach (['datetime', 'datetimetz', 'datetime_immutable', 'datetimetz_immutable'] as $type) { @@ -565,7 +566,7 @@ public function testGetDefaultValueDeclarationSQLDateTime() : void } } - public function testGetDefaultValueDeclarationSQLForIntegerTypes() : void + public function testGetDefaultValueDeclarationSQLForIntegerTypes(): void { foreach (['bigint', 'integer', 'smallint'] as $type) { $field = [ @@ -583,7 +584,7 @@ public function testGetDefaultValueDeclarationSQLForIntegerTypes() : void /** * @group 2859 */ - public function testGetDefaultValueDeclarationSQLForDateType() : void + public function testGetDefaultValueDeclarationSQLForDateType(): void { $currentDateSql = $this->platform->getCurrentDateSQL(); foreach (['date', 'date_immutable'] as $type) { @@ -602,7 +603,7 @@ public function testGetDefaultValueDeclarationSQLForDateType() : void /** * @group DBAL-45 */ - public function testKeywordList() : void + public function testKeywordList(): void { $keywordList = $this->platform->getReservedKeywordsList(); self::assertInstanceOf(KeywordList::class, $keywordList); @@ -613,7 +614,7 @@ public function testKeywordList() : void /** * @group DBAL-374 */ - public function testQuotedColumnInPrimaryKeyPropagation() : void + public function testQuotedColumnInPrimaryKeyPropagation(): void { $table = new Table('`quoted`'); $table->addColumn('create', 'string'); @@ -626,27 +627,27 @@ public function testQuotedColumnInPrimaryKeyPropagation() : void /** * @return string[] */ - abstract protected function getQuotedColumnInPrimaryKeySQL() : array; + abstract protected function getQuotedColumnInPrimaryKeySQL(): array; /** * @return string[] */ - abstract protected function getQuotedColumnInIndexSQL() : array; + abstract protected function getQuotedColumnInIndexSQL(): array; /** * @return string[] */ - abstract protected function getQuotedNameInIndexSQL() : array; + abstract protected function getQuotedNameInIndexSQL(): array; /** * @return string[] */ - abstract protected function getQuotedColumnInForeignKeySQL() : array; + abstract protected function getQuotedColumnInForeignKeySQL(): array; /** * @group DBAL-374 */ - public function testQuotedColumnInIndexPropagation() : void + public function testQuotedColumnInIndexPropagation(): void { $table = new Table('`quoted`'); $table->addColumn('create', 'string'); @@ -656,7 +657,7 @@ public function testQuotedColumnInIndexPropagation() : void self::assertEquals($this->getQuotedColumnInIndexSQL(), $sql); } - public function testQuotedNameInIndexSQL() : void + public function testQuotedNameInIndexSQL(): void { $table = new Table('test'); $table->addColumn('column1', 'string'); @@ -669,7 +670,7 @@ public function testQuotedNameInIndexSQL() : void /** * @group DBAL-374 */ - public function testQuotedColumnInForeignKeyPropagation() : void + public function testQuotedColumnInForeignKeyPropagation(): void { $table = new Table('`quoted`'); $table->addColumn('create', 'string'); @@ -707,7 +708,7 @@ public function testQuotedColumnInForeignKeyPropagation() : void /** * @group DBAL-1051 */ - public function testQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : void + public function testQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): void { $index = new Index('select', ['foo'], true); @@ -717,12 +718,12 @@ public function testQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : vo ); } - abstract protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string; + abstract protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string; /** * @group DBAL-2270 */ - public function testQuotesReservedKeywordInTruncateTableSQL() : void + public function testQuotesReservedKeywordInTruncateTableSQL(): void { self::assertSame( $this->getQuotesReservedKeywordInTruncateTableSQL(), @@ -730,12 +731,12 @@ public function testQuotesReservedKeywordInTruncateTableSQL() : void ); } - abstract protected function getQuotesReservedKeywordInTruncateTableSQL() : string; + abstract protected function getQuotesReservedKeywordInTruncateTableSQL(): string; /** * @group DBAL-1051 */ - public function testQuotesReservedKeywordInIndexDeclarationSQL() : void + public function testQuotesReservedKeywordInIndexDeclarationSQL(): void { $index = new Index('select', ['foo']); @@ -749,24 +750,24 @@ public function testQuotesReservedKeywordInIndexDeclarationSQL() : void ); } - abstract protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string; + abstract protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string; - protected function supportsInlineIndexDeclaration() : bool + protected function supportsInlineIndexDeclaration(): bool { return true; } - public function testSupportsCommentOnStatement() : void + public function testSupportsCommentOnStatement(): void { self::assertSame($this->supportsCommentOnStatement(), $this->platform->supportsCommentOnStatement()); } - protected function supportsCommentOnStatement() : bool + protected function supportsCommentOnStatement(): bool { return false; } - public function testGetCreateSchemaSQL() : void + public function testGetCreateSchemaSQL(): void { $this->expectException(DBALException::class); @@ -776,7 +777,7 @@ public function testGetCreateSchemaSQL() : void /** * @group DBAL-585 */ - public function testAlterTableChangeQuotedColumn() : void + public function testAlterTableChangeQuotedColumn(): void { $tableDiff = new TableDiff('mytable'); $tableDiff->fromTable = new Table('mytable'); @@ -798,7 +799,7 @@ public function testAlterTableChangeQuotedColumn() : void /** * @group DBAL-563 */ - public function testUsesSequenceEmulatedIdentityColumns() : void + public function testUsesSequenceEmulatedIdentityColumns(): void { self::assertFalse($this->platform->usesSequenceEmulatedIdentityColumns()); } @@ -806,41 +807,41 @@ public function testUsesSequenceEmulatedIdentityColumns() : void /** * @group DBAL-563 */ - public function testReturnsIdentitySequenceName() : void + public function testReturnsIdentitySequenceName(): void { $this->expectException(DBALException::class); $this->platform->getIdentitySequenceName('mytable', 'mycolumn'); } - public function testReturnsBinaryDefaultLength() : void + public function testReturnsBinaryDefaultLength(): void { self::assertSame($this->getBinaryDefaultLength(), $this->platform->getBinaryDefaultLength()); } - protected function getBinaryDefaultLength() : int + protected function getBinaryDefaultLength(): int { return 255; } - public function testReturnsBinaryMaxLength() : void + public function testReturnsBinaryMaxLength(): void { self::assertSame($this->getBinaryMaxLength(), $this->platform->getBinaryMaxLength()); } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 4000; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { $this->expectException(DBALException::class); $this->platform->getBinaryTypeDeclarationSQL([]); } - public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void + public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL(): void { $this->markTestSkipped('Not applicable to the platform'); } @@ -848,7 +849,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void /** * @group DBAL-553 */ - public function hasNativeJsonType() : void + public function hasNativeJsonType(): void { self::assertFalse($this->platform->hasNativeJsonType()); } @@ -856,7 +857,7 @@ public function hasNativeJsonType() : void /** * @group DBAL-553 */ - public function testReturnsJsonTypeDeclarationSQL() : void + public function testReturnsJsonTypeDeclarationSQL(): void { $column = [ 'length' => 666, @@ -873,7 +874,7 @@ public function testReturnsJsonTypeDeclarationSQL() : void /** * @group DBAL-234 */ - public function testAlterTableRenameIndex() : void + public function testAlterTableRenameIndex(): void { $tableDiff = new TableDiff('mytable'); $tableDiff->fromTable = new Table('mytable'); @@ -894,7 +895,7 @@ public function testAlterTableRenameIndex() : void * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return [ 'DROP INDEX idx_foo', @@ -905,7 +906,7 @@ protected function getAlterTableRenameIndexSQL() : array /** * @group DBAL-234 */ - public function testQuotesAlterTableRenameIndex() : void + public function testQuotesAlterTableRenameIndex(): void { $tableDiff = new TableDiff('table'); $tableDiff->fromTable = new Table('table'); @@ -927,7 +928,7 @@ public function testQuotesAlterTableRenameIndex() : void * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'DROP INDEX "create"', @@ -940,7 +941,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array /** * @group DBAL-835 */ - public function testQuotesAlterTableRenameColumn() : void + public function testQuotesAlterTableRenameColumn(): void { $fromTable = new Table('mytable'); @@ -985,12 +986,12 @@ public function testQuotesAlterTableRenameColumn() : void * * @group DBAL-835 */ - abstract protected function getQuotedAlterTableRenameColumnSQL() : array; + abstract protected function getQuotedAlterTableRenameColumnSQL(): array; /** * @group DBAL-835 */ - public function testQuotesAlterTableChangeColumnLength() : void + public function testQuotesAlterTableChangeColumnLength(): void { $fromTable = new Table('mytable'); @@ -1027,12 +1028,12 @@ public function testQuotesAlterTableChangeColumnLength() : void * * @group DBAL-835 */ - abstract protected function getQuotedAlterTableChangeColumnLengthSQL() : array; + abstract protected function getQuotedAlterTableChangeColumnLengthSQL(): array; /** * @group DBAL-807 */ - public function testAlterTableRenameIndexInSchema() : void + public function testAlterTableRenameIndexInSchema(): void { $tableDiff = new TableDiff('myschema.mytable'); $tableDiff->fromTable = new Table('myschema.mytable'); @@ -1053,7 +1054,7 @@ public function testAlterTableRenameIndexInSchema() : void * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return [ 'DROP INDEX idx_foo', @@ -1064,7 +1065,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array /** * @group DBAL-807 */ - public function testQuotesAlterTableRenameIndexInSchema() : void + public function testQuotesAlterTableRenameIndexInSchema(): void { $tableDiff = new TableDiff('`schema`.table'); $tableDiff->fromTable = new Table('`schema`.table'); @@ -1086,7 +1087,7 @@ public function testQuotesAlterTableRenameIndexInSchema() : void * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'DROP INDEX "schema"."create"', @@ -1099,7 +1100,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array /** * @group DBAL-1237 */ - public function testQuotesDropForeignKeySQL() : void + public function testQuotesDropForeignKeySQL(): void { if (! $this->platform->supportsCreateDropForeignKeyConstraints()) { $this->markTestSkipped( @@ -1117,7 +1118,7 @@ public function testQuotesDropForeignKeySQL() : void self::assertSame($expectedSql, $this->platform->getDropForeignKeySQL($foreignKey, $table)); } - protected function getQuotesDropForeignKeySQL() : string + protected function getQuotesDropForeignKeySQL(): string { return 'ALTER TABLE "table" DROP FOREIGN KEY "select"'; } @@ -1125,7 +1126,7 @@ protected function getQuotesDropForeignKeySQL() : string /** * @group DBAL-1237 */ - public function testQuotesDropConstraintSQL() : void + public function testQuotesDropConstraintSQL(): void { $tableName = 'table'; $table = new Table($tableName); @@ -1137,27 +1138,27 @@ public function testQuotesDropConstraintSQL() : void self::assertSame($expectedSql, $this->platform->getDropConstraintSQL($constraint, $table)); } - protected function getQuotesDropConstraintSQL() : string + protected function getQuotesDropConstraintSQL(): string { return 'ALTER TABLE "table" DROP CONSTRAINT "select"'; } - protected function getStringLiteralQuoteCharacter() : string + protected function getStringLiteralQuoteCharacter(): string { return "'"; } - public function testGetStringLiteralQuoteCharacter() : void + public function testGetStringLiteralQuoteCharacter(): void { self::assertSame($this->getStringLiteralQuoteCharacter(), $this->platform->getStringLiteralQuoteCharacter()); } - protected function getQuotedCommentOnColumnSQLWithoutQuoteCharacter() : string + protected function getQuotedCommentOnColumnSQLWithoutQuoteCharacter(): string { return "COMMENT ON COLUMN mytable.id IS 'This is a comment'"; } - public function testGetCommentOnColumnSQLWithoutQuoteCharacter() : void + public function testGetCommentOnColumnSQLWithoutQuoteCharacter(): void { self::assertEquals( $this->getQuotedCommentOnColumnSQLWithoutQuoteCharacter(), @@ -1165,12 +1166,12 @@ public function testGetCommentOnColumnSQLWithoutQuoteCharacter() : void ); } - protected function getQuotedCommentOnColumnSQLWithQuoteCharacter() : string + protected function getQuotedCommentOnColumnSQLWithQuoteCharacter(): string { return "COMMENT ON COLUMN mytable.id IS 'It''s a quote !'"; } - public function testGetCommentOnColumnSQLWithQuoteCharacter() : void + public function testGetCommentOnColumnSQLWithQuoteCharacter(): void { $c = $this->getStringLiteralQuoteCharacter(); @@ -1185,12 +1186,12 @@ public function testGetCommentOnColumnSQLWithQuoteCharacter() : void * * @return string[] */ - abstract protected function getCommentOnColumnSQL() : array; + abstract protected function getCommentOnColumnSQL(): array; /** * @group DBAL-1004 */ - public function testGetCommentOnColumnSQL() : void + public function testGetCommentOnColumnSQL(): void { self::assertSame( $this->getCommentOnColumnSQL(), @@ -1206,7 +1207,7 @@ public function testGetCommentOnColumnSQL() : void * @group DBAL-1176 * @dataProvider getGeneratesInlineColumnCommentSQL */ - public function testGeneratesInlineColumnCommentSQL(?string $comment, string $expectedSql) : void + public function testGeneratesInlineColumnCommentSQL(?string $comment, string $expectedSql): void { if (! $this->platform->supportsInlineColumnComments()) { $this->markTestSkipped(sprintf('%s does not support inline column comments.', get_class($this->platform))); @@ -1218,7 +1219,7 @@ public function testGeneratesInlineColumnCommentSQL(?string $comment, string $ex /** * @return mixed[][] */ - public static function getGeneratesInlineColumnCommentSQL() : iterable + public static function getGeneratesInlineColumnCommentSQL(): iterable { return [ 'regular comment' => ['Regular comment', static::getInlineColumnRegularCommentSQL()], @@ -1233,37 +1234,37 @@ public static function getGeneratesInlineColumnCommentSQL() : iterable ]; } - protected static function getInlineColumnCommentDelimiter() : string + protected static function getInlineColumnCommentDelimiter(): string { return "'"; } - protected static function getInlineColumnRegularCommentSQL() : string + protected static function getInlineColumnRegularCommentSQL(): string { return "COMMENT 'Regular comment'"; } - protected static function getInlineColumnCommentRequiringEscapingSQL() : string + protected static function getInlineColumnCommentRequiringEscapingSQL(): string { return "COMMENT 'Using inline comment delimiter '' works'"; } - protected static function getInlineColumnEmptyCommentSQL() : string + protected static function getInlineColumnEmptyCommentSQL(): string { return "COMMENT ''"; } - protected function getQuotedStringLiteralWithoutQuoteCharacter() : string + protected function getQuotedStringLiteralWithoutQuoteCharacter(): string { return "'No quote'"; } - protected function getQuotedStringLiteralWithQuoteCharacter() : string + protected function getQuotedStringLiteralWithQuoteCharacter(): string { return "'It''s a quote'"; } - protected function getQuotedStringLiteralQuoteCharacter() : string + protected function getQuotedStringLiteralQuoteCharacter(): string { return "''''"; } @@ -1271,7 +1272,7 @@ protected function getQuotedStringLiteralQuoteCharacter() : string /** * @group DBAL-1176 */ - public function testThrowsExceptionOnGeneratingInlineColumnCommentSQLIfUnsupported() : void + public function testThrowsExceptionOnGeneratingInlineColumnCommentSQLIfUnsupported(): void { if ($this->platform->supportsInlineColumnComments()) { $this->markTestSkipped(sprintf('%s supports inline column comments.', get_class($this->platform))); @@ -1284,7 +1285,7 @@ public function testThrowsExceptionOnGeneratingInlineColumnCommentSQLIfUnsupport $this->platform->getInlineColumnCommentSQL('unsupported'); } - public function testQuoteStringLiteral() : void + public function testQuoteStringLiteral(): void { $c = $this->getStringLiteralQuoteCharacter(); @@ -1305,7 +1306,7 @@ public function testQuoteStringLiteral() : void /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { $this->expectException(DBALException::class); @@ -1315,7 +1316,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * @group DBAL-1010 */ - public function testGeneratesAlterTableRenameColumnSQL() : void + public function testGeneratesAlterTableRenameColumnSQL(): void { $table = new Table('foo'); $table->addColumn( @@ -1338,12 +1339,12 @@ public function testGeneratesAlterTableRenameColumnSQL() : void /** * @return string[] */ - abstract public function getAlterTableRenameColumnSQL() : array; + abstract public function getAlterTableRenameColumnSQL(): array; /** * @group DBAL-1016 */ - public function testQuotesTableIdentifiersInAlterTableSQL() : void + public function testQuotesTableIdentifiersInAlterTableSQL(): void { $table = new Table('"foo"'); $table->addColumn('id', 'integer'); @@ -1380,12 +1381,12 @@ public function testQuotesTableIdentifiersInAlterTableSQL() : void /** * @return string[] */ - abstract protected function getQuotesTableIdentifiersInAlterTableSQL() : array; + abstract protected function getQuotesTableIdentifiersInAlterTableSQL(): array; /** * @group DBAL-1090 */ - public function testAlterStringToFixedString() : void + public function testAlterStringToFixedString(): void { $table = new Table('mytable'); $table->addColumn('name', 'string', ['length' => 2]); @@ -1413,12 +1414,12 @@ public function testAlterStringToFixedString() : void /** * @return string[] */ - abstract protected function getAlterStringToFixedStringSQL() : array; + abstract protected function getAlterStringToFixedStringSQL(): array; /** * @group DBAL-1062 */ - public function testGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : void + public function testGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): void { $foreignTable = new Table('foreign_table'); $foreignTable->addColumn('id', 'integer'); @@ -1446,7 +1447,7 @@ public function testGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : void /** * @return string[] */ - abstract protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array; + abstract protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array; /** * @param mixed[] $column @@ -1454,7 +1455,7 @@ abstract protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL * @group DBAL-1082 * @dataProvider getGeneratesDecimalTypeDeclarationSQL */ - public function testGeneratesDecimalTypeDeclarationSQL(array $column, string $expectedSql) : void + public function testGeneratesDecimalTypeDeclarationSQL(array $column, string $expectedSql): void { self::assertSame($expectedSql, $this->platform->getDecimalTypeDeclarationSQL($column)); } @@ -1462,7 +1463,7 @@ public function testGeneratesDecimalTypeDeclarationSQL(array $column, string $ex /** * @return mixed[][] */ - public static function getGeneratesDecimalTypeDeclarationSQL() : iterable + public static function getGeneratesDecimalTypeDeclarationSQL(): iterable { return [ [[], 'NUMERIC(10, 0)'], @@ -1480,7 +1481,7 @@ public static function getGeneratesDecimalTypeDeclarationSQL() : iterable * @group DBAL-1082 * @dataProvider getGeneratesFloatDeclarationSQL */ - public function testGeneratesFloatDeclarationSQL(array $column, string $expectedSql) : void + public function testGeneratesFloatDeclarationSQL(array $column, string $expectedSql): void { self::assertSame($expectedSql, $this->platform->getFloatDeclarationSQL($column)); } @@ -1488,7 +1489,7 @@ public function testGeneratesFloatDeclarationSQL(array $column, string $expected /** * @return mixed[][] */ - public static function getGeneratesFloatDeclarationSQL() : iterable + public static function getGeneratesFloatDeclarationSQL(): iterable { return [ [[], 'DOUBLE PRECISION'], @@ -1500,7 +1501,7 @@ public static function getGeneratesFloatDeclarationSQL() : iterable ]; } - public function testItEscapesStringsForLike() : void + public function testItEscapesStringsForLike(): void { self::assertSame( '\_25\% off\_ your next purchase \\\\o/', @@ -1508,7 +1509,7 @@ public function testItEscapesStringsForLike() : void ); } - public function testZeroOffsetWithoutLimitIsIgnored() : void + public function testZeroOffsetWithoutLimitIsIgnored(): void { $query = 'SELECT * FROM user'; @@ -1521,25 +1522,25 @@ public function testZeroOffsetWithoutLimitIsIgnored() : void interface GetCreateTableSqlDispatchEventListener { - public function onSchemaCreateTable() : void; + public function onSchemaCreateTable(): void; - public function onSchemaCreateTableColumn() : void; + public function onSchemaCreateTableColumn(): void; } interface GetAlterTableSqlDispatchEventListener { - public function onSchemaAlterTable() : void; + public function onSchemaAlterTable(): void; - public function onSchemaAlterTableAddColumn() : void; + public function onSchemaAlterTableAddColumn(): void; - public function onSchemaAlterTableRemoveColumn() : void; + public function onSchemaAlterTableRemoveColumn(): void; - public function onSchemaAlterTableChangeColumn() : void; + public function onSchemaAlterTableChangeColumn(): void; - public function onSchemaAlterTableRenameColumn() : void; + public function onSchemaAlterTableRenameColumn(): void; } interface GetDropTableSqlDispatchEventListener { - public function onSchemaDropTable() : void; + public function onSchemaDropTable(): void; } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php index 4e0606da55e..b97ac6ee65f 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\Type; use UnexpectedValueException; + use function sprintf; abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCase @@ -24,9 +25,9 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa /** * @return PostgreSqlPlatform */ - abstract public function createPlatform() : AbstractPlatform; + abstract public function createPlatform(): AbstractPlatform; - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id SERIAL NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'; } @@ -34,7 +35,7 @@ public function getGenerateTableSql() : string /** * {@inheritDoc} */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return [ 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)', @@ -45,7 +46,7 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return [ 'ALTER TABLE mytable ADD quota INT DEFAULT NULL', @@ -60,17 +61,17 @@ public function getGenerateAlterTableSql() : array ]; } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - protected function getGenerateForeignKeySql() : string + protected function getGenerateForeignKeySql(): string { return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id) NOT DEFERRABLE INITIALLY IMMEDIATE'; } - public function testGeneratesForeignKeySqlForNonStandardOptions() : void + public function testGeneratesForeignKeySqlForNonStandardOptions(): void { $foreignKey = new ForeignKeyConstraint( ['foreign_id'], @@ -145,7 +146,7 @@ public function testGeneratesForeignKeySqlForNonStandardOptions() : void ); } - public function testGeneratesSqlSnippets() : void + public function testGeneratesSqlSnippets(): void { self::assertEquals('SIMILAR TO', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct'); self::assertEquals('"', $this->platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); @@ -154,7 +155,7 @@ public function testGeneratesSqlSnippets() : void self::assertEquals('SUBSTRING(column FROM 1 FOR 5)', $this->platform->getSubstringExpression('column', 1, 5), 'Substring expression with length is not correct'); } - public function testGeneratesTransactionCommands() : void + public function testGeneratesTransactionCommands(): void { self::assertEquals( 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', @@ -174,14 +175,14 @@ public function testGeneratesTransactionCommands() : void ); } - public function testGeneratesDDLSnippets() : void + public function testGeneratesDDLSnippets(): void { self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar')); self::assertEquals('DROP DATABASE foobar', $this->platform->getDropDatabaseSQL('foobar')); self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar')); } - public function testGenerateTableWithAutoincrement() : void + public function testGenerateTableWithAutoincrement(): void { $table = new Table('autoinc_table'); $column = $table->addColumn('id', 'integer'); @@ -193,7 +194,7 @@ public function testGenerateTableWithAutoincrement() : void /** * @return mixed[][] */ - public static function serialTypes() : iterable + public static function serialTypes(): iterable { return [ ['integer', 'SERIAL'], @@ -205,7 +206,7 @@ public static function serialTypes() : iterable * @dataProvider serialTypes * @group 2906 */ - public function testGenerateTableWithAutoincrementDoesNotSetDefault(string $type, string $definition) : void + public function testGenerateTableWithAutoincrementDoesNotSetDefault(string $type, string $definition): void { $table = new Table('autoinc_table_notnull'); $column = $table->addColumn('id', $type); @@ -221,7 +222,7 @@ public function testGenerateTableWithAutoincrementDoesNotSetDefault(string $type * @dataProvider serialTypes * @group 2906 */ - public function testCreateTableWithAutoincrementAndNotNullAddsConstraint(string $type, string $definition) : void + public function testCreateTableWithAutoincrementAndNotNullAddsConstraint(string $type, string $definition): void { $table = new Table('autoinc_table_notnull_enabled'); $column = $table->addColumn('id', $type); @@ -237,7 +238,7 @@ public function testCreateTableWithAutoincrementAndNotNullAddsConstraint(string * @dataProvider serialTypes * @group 2906 */ - public function testGetDefaultValueDeclarationSQLIgnoresTheDefaultKeyWhenTheFieldIsSerial(string $type) : void + public function testGetDefaultValueDeclarationSQLIgnoresTheDefaultKeyWhenTheFieldIsSerial(string $type): void { $sql = $this->platform->getDefaultValueDeclarationSQL( [ @@ -250,7 +251,7 @@ public function testGetDefaultValueDeclarationSQLIgnoresTheDefaultKeyWhenTheFiel self::assertSame('', $sql); } - public function testGeneratesTypeDeclarationForIntegers() : void + public function testGeneratesTypeDeclarationForIntegers(): void { self::assertEquals( 'INT', @@ -268,7 +269,7 @@ public function testGeneratesTypeDeclarationForIntegers() : void ); } - public function testGeneratesTypeDeclarationForStrings() : void + public function testGeneratesTypeDeclarationForStrings(): void { self::assertEquals( 'CHAR(10)', @@ -288,12 +289,12 @@ public function testGeneratesTypeDeclarationForStrings() : void ); } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } - public function testGeneratesSequenceSqlCommands() : void + public function testGeneratesSequenceSqlCommands(): void { $sequence = new Sequence('myseq', 20, 1); self::assertEquals( @@ -310,43 +311,43 @@ public function testGeneratesSequenceSqlCommands() : void ); } - public function testDoesNotPreferIdentityColumns() : void + public function testDoesNotPreferIdentityColumns(): void { self::assertFalse($this->platform->prefersIdentityColumns()); } - public function testPrefersSequences() : void + public function testPrefersSequences(): void { self::assertTrue($this->platform->prefersSequences()); } - public function testSupportsIdentityColumns() : void + public function testSupportsIdentityColumns(): void { self::assertTrue($this->platform->supportsIdentityColumns()); } - public function testSupportsSavePoints() : void + public function testSupportsSavePoints(): void { self::assertTrue($this->platform->supportsSavepoints()); } - public function testSupportsSequences() : void + public function testSupportsSequences(): void { self::assertTrue($this->platform->supportsSequences()); } - protected function supportsCommentOnStatement() : bool + protected function supportsCommentOnStatement(): bool { return true; } - public function testModifyLimitQuery() : void + public function testModifyLimitQuery(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0); self::assertEquals('SELECT * FROM user LIMIT 10', $sql); } - public function testModifyLimitQueryWithEmptyOffset() : void + public function testModifyLimitQueryWithEmptyOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10); self::assertEquals('SELECT * FROM user LIMIT 10', $sql); @@ -355,7 +356,7 @@ public function testModifyLimitQueryWithEmptyOffset() : void /** * {@inheritDoc} */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { return [ 'CREATE TABLE test (id INT NOT NULL, PRIMARY KEY(id))', @@ -366,7 +367,7 @@ public function getCreateTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { return [ 'ALTER TABLE mytable ADD quota INT NOT NULL', @@ -379,7 +380,7 @@ public function getAlterTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { return [ 'CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY(id))', @@ -390,7 +391,7 @@ public function getCreateTableColumnTypeCommentsSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))']; } @@ -398,7 +399,7 @@ protected function getQuotedColumnInPrimaryKeySQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)', @@ -409,7 +410,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return [ 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', @@ -420,7 +421,7 @@ protected function getQuotedNameInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL)', @@ -441,7 +442,7 @@ public function testConvertBooleanAsLiteralStrings( string $preparedStatementValue, ?int $integerValue, ?bool $booleanValue - ) : void { + ): void { $platform = $this->createPlatform(); self::assertEquals($preparedStatementValue, $platform->convertBooleans($databaseValue)); @@ -450,7 +451,7 @@ public function testConvertBooleanAsLiteralStrings( /** * @group DBAL-457 */ - public function testConvertBooleanAsLiteralIntegers() : void + public function testConvertBooleanAsLiteralIntegers(): void { $platform = $this->createPlatform(); $platform->setUseBooleanTrueFalseStrings(false); @@ -473,7 +474,7 @@ public function testConvertBooleanAsDatabaseValueStrings( string $preparedStatementValue, ?int $integerValue, ?bool $booleanValue - ) : void { + ): void { $platform = $this->createPlatform(); self::assertSame($integerValue, $platform->convertBooleansToDatabaseValue($booleanValue)); @@ -482,7 +483,7 @@ public function testConvertBooleanAsDatabaseValueStrings( /** * @group DBAL-630 */ - public function testConvertBooleanAsDatabaseValueIntegers() : void + public function testConvertBooleanAsDatabaseValueIntegers(): void { $platform = $this->createPlatform(); $platform->setUseBooleanTrueFalseStrings(false); @@ -496,14 +497,14 @@ public function testConvertBooleanAsDatabaseValueIntegers() : void * * @dataProvider pgBooleanProvider */ - public function testConvertFromBoolean($databaseValue, string $prepareStatementValue, ?int $integerValue, ?bool $booleanValue) : void + public function testConvertFromBoolean($databaseValue, string $prepareStatementValue, ?int $integerValue, ?bool $booleanValue): void { $platform = $this->createPlatform(); self::assertSame($booleanValue, $platform->convertFromBoolean($databaseValue)); } - public function testThrowsExceptionWithInvalidBooleanLiteral() : void + public function testThrowsExceptionWithInvalidBooleanLiteral(): void { $platform = $this->createPlatform(); @@ -513,14 +514,14 @@ public function testThrowsExceptionWithInvalidBooleanLiteral() : void $platform->convertBooleansToDatabaseValue('my-bool'); } - public function testGetCreateSchemaSQL() : void + public function testGetCreateSchemaSQL(): void { $schemaName = 'schema'; $sql = $this->platform->getCreateSchemaSQL($schemaName); self::assertEquals('CREATE SCHEMA ' . $schemaName, $sql); } - public function testAlterDecimalPrecisionScale() : void + public function testAlterDecimalPrecisionScale(): void { $table = new Table('mytable'); $table->addColumn('dfoo1', 'decimal'); @@ -582,7 +583,7 @@ public function testAlterDecimalPrecisionScale() : void /** * @group DBAL-365 */ - public function testDroppingConstraintsBeforeColumns() : void + public function testDroppingConstraintsBeforeColumns(): void { $newTable = new Table('mytable'); $newTable->addColumn('id', 'integer'); @@ -609,7 +610,7 @@ public function testDroppingConstraintsBeforeColumns() : void /** * @group DBAL-563 */ - public function testUsesSequenceEmulatedIdentityColumns() : void + public function testUsesSequenceEmulatedIdentityColumns(): void { self::assertTrue($this->platform->usesSequenceEmulatedIdentityColumns()); } @@ -617,7 +618,7 @@ public function testUsesSequenceEmulatedIdentityColumns() : void /** * @group DBAL-563 */ - public function testReturnsIdentitySequenceName() : void + public function testReturnsIdentitySequenceName(): void { self::assertSame('mytable_mycolumn_seq', $this->platform->getIdentitySequenceName('mytable', 'mycolumn')); } @@ -626,7 +627,7 @@ public function testReturnsIdentitySequenceName() : void * @dataProvider dataCreateSequenceWithCache * @group DBAL-139 */ - public function testCreateSequenceWithCache(int $cacheSize, string $expectedSql) : void + public function testCreateSequenceWithCache(int $cacheSize, string $expectedSql): void { $sequence = new Sequence('foo', 1, 1, $cacheSize); self::assertStringContainsString($expectedSql, $this->platform->getCreateSequenceSQL($sequence)); @@ -635,24 +636,24 @@ public function testCreateSequenceWithCache(int $cacheSize, string $expectedSql) /** * @return mixed[][] */ - public static function dataCreateSequenceWithCache() : iterable + public static function dataCreateSequenceWithCache(): iterable { return [ [3, 'CACHE 3'], ]; } - protected function getBinaryDefaultLength() : int + protected function getBinaryDefaultLength(): int { return 0; } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 0; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -663,7 +664,7 @@ public function testReturnsBinaryTypeDeclarationSQL() : void self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 9999999])); } - public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType() : void + public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType(): void { $table1 = new Table('mytable'); $table1->addColumn('column_varbinary', 'binary'); @@ -708,7 +709,7 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType() : v * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return ['ALTER INDEX idx_foo RENAME TO idx_bar']; } @@ -718,7 +719,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'ALTER INDEX "create" RENAME TO "select"', @@ -731,7 +732,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array * * @return mixed[][] */ - public static function pgBooleanProvider() : iterable + public static function pgBooleanProvider(): iterable { return [ // Database value, prepared statement value, boolean integer value, boolean value. @@ -758,7 +759,7 @@ public static function pgBooleanProvider() : iterable /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return [ 'ALTER TABLE mytable RENAME COLUMN unquoted1 TO unquoted', @@ -776,7 +777,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { return [ 'ALTER TABLE mytable ALTER unquoted1 TYPE VARCHAR(255)', @@ -793,7 +794,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return ['ALTER INDEX myschema.idx_foo RENAME TO idx_bar']; } @@ -803,7 +804,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'ALTER INDEX "schema"."create" RENAME TO "select"', @@ -811,12 +812,12 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array ]; } - protected function getQuotesDropForeignKeySQL() : string + protected function getQuotesDropForeignKeySQL(): string { return 'ALTER TABLE "table" DROP CONSTRAINT "select"'; } - public function testGetNullCommentOnColumnSQL() : void + public function testGetNullCommentOnColumnSQL(): void { self::assertEquals( 'COMMENT ON COLUMN mytable.id IS NULL', @@ -827,7 +828,7 @@ public function testGetNullCommentOnColumnSQL() : void /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('UUID', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -835,7 +836,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return ['ALTER TABLE foo RENAME COLUMN bar TO baz']; } @@ -843,7 +844,7 @@ public function getAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'ALTER TABLE "foo" DROP CONSTRAINT fk1', @@ -863,7 +864,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ 'COMMENT ON COLUMN foo.bar IS \'comment\'', @@ -875,7 +876,7 @@ protected function getCommentOnColumnSQL() : array /** * @group DBAL-1004 */ - public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() : void + public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers(): void { $table1 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'))]); $table2 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'), ['comment' => 'baz'])]); @@ -894,7 +895,7 @@ public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() : /** * @group 3158 */ - public function testAltersTableColumnCommentIfRequiredByType() : void + public function testAltersTableColumnCommentIfRequiredByType(): void { $table1 = new Table('"foo"', [new Column('"bar"', Type::getType('datetime'))]); $table2 = new Table('"foo"', [new Column('"bar"', Type::getType('datetime_immutable'))]); @@ -914,17 +915,17 @@ public function testAltersTableColumnCommentIfRequiredByType() : void ); } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return 'INDEX "select" (foo)'; } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'TRUNCATE "select"'; } @@ -932,7 +933,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL() : string /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return ['ALTER TABLE mytable ALTER name TYPE CHAR(2)']; } @@ -940,7 +941,7 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return ['ALTER INDEX idx_foo RENAME TO idx_foo_renamed']; } @@ -948,7 +949,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : arra /** * @group DBAL-1142 */ - public function testInitializesTsvectorTypeMapping() : void + public function testInitializesTsvectorTypeMapping(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('tsvector')); self::assertEquals('text', $this->platform->getDoctrineTypeMapping('tsvector')); @@ -957,7 +958,7 @@ public function testInitializesTsvectorTypeMapping() : void /** * @group DBAL-1220 */ - public function testReturnsDisallowDatabaseConnectionsSQL() : void + public function testReturnsDisallowDatabaseConnectionsSQL(): void { self::assertSame( "UPDATE pg_database SET datallowconn = 'false' WHERE datname = 'foo'", @@ -968,7 +969,7 @@ public function testReturnsDisallowDatabaseConnectionsSQL() : void /** * @group DBAL-1220 */ - public function testReturnsCloseActiveDatabaseConnectionsSQL() : void + public function testReturnsCloseActiveDatabaseConnectionsSQL(): void { self::assertSame( "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = 'foo'", @@ -979,7 +980,7 @@ public function testReturnsCloseActiveDatabaseConnectionsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -990,7 +991,7 @@ public function testQuotesTableNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableForeignKeysSQL() : void + public function testQuotesSchemaNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1001,7 +1002,7 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableConstraintsSQL() : void + public function testQuotesTableNameInListTableConstraintsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1012,7 +1013,7 @@ public function testQuotesTableNameInListTableConstraintsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1023,7 +1024,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableIndexesSQL() : void + public function testQuotesSchemaNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1034,7 +1035,7 @@ public function testQuotesSchemaNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableColumnsSQL() : void + public function testQuotesTableNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1045,7 +1046,7 @@ public function testQuotesTableNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableColumnsSQL() : void + public function testQuotesSchemaNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1056,7 +1057,7 @@ public function testQuotesSchemaNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL() : void + public function testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php index 053ff482746..6f21061f83d 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\Type; + use function sprintf; abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCase @@ -18,7 +19,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas /** @var SQLServerPlatform */ protected $platform; - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test NVARCHAR(255), PRIMARY KEY (id))'; } @@ -26,7 +27,7 @@ public function getGenerateTableSql() : string /** * {@inheritDoc} */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return [ 'CREATE TABLE test (foo NVARCHAR(255), bar NVARCHAR(255))', @@ -37,7 +38,7 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return [ 'ALTER TABLE mytable ADD quota INT', @@ -57,14 +58,14 @@ public function getGenerateAlterTableSql() : array ]; } - public function testDoesNotSupportRegexp() : void + public function testDoesNotSupportRegexp(): void { $this->expectException(DBALException::class); $this->platform->getRegexpExpression(); } - public function testGeneratesSqlSnippets() : void + public function testGeneratesSqlSnippets(): void { self::assertEquals('CONVERT(date, GETDATE())', $this->platform->getCurrentDateSQL()); self::assertEquals('CONVERT(time, GETDATE())', $this->platform->getCurrentTimeSQL()); @@ -73,7 +74,7 @@ public function testGeneratesSqlSnippets() : void self::assertEquals('(column1 + column2 + column3)', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); } - public function testGeneratesTransactionsCommands() : void + public function testGeneratesTransactionsCommands(): void { self::assertEquals( 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', @@ -93,7 +94,7 @@ public function testGeneratesTransactionsCommands() : void ); } - public function testGeneratesDDLSnippets() : void + public function testGeneratesDDLSnippets(): void { $dropDatabaseExpectation = 'DROP DATABASE foobar'; @@ -103,7 +104,7 @@ public function testGeneratesDDLSnippets() : void self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar')); } - public function testGeneratesTypeDeclarationForIntegers() : void + public function testGeneratesTypeDeclarationForIntegers(): void { self::assertEquals( 'INT', @@ -121,7 +122,7 @@ public function testGeneratesTypeDeclarationForIntegers() : void ); } - public function testGeneratesTypeDeclarationsForStrings() : void + public function testGeneratesTypeDeclarationsForStrings(): void { self::assertEquals( 'NCHAR(10)', @@ -146,47 +147,47 @@ public function testGeneratesTypeDeclarationsForStrings() : void ); } - public function testPrefersIdentityColumns() : void + public function testPrefersIdentityColumns(): void { self::assertTrue($this->platform->prefersIdentityColumns()); } - public function testSupportsIdentityColumns() : void + public function testSupportsIdentityColumns(): void { self::assertTrue($this->platform->supportsIdentityColumns()); } - public function testSupportsCreateDropDatabase() : void + public function testSupportsCreateDropDatabase(): void { self::assertTrue($this->platform->supportsCreateDropDatabase()); } - public function testSupportsSchemas() : void + public function testSupportsSchemas(): void { self::assertTrue($this->platform->supportsSchemas()); } - public function testDoesNotSupportSavePoints() : void + public function testDoesNotSupportSavePoints(): void { self::assertTrue($this->platform->supportsSavepoints()); } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2) WHERE test IS NOT NULL AND test2 IS NOT NULL'; } - protected function getGenerateForeignKeySql() : string + protected function getGenerateForeignKeySql(): string { return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; } - public function testModifyLimitQuery() : void + public function testModifyLimitQuery(): void { $querySql = 'SELECT * FROM user'; $alteredSql = 'SELECT TOP 10 * FROM user'; @@ -194,7 +195,7 @@ public function testModifyLimitQuery() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithEmptyOffset() : void + public function testModifyLimitQueryWithEmptyOffset(): void { $querySql = 'SELECT * FROM user'; $alteredSql = 'SELECT TOP 10 * FROM user'; @@ -202,7 +203,7 @@ public function testModifyLimitQueryWithEmptyOffset() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithOffset() : void + public function testModifyLimitQueryWithOffset(): void { if (! $this->platform->supportsLimitOffset()) { $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->platform->getName())); @@ -215,7 +216,7 @@ public function testModifyLimitQueryWithOffset() : void $this->expectCteWithMinAndMaxRowNums($alteredSql, 6, 15, $sql); } - public function testModifyLimitQueryWithAscOrderBy() : void + public function testModifyLimitQueryWithAscOrderBy(): void { $querySql = 'SELECT * FROM user ORDER BY username ASC'; $alteredSql = 'SELECT TOP 10 * FROM user ORDER BY username ASC'; @@ -224,7 +225,7 @@ public function testModifyLimitQueryWithAscOrderBy() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithLowercaseOrderBy() : void + public function testModifyLimitQueryWithLowercaseOrderBy(): void { $querySql = 'SELECT * FROM user order by username'; $alteredSql = 'SELECT TOP 10 * FROM user order by username'; @@ -232,7 +233,7 @@ public function testModifyLimitQueryWithLowercaseOrderBy() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithDescOrderBy() : void + public function testModifyLimitQueryWithDescOrderBy(): void { $querySql = 'SELECT * FROM user ORDER BY username DESC'; $alteredSql = 'SELECT TOP 10 * FROM user ORDER BY username DESC'; @@ -240,7 +241,7 @@ public function testModifyLimitQueryWithDescOrderBy() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithMultipleOrderBy() : void + public function testModifyLimitQueryWithMultipleOrderBy(): void { $querySql = 'SELECT * FROM user ORDER BY username DESC, usereamil ASC'; $alteredSql = 'SELECT TOP 10 * FROM user ORDER BY username DESC, usereamil ASC'; @@ -248,7 +249,7 @@ public function testModifyLimitQueryWithMultipleOrderBy() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithSubSelect() : void + public function testModifyLimitQueryWithSubSelect(): void { $querySql = 'SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result'; $alteredSql = 'SELECT TOP 10 * FROM (SELECT u.id as uid, u.name as uname) dctrn_result'; @@ -256,7 +257,7 @@ public function testModifyLimitQueryWithSubSelect() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithSubSelectAndOrder() : void + public function testModifyLimitQueryWithSubSelectAndOrder(): void { $querySql = 'SELECT * FROM (SELECT u.id as uid, u.name as uname ORDER BY u.name DESC) dctrn_result'; $alteredSql = 'SELECT TOP 10 * FROM (SELECT u.id as uid, u.name as uname) dctrn_result'; @@ -269,7 +270,7 @@ public function testModifyLimitQueryWithSubSelectAndOrder() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithSubSelectAndMultipleOrder() : void + public function testModifyLimitQueryWithSubSelectAndMultipleOrder(): void { if (! $this->platform->supportsLimitOffset()) { $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->platform->getName())); @@ -291,7 +292,7 @@ public function testModifyLimitQueryWithSubSelectAndMultipleOrder() : void $this->expectCteWithMinAndMaxRowNums($alteredSql, 6, 15, $sql); } - public function testModifyLimitQueryWithFromColumnNames() : void + public function testModifyLimitQueryWithFromColumnNames(): void { $querySql = 'SELECT a.fromFoo, fromBar FROM foo'; $alteredSql = 'SELECT TOP 10 a.fromFoo, fromBar FROM foo'; @@ -302,7 +303,7 @@ public function testModifyLimitQueryWithFromColumnNames() : void /** * @group DBAL-927 */ - public function testModifyLimitQueryWithExtraLongQuery() : void + public function testModifyLimitQueryWithExtraLongQuery(): void { $query = 'SELECT table1.column1, table2.column2, table3.column3, table4.column4, table5.column5, table6.column6, table7.column7, table8.column8 FROM table1, table2, table3, table4, table5, table6, table7, table8 '; $query .= 'WHERE (table1.column1 = table2.column2) AND (table1.column1 = table3.column3) AND (table1.column1 = table4.column4) AND (table1.column1 = table5.column5) AND (table1.column1 = table6.column6) AND (table1.column1 = table7.column7) AND (table1.column1 = table8.column8) AND (table2.column2 = table3.column3) AND (table2.column2 = table4.column4) AND (table2.column2 = table5.column5) AND (table2.column2 = table6.column6) '; @@ -321,7 +322,7 @@ public function testModifyLimitQueryWithExtraLongQuery() : void /** * @group DDC-2470 */ - public function testModifyLimitQueryWithOrderByClause() : void + public function testModifyLimitQueryWithOrderByClause(): void { if (! $this->platform->supportsLimitOffset()) { $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->platform->getName())); @@ -337,7 +338,7 @@ public function testModifyLimitQueryWithOrderByClause() : void /** * @group DBAL-713 */ - public function testModifyLimitQueryWithSubSelectInSelectList() : void + public function testModifyLimitQueryWithSubSelectInSelectList(): void { $querySql = 'SELECT ' . 'u.id, ' . @@ -361,7 +362,7 @@ public function testModifyLimitQueryWithSubSelectInSelectList() : void /** * @group DBAL-713 */ - public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause() : void + public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause(): void { if (! $this->platform->supportsLimitOffset()) { $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->platform->getName())); @@ -390,7 +391,7 @@ public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause() /** * @group DBAL-834 */ - public function testModifyLimitQueryWithAggregateFunctionInOrderByClause() : void + public function testModifyLimitQueryWithAggregateFunctionInOrderByClause(): void { $querySql = 'SELECT ' . 'MAX(heading_id) aliased, ' . @@ -411,7 +412,7 @@ public function testModifyLimitQueryWithAggregateFunctionInOrderByClause() : voi /** * @throws DBALException */ - public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable() : void + public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' . 'FROM (' @@ -435,7 +436,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBas /** * @throws DBALException */ - public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable() : void + public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' . 'FROM (' @@ -459,7 +460,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoi /** * @throws DBALException */ - public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables() : void + public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables(): void { $querySql = 'SELECT DISTINCT id_0, name_1, foo_2 ' . 'FROM (' @@ -480,7 +481,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBo $this->expectCteWithMaxRowNum($alteredSql, 5, $sql); } - public function testModifyLimitSubquerySimple() : void + public function testModifyLimitSubquerySimple(): void { $querySql = 'SELECT DISTINCT id_0 FROM ' . '(SELECT k0_.id AS id_0, k0_.field AS field_1 ' @@ -494,7 +495,7 @@ public function testModifyLimitSubquerySimple() : void /** * @group DDC-1360 */ - public function testQuoteIdentifier() : void + public function testQuoteIdentifier(): void { self::assertEquals('[fo][o]', $this->platform->quoteIdentifier('fo]o')); self::assertEquals('[test]', $this->platform->quoteIdentifier('test')); @@ -504,7 +505,7 @@ public function testQuoteIdentifier() : void /** * @group DDC-1360 */ - public function testQuoteSingleIdentifier() : void + public function testQuoteSingleIdentifier(): void { self::assertEquals('[fo][o]', $this->platform->quoteSingleIdentifier('fo]o')); self::assertEquals('[test]', $this->platform->quoteSingleIdentifier('test')); @@ -514,7 +515,7 @@ public function testQuoteSingleIdentifier() : void /** * @group DBAL-220 */ - public function testCreateClusteredIndex() : void + public function testCreateClusteredIndex(): void { $idx = new Index('idx', ['id']); $idx->addFlag('clustered'); @@ -524,7 +525,7 @@ public function testCreateClusteredIndex() : void /** * @group DBAL-220 */ - public function testCreateNonClusteredPrimaryKeyInTable() : void + public function testCreateNonClusteredPrimaryKeyInTable(): void { $table = new Table('tbl'); $table->addColumn('id', 'integer'); @@ -537,14 +538,14 @@ public function testCreateNonClusteredPrimaryKeyInTable() : void /** * @group DBAL-220 */ - public function testCreateNonClusteredPrimaryKey() : void + public function testCreateNonClusteredPrimaryKey(): void { $idx = new Index('idx', ['id'], false, true); $idx->addFlag('nonclustered'); self::assertEquals('ALTER TABLE tbl ADD PRIMARY KEY NONCLUSTERED (id)', $this->platform->getCreatePrimaryKeySQL($idx, 'tbl')); } - public function testAlterAddPrimaryKey() : void + public function testAlterAddPrimaryKey(): void { $idx = new Index('idx', ['id'], false, true); self::assertEquals('ALTER TABLE tbl ADD PRIMARY KEY (id)', $this->platform->getCreateIndexSQL($idx, 'tbl')); @@ -553,7 +554,7 @@ public function testAlterAddPrimaryKey() : void /** * {@inheritDoc} */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL, PRIMARY KEY ([create]))']; } @@ -561,7 +562,7 @@ protected function getQuotedColumnInPrimaryKeySQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return [ 'CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL)', @@ -572,7 +573,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return [ 'CREATE TABLE test (column1 NVARCHAR(255) NOT NULL)', @@ -583,7 +584,7 @@ protected function getQuotedNameInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return [ 'CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL, foo NVARCHAR(255) NOT NULL, [bar] NVARCHAR(255) NOT NULL)', @@ -593,14 +594,14 @@ protected function getQuotedColumnInForeignKeySQL() : array ]; } - public function testGetCreateSchemaSQL() : void + public function testGetCreateSchemaSQL(): void { $schemaName = 'schema'; $sql = $this->platform->getCreateSchemaSQL($schemaName); self::assertEquals('CREATE SCHEMA ' . $schemaName, $sql); } - public function testCreateTableWithSchemaColumnComments() : void + public function testCreateTableWithSchemaColumnComments(): void { $table = new Table('testschema.test'); $table->addColumn('id', 'integer', ['comment' => 'This is a comment']); @@ -614,7 +615,7 @@ public function testCreateTableWithSchemaColumnComments() : void self::assertEquals($expectedSql, $this->platform->getCreateTableSQL($table)); } - public function testAlterTableWithSchemaColumnComments() : void + public function testAlterTableWithSchemaColumnComments(): void { $tableDiff = new TableDiff('testschema.mytable'); $tableDiff->addedColumns['quota'] = new Column('quota', Type::getType('integer'), ['comment' => 'A comment']); @@ -627,7 +628,7 @@ public function testAlterTableWithSchemaColumnComments() : void self::assertEquals($expectedSql, $this->platform->getAlterTableSQL($tableDiff)); } - public function testAlterTableWithSchemaDropColumnComments() : void + public function testAlterTableWithSchemaDropColumnComments(): void { $tableDiff = new TableDiff('testschema.mytable'); $tableDiff->changedColumns['quota'] = new ColumnDiff( @@ -642,7 +643,7 @@ public function testAlterTableWithSchemaDropColumnComments() : void self::assertEquals($expectedSql, $this->platform->getAlterTableSQL($tableDiff)); } - public function testAlterTableWithSchemaUpdateColumnComments() : void + public function testAlterTableWithSchemaUpdateColumnComments(): void { $tableDiff = new TableDiff('testschema.mytable'); $tableDiff->changedColumns['quota'] = new ColumnDiff( @@ -662,7 +663,7 @@ public function testAlterTableWithSchemaUpdateColumnComments() : void * * @group DBAL-543 */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { return [ 'CREATE TABLE test (id INT NOT NULL, PRIMARY KEY (id))', @@ -675,7 +676,7 @@ public function getCreateTableColumnCommentsSQL() : array * * @group DBAL-543 */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { return [ 'ALTER TABLE mytable ADD quota INT NOT NULL', @@ -690,7 +691,7 @@ public function getAlterTableColumnCommentsSQL() : array * * @group DBAL-543 */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { return [ 'CREATE TABLE test (id INT NOT NULL, data VARCHAR(MAX) NOT NULL, PRIMARY KEY (id))', @@ -701,7 +702,7 @@ public function getCreateTableColumnTypeCommentsSQL() : array /** * @group DBAL-543 */ - public function testGeneratesCreateTableSQLWithColumnComments() : void + public function testGeneratesCreateTableSQLWithColumnComments(): void { $table = new Table('mytable'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -740,7 +741,7 @@ public function testGeneratesCreateTableSQLWithColumnComments() : void * @group DBAL-543 * @group DBAL-1011 */ - public function testGeneratesAlterTableSQLWithColumnComments() : void + public function testGeneratesAlterTableSQLWithColumnComments(): void { $table = new Table('mytable'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -922,7 +923,7 @@ public function testGeneratesAlterTableSQLWithColumnComments() : void /** * @group DBAL-122 */ - public function testInitializesDoctrineTypeMappings() : void + public function testInitializesDoctrineTypeMappings(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('bigint')); self::assertSame('bigint', $this->platform->getDoctrineTypeMapping('bigint')); @@ -1000,12 +1001,12 @@ public function testInitializesDoctrineTypeMappings() : void self::assertSame('guid', $this->platform->getDoctrineTypeMapping('uniqueidentifier')); } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 8000; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('VARBINARY(255)', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('VARBINARY(255)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -1020,7 +1021,7 @@ public function testReturnsBinaryTypeDeclarationSQL() : void * @group legacy * @expectedDeprecation Binary field length 8001 is greater than supported by the platform (8000). Reduce the field length or use a BLOB field instead. */ - public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void + public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL(): void { self::assertSame('VARBINARY(MAX)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 8001])); self::assertSame('VARBINARY(MAX)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 8001])); @@ -1031,7 +1032,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return ["EXEC sp_RENAME N'mytable.idx_foo', N'idx_bar', N'INDEX'"]; } @@ -1041,7 +1042,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ "EXEC sp_RENAME N'[table].[create]', N'[select]', N'INDEX'", @@ -1052,7 +1053,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array /** * @group DBAL-825 */ - public function testChangeColumnsTypeWithDefaultValue() : void + public function testChangeColumnsTypeWithDefaultValue(): void { $tableName = 'column_def_change_type'; $table = new Table($tableName); @@ -1094,7 +1095,7 @@ public function testChangeColumnsTypeWithDefaultValue() : void /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return [ "sp_RENAME 'mytable.unquoted1', 'unquoted', 'COLUMN'", @@ -1112,7 +1113,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { $this->markTestIncomplete('Not implemented yet'); } @@ -1122,7 +1123,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return ["EXEC sp_RENAME N'myschema.mytable.idx_foo', N'idx_bar', N'INDEX'"]; } @@ -1132,7 +1133,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ "EXEC sp_RENAME N'[schema].[table].[create]', N'[select]', N'INDEX'", @@ -1140,12 +1141,12 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array ]; } - protected function getQuotesDropForeignKeySQL() : string + protected function getQuotesDropForeignKeySQL(): string { return 'ALTER TABLE [table] DROP CONSTRAINT [select]'; } - protected function getQuotesDropConstraintSQL() : string + protected function getQuotesDropConstraintSQL(): string { return 'ALTER TABLE [table] DROP CONSTRAINT [select]'; } @@ -1156,7 +1157,7 @@ protected function getQuotesDropConstraintSQL() : string * @dataProvider getGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL * @group DBAL-830 */ - public function testGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL(string $table, array $column, string $expectedSql) : void + public function testGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL(string $table, array $column, string $expectedSql): void { self::assertSame($expectedSql, $this->platform->getDefaultConstraintDeclarationSQL($table, $column)); } @@ -1164,7 +1165,7 @@ public function testGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL(st /** * @return mixed[][] */ - public static function getGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL() : iterable + public static function getGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL(): iterable { return [ // Unquoted identifiers non-reserved keywords. @@ -1184,7 +1185,7 @@ public static function getGeneratesIdentifierNamesInDefaultConstraintDeclaration * @dataProvider getGeneratesIdentifierNamesInCreateTableSQL * @group DBAL-830 */ - public function testGeneratesIdentifierNamesInCreateTableSQL(Table $table, array $expectedSql) : void + public function testGeneratesIdentifierNamesInCreateTableSQL(Table $table, array $expectedSql): void { self::assertSame($expectedSql, $this->platform->getCreateTableSQL($table)); } @@ -1192,7 +1193,7 @@ public function testGeneratesIdentifierNamesInCreateTableSQL(Table $table, array /** * @return mixed[][] */ - public static function getGeneratesIdentifierNamesInCreateTableSQL() : iterable + public static function getGeneratesIdentifierNamesInCreateTableSQL(): iterable { return [ // Unquoted identifiers non-reserved keywords. @@ -1236,7 +1237,7 @@ public static function getGeneratesIdentifierNamesInCreateTableSQL() : iterable * @dataProvider getGeneratesIdentifierNamesInAlterTableSQL * @group DBAL-830 */ - public function testGeneratesIdentifierNamesInAlterTableSQL(TableDiff $tableDiff, array $expectedSql) : void + public function testGeneratesIdentifierNamesInAlterTableSQL(TableDiff $tableDiff, array $expectedSql): void { self::assertSame($expectedSql, $this->platform->getAlterTableSQL($tableDiff)); } @@ -1244,7 +1245,7 @@ public function testGeneratesIdentifierNamesInAlterTableSQL(TableDiff $tableDiff /** * @return mixed[][] */ - public static function getGeneratesIdentifierNamesInAlterTableSQL() : iterable + public static function getGeneratesIdentifierNamesInAlterTableSQL(): iterable { return [ // Unquoted identifiers non-reserved keywords. @@ -1349,7 +1350,7 @@ public static function getGeneratesIdentifierNamesInAlterTableSQL() : iterable /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('UNIQUEIDENTIFIER', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -1357,7 +1358,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return [ "sp_RENAME 'foo.bar', 'baz', 'COLUMN'", @@ -1369,7 +1370,7 @@ public function getAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'ALTER TABLE [foo] DROP CONSTRAINT fk1', @@ -1391,7 +1392,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ "COMMENT ON COLUMN foo.bar IS 'comment'", @@ -1403,7 +1404,7 @@ protected function getCommentOnColumnSQL() : array /** * {@inheritdoc} */ - public static function getReturnsForeignKeyReferentialActionSQL() : iterable + public static function getReturnsForeignKeyReferentialActionSQL(): iterable { return [ ['CASCADE', 'CASCADE'], @@ -1415,17 +1416,17 @@ public static function getReturnsForeignKeyReferentialActionSQL() : iterable ]; } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT [select] UNIQUE (foo) WHERE foo IS NOT NULL'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return 'INDEX [select] (foo)'; } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'TRUNCATE TABLE [select]'; } @@ -1433,7 +1434,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL() : string /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return ['ALTER TABLE mytable ALTER COLUMN name NCHAR(2) NOT NULL']; } @@ -1441,12 +1442,12 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return ["EXEC sp_RENAME N'mytable.idx_foo', N'idx_foo_renamed', N'INDEX'"]; } - public function testModifyLimitQueryWithTopNSubQueryWithOrderBy() : void + public function testModifyLimitQueryWithTopNSubQueryWithOrderBy(): void { $querySql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC)'; $alteredSql = 'SELECT TOP 10 * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC)'; @@ -1462,7 +1463,7 @@ public function testModifyLimitQueryWithTopNSubQueryWithOrderBy() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableColumnsSQL() : void + public function testQuotesTableNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1473,7 +1474,7 @@ public function testQuotesTableNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableColumnsSQL() : void + public function testQuotesSchemaNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1484,7 +1485,7 @@ public function testQuotesSchemaNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1495,7 +1496,7 @@ public function testQuotesTableNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableForeignKeysSQL() : void + public function testQuotesSchemaNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1506,7 +1507,7 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1517,7 +1518,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableIndexesSQL() : void + public function testQuotesSchemaNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1528,7 +1529,7 @@ public function testQuotesSchemaNameInListTableIndexesSQL() : void /** * @group 2859 */ - public function testGetDefaultValueDeclarationSQLForDateType() : void + public function testGetDefaultValueDeclarationSQLForDateType(): void { $currentDateSql = $this->platform->getCurrentDateSQL(); foreach (['date', 'date_immutable'] as $type) { @@ -1544,12 +1545,12 @@ public function testGetDefaultValueDeclarationSQLForDateType() : void } } - public function testSupportsColumnCollation() : void + public function testSupportsColumnCollation(): void { self::assertTrue($this->platform->supportsColumnCollation()); } - public function testColumnCollationDeclarationSQL() : void + public function testColumnCollationDeclarationSQL(): void { self::assertSame( 'COLLATE Latin1_General_CS_AS_KS_WS', @@ -1557,7 +1558,7 @@ public function testColumnCollationDeclarationSQL() : void ); } - public function testGetCreateTableSQLWithColumnCollation() : void + public function testGetCreateTableSQLWithColumnCollation(): void { $table = new Table('foo'); $table->addColumn('no_collation', 'string'); @@ -1570,13 +1571,13 @@ public function testGetCreateTableSQLWithColumnCollation() : void ); } - private function expectCteWithMaxRowNum(string $expectedSql, int $expectedMax, string $sql) : void + private function expectCteWithMaxRowNum(string $expectedSql, int $expectedMax, string $sql): void { $pattern = 'WITH dctrn_cte AS (%s) SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS doctrine_rownum FROM dctrn_cte) AS doctrine_tbl WHERE doctrine_rownum <= %d ORDER BY doctrine_rownum ASC'; self::assertEquals(sprintf($pattern, $expectedSql, $expectedMax), $sql); } - private function expectCteWithMinAndMaxRowNums(string $expectedSql, int $expectedMin, int $expectedMax, string $sql) : void + private function expectCteWithMinAndMaxRowNums(string $expectedSql, int $expectedMin, int $expectedMax, string $sql): void { $pattern = 'WITH dctrn_cte AS (%s) SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS doctrine_rownum FROM dctrn_cte) AS doctrine_tbl WHERE doctrine_rownum >= %d AND doctrine_rownum <= %d ORDER BY doctrine_rownum ASC'; self::assertEquals(sprintf($pattern, $expectedSql, $expectedMin, $expectedMax), $sql); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php index 6bf261af7de..e23c056f0b4 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php @@ -17,7 +17,7 @@ class DB2PlatformTest extends AbstractPlatformTestCase /** @var DB2Platform */ protected $platform; - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new DB2Platform(); } @@ -25,7 +25,7 @@ public function createPlatform() : AbstractPlatform /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return [ 'ALTER TABLE mytable ALTER COLUMN baz SET DATA TYPE VARCHAR(255)', @@ -42,17 +42,17 @@ public function getGenerateAlterTableSql() : array ]; } - protected function getGenerateForeignKeySql() : string + protected function getGenerateForeignKeySql(): string { return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'; } @@ -60,7 +60,7 @@ public function getGenerateTableSql() : string /** * {@inheritDoc} */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return [ 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)', @@ -68,7 +68,7 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array ]; } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } @@ -76,7 +76,7 @@ public function getGenerateUniqueIndexSql() : string /** * {@inheritDoc} */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL)', @@ -89,7 +89,7 @@ protected function getQuotedColumnInForeignKeySQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)', @@ -100,7 +100,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return [ 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', @@ -111,17 +111,17 @@ protected function getQuotedNameInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))']; } - protected function getBitAndComparisonExpressionSql(string $value1, string $value2) : string + protected function getBitAndComparisonExpressionSql(string $value1, string $value2): string { return 'BITAND(' . $value1 . ', ' . $value2 . ')'; } - protected function getBitOrComparisonExpressionSql(string $value1, string $value2) : string + protected function getBitOrComparisonExpressionSql(string $value1, string $value2): string { return 'BITOR(' . $value1 . ', ' . $value2 . ')'; } @@ -129,7 +129,7 @@ protected function getBitOrComparisonExpressionSql(string $value1, string $value /** * {@inheritDoc} */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { return [ 'CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))', @@ -140,7 +140,7 @@ public function getCreateTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { return [ 'ALTER TABLE mytable ' . @@ -155,7 +155,7 @@ public function getAlterTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { return [ 'CREATE TABLE test (id INTEGER NOT NULL, "data" CLOB(1M) NOT NULL, PRIMARY KEY(id))', @@ -163,12 +163,12 @@ public function getCreateTableColumnTypeCommentsSQL() : array ]; } - public function testHasCorrectPlatformName() : void + public function testHasCorrectPlatformName(): void { self::assertEquals('db2', $this->platform->getName()); } - public function testGeneratesCreateTableSQLWithCommonIndexes() : void + public function testGeneratesCreateTableSQLWithCommonIndexes(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -187,7 +187,7 @@ public function testGeneratesCreateTableSQLWithCommonIndexes() : void ); } - public function testGeneratesCreateTableSQLWithForeignKeyConstraints() : void + public function testGeneratesCreateTableSQLWithForeignKeyConstraints(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -213,7 +213,7 @@ public function testGeneratesCreateTableSQLWithForeignKeyConstraints() : void ); } - public function testGeneratesCreateTableSQLWithCheckConstraints() : void + public function testGeneratesCreateTableSQLWithCheckConstraints(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -227,7 +227,7 @@ public function testGeneratesCreateTableSQLWithCheckConstraints() : void ); } - public function testGeneratesColumnTypesDeclarationSQL() : void + public function testGeneratesColumnTypesDeclarationSQL(): void { $fullColumnDef = [ 'length' => 10, @@ -259,7 +259,7 @@ public function testGeneratesColumnTypesDeclarationSQL() : void self::assertEquals('TIME', $this->platform->getTimeTypeDeclarationSQL($fullColumnDef)); } - public function testInitializesDoctrineTypeMappings() : void + public function testInitializesDoctrineTypeMappings(): void { $this->platform->initializeDoctrineTypeMappings(); @@ -306,7 +306,7 @@ public function testInitializesDoctrineTypeMappings() : void /** * {@inheritDoc} */ - public function getIsCommentedDoctrineType() : array + public function getIsCommentedDoctrineType(): array { $data = parent::getIsCommentedDoctrineType(); @@ -315,7 +315,7 @@ public function getIsCommentedDoctrineType() : array return $data; } - public function testGeneratesDDLSnippets() : void + public function testGeneratesDDLSnippets(): void { self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar')); self::assertEquals('DROP DATABASE foobar', $this->platform->getDropDatabaseSQL('foobar')); @@ -328,7 +328,7 @@ public function testGeneratesDDLSnippets() : void self::assertEquals('DROP VIEW fooview', $this->platform->getDropViewSQL('fooview')); } - public function testGeneratesCreateUnnamedPrimaryKeySQL() : void + public function testGeneratesCreateUnnamedPrimaryKeySQL(): void { self::assertEquals( 'ALTER TABLE foo ADD PRIMARY KEY (a, b)', @@ -339,7 +339,7 @@ public function testGeneratesCreateUnnamedPrimaryKeySQL() : void ); } - public function testGeneratesSQLSnippets() : void + public function testGeneratesSQLSnippets(): void { self::assertEquals('CURRENT DATE', $this->platform->getCurrentDateSQL()); self::assertEquals('CURRENT TIME', $this->platform->getCurrentTimeSQL()); @@ -369,7 +369,7 @@ public function testGeneratesSQLSnippets() : void self::assertEquals('SUBSTR(column, 5, 2)', $this->platform->getSubstringExpression('column', 5, 2)); } - public function testModifiesLimitQuery() : void + public function testModifiesLimitQuery(): void { self::assertEquals( 'SELECT * FROM user', @@ -396,47 +396,47 @@ public function testModifiesLimitQuery() : void ); } - public function testPrefersIdentityColumns() : void + public function testPrefersIdentityColumns(): void { self::assertTrue($this->platform->prefersIdentityColumns()); } - public function testSupportsIdentityColumns() : void + public function testSupportsIdentityColumns(): void { self::assertTrue($this->platform->supportsIdentityColumns()); } - public function testDoesNotSupportSavePoints() : void + public function testDoesNotSupportSavePoints(): void { self::assertFalse($this->platform->supportsSavepoints()); } - public function testDoesNotSupportReleasePoints() : void + public function testDoesNotSupportReleasePoints(): void { self::assertFalse($this->platform->supportsReleaseSavepoints()); } - public function testDoesNotSupportCreateDropDatabase() : void + public function testDoesNotSupportCreateDropDatabase(): void { self::assertFalse($this->platform->supportsCreateDropDatabase()); } - public function testReturnsSQLResultCasing() : void + public function testReturnsSQLResultCasing(): void { self::assertSame('COL', $this->platform->getSQLResultCasing('cOl')); } - protected function getBinaryDefaultLength() : int + protected function getBinaryDefaultLength(): int { return 1; } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 32704; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('VARCHAR(1) FOR BIT DATA', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('VARCHAR(255) FOR BIT DATA', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -450,7 +450,7 @@ public function testReturnsBinaryTypeDeclarationSQL() : void * @group legacy * @expectedDeprecation Binary field length 32705 is greater than supported by the platform (32704). Reduce the field length or use a BLOB field instead. */ - public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void + public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL(): void { self::assertSame('BLOB(1M)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 32705])); self::assertSame('BLOB(1M)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 32705])); @@ -461,7 +461,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return ['RENAME INDEX idx_foo TO idx_bar']; } @@ -471,7 +471,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'RENAME INDEX "create" TO "select"', @@ -482,7 +482,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return ['ALTER TABLE mytable ' . 'RENAME COLUMN unquoted1 TO unquoted ' . @@ -500,7 +500,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { $this->markTestIncomplete('Not implemented yet'); } @@ -510,7 +510,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return ['RENAME INDEX myschema.idx_foo TO idx_bar']; } @@ -520,7 +520,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'RENAME INDEX "schema"."create" TO "select"', @@ -531,7 +531,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -539,7 +539,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return ['ALTER TABLE foo RENAME COLUMN bar TO baz']; } @@ -547,7 +547,7 @@ public function getAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'ALTER TABLE "foo" DROP FOREIGN KEY fk1', @@ -567,7 +567,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ 'COMMENT ON COLUMN foo.bar IS \'comment\'', @@ -580,7 +580,7 @@ protected function getCommentOnColumnSQL() : array * @group DBAL-944 * @dataProvider getGeneratesAlterColumnSQL */ - public function testGeneratesAlterColumnSQL(string $changedProperty, Column $column, ?string $expectedSQLClause = null) : void + public function testGeneratesAlterColumnSQL(string $changedProperty, Column $column, ?string $expectedSQLClause = null): void { $tableDiff = new TableDiff('foo'); $tableDiff->fromTable = new Table('foo'); @@ -600,7 +600,7 @@ public function testGeneratesAlterColumnSQL(string $changedProperty, Column $col /** * @return mixed[][] */ - public static function getGeneratesAlterColumnSQL() : iterable + public static function getGeneratesAlterColumnSQL(): iterable { return [ [ @@ -661,27 +661,27 @@ public static function getGeneratesAlterColumnSQL() : iterable ]; } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return ''; // not supported by this platform } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'TRUNCATE "select" IMMEDIATE'; } - protected function supportsInlineIndexDeclaration() : bool + protected function supportsInlineIndexDeclaration(): bool { return false; } - protected function supportsCommentOnStatement() : bool + protected function supportsCommentOnStatement(): bool { return true; } @@ -689,7 +689,7 @@ protected function supportsCommentOnStatement() : bool /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return [ 'ALTER TABLE mytable ALTER COLUMN name SET DATA TYPE CHAR(2)', @@ -700,7 +700,7 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return ['RENAME INDEX idx_foo TO idx_foo_renamed']; } @@ -708,7 +708,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : arra /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableColumnsSQL() : void + public function testQuotesTableNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -719,7 +719,7 @@ public function testQuotesTableNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -730,7 +730,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php index f8bbbf70ac5..ecd036146d4 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php @@ -8,12 +8,12 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new MariaDb1027Platform(); } - public function testHasNativeJsonType() : void + public function testHasNativeJsonType(): void { self::assertFalse($this->platform->hasNativeJsonType()); } @@ -23,12 +23,12 @@ public function testHasNativeJsonType() : void * * @link https://mariadb.com/kb/en/library/json-data-type/ */ - public function testReturnsJsonTypeDeclarationSQL() : void + public function testReturnsJsonTypeDeclarationSQL(): void { self::assertSame('LONGTEXT', $this->platform->getJsonTypeDeclarationSQL([])); } - public function testInitializesJsonTypeMapping() : void + public function testInitializesJsonTypeMapping(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json')); self::assertSame(Types::JSON, $this->platform->getDoctrineTypeMapping('json')); @@ -40,7 +40,7 @@ public function testInitializesJsonTypeMapping() : void * * @see AbstractMySQLPlatformTestCase::testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() */ - public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : void + public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes(): void { $this->markTestSkipped('MariaDB102Platform support propagation of default values for BLOB and TEXT columns'); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php index 0587f4cde6a..301387cfe09 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php @@ -8,22 +8,22 @@ class MySQL57PlatformTest extends AbstractMySQLPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new MySQL57Platform(); } - public function testHasNativeJsonType() : void + public function testHasNativeJsonType(): void { self::assertTrue($this->platform->hasNativeJsonType()); } - public function testReturnsJsonTypeDeclarationSQL() : void + public function testReturnsJsonTypeDeclarationSQL(): void { self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL([])); } - public function testInitializesJsonTypeMapping() : void + public function testInitializesJsonTypeMapping(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json')); self::assertSame(Types::JSON, $this->platform->getDoctrineTypeMapping('json')); @@ -34,7 +34,7 @@ public function testInitializesJsonTypeMapping() : void * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return ['ALTER TABLE mytable RENAME INDEX idx_foo TO idx_bar']; } @@ -44,7 +44,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'ALTER TABLE `table` RENAME INDEX `create` TO `select`', @@ -57,7 +57,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return ['ALTER TABLE myschema.mytable RENAME INDEX idx_foo TO idx_bar']; } @@ -67,7 +67,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'ALTER TABLE `schema`.`table` RENAME INDEX `create` TO `select`', @@ -78,7 +78,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return ['ALTER TABLE mytable RENAME INDEX idx_foo TO idx_foo_renamed']; } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php index e8007baf55f..b5727547915 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php @@ -8,12 +8,12 @@ class MySqlPlatformTest extends AbstractMySQLPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new MySqlPlatform(); } - public function testHasCorrectDefaultTransactionIsolationLevel() : void + public function testHasCorrectDefaultTransactionIsolationLevel(): void { self::assertEquals( TransactionIsolationLevel::REPEATABLE_READ, diff --git a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php index 4cd9013669f..68a8db28b93 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\Type; + use function array_walk; use function preg_replace; use function sprintf; @@ -28,7 +29,7 @@ class OraclePlatformTest extends AbstractPlatformTestCase /** * @return mixed[][] */ - public static function dataValidIdentifiers() : iterable + public static function dataValidIdentifiers(): iterable { return [ ['a'], @@ -46,7 +47,7 @@ public static function dataValidIdentifiers() : iterable /** * @dataProvider dataValidIdentifiers */ - public function testValidIdentifiers(string $identifier) : void + public function testValidIdentifiers(string $identifier): void { $platform = $this->createPlatform(); $platform->assertValidIdentifier($identifier); @@ -57,7 +58,7 @@ public function testValidIdentifiers(string $identifier) : void /** * @return mixed[][] */ - public static function dataInvalidIdentifiers() : iterable + public static function dataInvalidIdentifiers(): iterable { return [ ['1'], @@ -71,7 +72,7 @@ public static function dataInvalidIdentifiers() : iterable /** * @dataProvider dataInvalidIdentifiers */ - public function testInvalidIdentifiers(string $identifier) : void + public function testInvalidIdentifiers(string $identifier): void { $this->expectException(DBALException::class); @@ -82,12 +83,12 @@ public function testInvalidIdentifiers(string $identifier) : void /** * @return OraclePlatform */ - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new OraclePlatform(); } - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id NUMBER(10) NOT NULL, test VARCHAR2(255) DEFAULT NULL NULL, PRIMARY KEY(id))'; } @@ -95,7 +96,7 @@ public function getGenerateTableSql() : string /** * {@inheritDoc} */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return [ 'CREATE TABLE test (foo VARCHAR2(255) DEFAULT NULL NULL, bar VARCHAR2(255) DEFAULT NULL NULL)', @@ -106,7 +107,7 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return [ 'ALTER TABLE mytable ADD (quota NUMBER(10) DEFAULT NULL NULL)', @@ -116,20 +117,20 @@ public function getGenerateAlterTableSql() : array ]; } - public function testRLike() : void + public function testRLike(): void { $this->expectException(DBALException::class); self::assertEquals('RLIKE', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct'); } - public function testGeneratesSqlSnippets() : void + public function testGeneratesSqlSnippets(): void { self::assertEquals('"', $this->platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); self::assertEquals('column1 || column2 || column3', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); } - public function testGeneratesTransactionsCommands() : void + public function testGeneratesTransactionsCommands(): void { self::assertEquals( 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', @@ -149,24 +150,24 @@ public function testGeneratesTransactionsCommands() : void ); } - public function testCreateDatabaseThrowsException() : void + public function testCreateDatabaseThrowsException(): void { $this->expectException(DBALException::class); self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar')); } - public function testDropDatabaseThrowsException() : void + public function testDropDatabaseThrowsException(): void { self::assertEquals('DROP USER foobar CASCADE', $this->platform->getDropDatabaseSQL('foobar')); } - public function testDropTable() : void + public function testDropTable(): void { self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar')); } - public function testGeneratesTypeDeclarationForIntegers() : void + public function testGeneratesTypeDeclarationForIntegers(): void { self::assertEquals( 'NUMBER(10)', @@ -184,7 +185,7 @@ public function testGeneratesTypeDeclarationForIntegers() : void ); } - public function testGeneratesTypeDeclarationsForStrings() : void + public function testGeneratesTypeDeclarationsForStrings(): void { self::assertEquals( 'CHAR(10)', @@ -204,37 +205,37 @@ public function testGeneratesTypeDeclarationsForStrings() : void ); } - public function testPrefersIdentityColumns() : void + public function testPrefersIdentityColumns(): void { self::assertFalse($this->platform->prefersIdentityColumns()); } - public function testSupportsIdentityColumns() : void + public function testSupportsIdentityColumns(): void { self::assertFalse($this->platform->supportsIdentityColumns()); } - public function testSupportsSavePoints() : void + public function testSupportsSavePoints(): void { self::assertTrue($this->platform->supportsSavepoints()); } - protected function supportsCommentOnStatement() : bool + protected function supportsCommentOnStatement(): bool { return true; } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } - protected function getGenerateForeignKeySql() : string + protected function getGenerateForeignKeySql(): string { return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; } @@ -245,7 +246,7 @@ protected function getGenerateForeignKeySql() : string * @group DBAL-1097 * @dataProvider getGeneratesAdvancedForeignKeyOptionsSQLData */ - public function testGeneratesAdvancedForeignKeyOptionsSQL(array $options, string $expectedSql) : void + public function testGeneratesAdvancedForeignKeyOptionsSQL(array $options, string $expectedSql): void { $foreignKey = new ForeignKeyConstraint(['foo'], 'foreign_table', ['bar'], null, $options); @@ -255,7 +256,7 @@ public function testGeneratesAdvancedForeignKeyOptionsSQL(array $options, string /** * @return mixed[][] */ - public static function getGeneratesAdvancedForeignKeyOptionsSQLData() : iterable + public static function getGeneratesAdvancedForeignKeyOptionsSQLData(): iterable { return [ [[], ''], @@ -270,7 +271,7 @@ public static function getGeneratesAdvancedForeignKeyOptionsSQLData() : iterable /** * {@inheritdoc} */ - public static function getReturnsForeignKeyReferentialActionSQL() : iterable + public static function getReturnsForeignKeyReferentialActionSQL(): iterable { return [ ['CASCADE', 'CASCADE'], @@ -281,43 +282,43 @@ public static function getReturnsForeignKeyReferentialActionSQL() : iterable ]; } - public function testModifyLimitQuery() : void + public function testModifyLimitQuery(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0); self::assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql); } - public function testModifyLimitQueryWithEmptyOffset() : void + public function testModifyLimitQueryWithEmptyOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10); self::assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql); } - public function testModifyLimitQueryWithNonEmptyOffset() : void + public function testModifyLimitQueryWithNonEmptyOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 10); self::assertEquals('SELECT * FROM (SELECT a.*, ROWNUM AS doctrine_rownum FROM (SELECT * FROM user) a WHERE ROWNUM <= 20) WHERE doctrine_rownum >= 11', $sql); } - public function testModifyLimitQueryWithEmptyLimit() : void + public function testModifyLimitQueryWithEmptyLimit(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', null, 10); self::assertEquals('SELECT * FROM (SELECT a.*, ROWNUM AS doctrine_rownum FROM (SELECT * FROM user) a) WHERE doctrine_rownum >= 11', $sql); } - public function testModifyLimitQueryWithAscOrderBy() : void + public function testModifyLimitQueryWithAscOrderBy(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10); self::assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username ASC) a WHERE ROWNUM <= 10', $sql); } - public function testModifyLimitQueryWithDescOrderBy() : void + public function testModifyLimitQueryWithDescOrderBy(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10); self::assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username DESC) a WHERE ROWNUM <= 10', $sql); } - public function testGenerateTableWithAutoincrement() : void + public function testGenerateTableWithAutoincrement(): void { $columnName = strtoupper('id' . uniqid()); $tableName = strtoupper('table' . uniqid()); @@ -351,7 +352,7 @@ public function testGenerateTableWithAutoincrement() : void ]; $statements = $this->platform->getCreateTableSQL($table); //strip all the whitespace from the statements - array_walk($statements, static function (&$value) : void { + array_walk($statements, static function (&$value): void { $value = preg_replace('/\s+/', ' ', $value); }); foreach ($targets as $key => $sql) { @@ -363,7 +364,7 @@ public function testGenerateTableWithAutoincrement() : void /** * {@inheritDoc} */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { return [ 'CREATE TABLE test (id NUMBER(10) NOT NULL, PRIMARY KEY(id))', @@ -374,7 +375,7 @@ public function getCreateTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { return [ 'CREATE TABLE test (id NUMBER(10) NOT NULL, data CLOB NOT NULL, PRIMARY KEY(id))', @@ -385,7 +386,7 @@ public function getCreateTableColumnTypeCommentsSQL() : array /** * {@inheritDoc} */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { return [ 'ALTER TABLE mytable ADD (quota NUMBER(10) NOT NULL)', @@ -395,12 +396,12 @@ public function getAlterTableColumnCommentsSQL() : array ]; } - public function getBitAndComparisonExpressionSql(string $value1, string $value2) : string + public function getBitAndComparisonExpressionSql(string $value1, string $value2): string { return 'BITAND(' . $value1 . ', ' . $value2 . ')'; } - public function getBitOrComparisonExpressionSql(string $value1, string $value2) : string + public function getBitOrComparisonExpressionSql(string $value1, string $value2): string { return '(' . $value1 . '-' . $this->getBitAndComparisonExpressionSql($value1, $value2) @@ -410,7 +411,7 @@ public function getBitOrComparisonExpressionSql(string $value1, string $value2) /** * {@inheritDoc} */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL, PRIMARY KEY("create"))']; } @@ -418,7 +419,7 @@ protected function getQuotedColumnInPrimaryKeySQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL)', @@ -429,7 +430,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return [ 'CREATE TABLE test (column1 VARCHAR2(255) NOT NULL)', @@ -440,7 +441,7 @@ protected function getQuotedNameInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL, foo VARCHAR2(255) NOT NULL, "bar" VARCHAR2(255) NOT NULL)', @@ -454,7 +455,7 @@ protected function getQuotedColumnInForeignKeySQL() : array * @group DBAL-472 * @group DBAL-1001 */ - public function testAlterTableNotNULL() : void + public function testAlterTableNotNULL(): void { $tableDiff = new TableDiff('mytable'); $tableDiff->changedColumns['foo'] = new ColumnDiff( @@ -492,7 +493,7 @@ public function testAlterTableNotNULL() : void /** * @group DBAL-2555 */ - public function testInitializesDoctrineTypeMappings() : void + public function testInitializesDoctrineTypeMappings(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('long raw')); self::assertSame('blob', $this->platform->getDoctrineTypeMapping('long raw')); @@ -504,12 +505,12 @@ public function testInitializesDoctrineTypeMappings() : void self::assertSame('date', $this->platform->getDoctrineTypeMapping('date')); } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 2000; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('RAW(255)', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('RAW(2000)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -524,13 +525,13 @@ public function testReturnsBinaryTypeDeclarationSQL() : void * @group legacy * @expectedDeprecation Binary field length 2001 is greater than supported by the platform (2000). Reduce the field length or use a BLOB field instead. */ - public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void + public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL(): void { self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 2001])); self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 2001])); } - public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType() : void + public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType(): void { $table1 = new Table('mytable'); $table1->addColumn('column_varbinary', 'binary'); @@ -550,7 +551,7 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType() : v /** * @group DBAL-563 */ - public function testUsesSequenceEmulatedIdentityColumns() : void + public function testUsesSequenceEmulatedIdentityColumns(): void { self::assertTrue($this->platform->usesSequenceEmulatedIdentityColumns()); } @@ -559,7 +560,7 @@ public function testUsesSequenceEmulatedIdentityColumns() : void * @group DBAL-563 * @group DBAL-831 */ - public function testReturnsIdentitySequenceName() : void + public function testReturnsIdentitySequenceName(): void { self::assertSame('MYTABLE_SEQ', $this->platform->getIdentitySequenceName('mytable', 'mycolumn')); self::assertSame('"mytable_SEQ"', $this->platform->getIdentitySequenceName('"mytable"', 'mycolumn')); @@ -571,7 +572,7 @@ public function testReturnsIdentitySequenceName() : void * @dataProvider dataCreateSequenceWithCache * @group DBAL-139 */ - public function testCreateSequenceWithCache(int $cacheSize, string $expectedSql) : void + public function testCreateSequenceWithCache(int $cacheSize, string $expectedSql): void { $sequence = new Sequence('foo', 1, 1, $cacheSize); self::assertStringContainsString($expectedSql, $this->platform->getCreateSequenceSQL($sequence)); @@ -580,7 +581,7 @@ public function testCreateSequenceWithCache(int $cacheSize, string $expectedSql) /** * @return mixed[][] */ - public static function dataCreateSequenceWithCache() : iterable + public static function dataCreateSequenceWithCache(): iterable { return [ [1, 'NOCACHE'], @@ -594,7 +595,7 @@ public static function dataCreateSequenceWithCache() : iterable * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return ['ALTER INDEX idx_foo RENAME TO idx_bar']; } @@ -604,7 +605,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'ALTER INDEX "create" RENAME TO "select"', @@ -615,7 +616,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return [ 'ALTER TABLE mytable RENAME COLUMN unquoted1 TO unquoted', @@ -633,7 +634,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { $this->markTestIncomplete('Not implemented yet'); } @@ -643,7 +644,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return ['ALTER INDEX myschema.idx_foo RENAME TO idx_bar']; } @@ -653,7 +654,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'ALTER INDEX "schema"."create" RENAME TO "select"', @@ -661,7 +662,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array ]; } - protected function getQuotesDropForeignKeySQL() : string + protected function getQuotesDropForeignKeySQL(): string { return 'ALTER TABLE "table" DROP CONSTRAINT "select"'; } @@ -669,7 +670,7 @@ protected function getQuotesDropForeignKeySQL() : string /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -677,7 +678,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return ['ALTER TABLE foo RENAME COLUMN bar TO baz']; } @@ -688,7 +689,7 @@ public function getAlterTableRenameColumnSQL() : array * @dataProvider getReturnsDropAutoincrementSQL * @group DBAL-831 */ - public function testReturnsDropAutoincrementSQL(string $table, array $expectedSql) : void + public function testReturnsDropAutoincrementSQL(string $table, array $expectedSql): void { self::assertSame($expectedSql, $this->platform->getDropAutoincrementSql($table)); } @@ -696,7 +697,7 @@ public function testReturnsDropAutoincrementSQL(string $table, array $expectedSq /** * @return mixed[][] */ - public static function getReturnsDropAutoincrementSQL() : iterable + public static function getReturnsDropAutoincrementSQL(): iterable { return [ [ @@ -729,7 +730,7 @@ public static function getReturnsDropAutoincrementSQL() : iterable /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'ALTER TABLE "foo" DROP CONSTRAINT fk1', @@ -747,7 +748,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ 'COMMENT ON COLUMN foo.bar IS \'comment\'', @@ -759,7 +760,7 @@ protected function getCommentOnColumnSQL() : array /** * @group DBAL-1004 */ - public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() : void + public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers(): void { $table1 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'))]); $table2 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'), ['comment' => 'baz'])]); @@ -775,7 +776,7 @@ public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() : ); } - public function testQuotedTableNames() : void + public function testQuotedTableNames(): void { $table = new Table('"test"'); $table->addColumn('"id"', 'integer', ['autoincrement' => true]); @@ -819,7 +820,7 @@ public function testQuotedTableNames() : void * @dataProvider getReturnsGetListTableColumnsSQL * @group DBAL-831 */ - public function testReturnsGetListTableColumnsSQL(?string $database, string $expectedSql) : void + public function testReturnsGetListTableColumnsSQL(?string $database, string $expectedSql): void { // note: this assertion is a bit strict, as it compares a full SQL string. // Should this break in future, then please try to reduce the matching to substring matching while reworking @@ -830,7 +831,7 @@ public function testReturnsGetListTableColumnsSQL(?string $database, string $exp /** * @return mixed[][] */ - public static function getReturnsGetListTableColumnsSQL() : iterable + public static function getReturnsGetListTableColumnsSQL(): iterable { return [ [ @@ -884,17 +885,17 @@ public static function getReturnsGetListTableColumnsSQL() : iterable ]; } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return 'INDEX "select" (foo)'; } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'TRUNCATE TABLE "select"'; } @@ -902,7 +903,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL() : string /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return ['ALTER TABLE mytable MODIFY (name CHAR(2) DEFAULT NULL)']; } @@ -910,7 +911,7 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return ['ALTER INDEX idx_foo RENAME TO idx_foo_renamed']; } @@ -918,7 +919,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : arra /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInListSequencesSQL() : void + public function testQuotesDatabaseNameInListSequencesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -929,7 +930,7 @@ public function testQuotesDatabaseNameInListSequencesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -940,7 +941,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -951,7 +952,7 @@ public function testQuotesTableNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableConstraintsSQL() : void + public function testQuotesTableNameInListTableConstraintsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -962,7 +963,7 @@ public function testQuotesTableNameInListTableConstraintsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableColumnsSQL() : void + public function testQuotesTableNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -973,7 +974,7 @@ public function testQuotesTableNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInListTableColumnsSQL() : void + public function testQuotesDatabaseNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php index 0734c603017..5b1d8593fb3 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php @@ -9,12 +9,12 @@ class PostgreSQL100PlatformTest extends PostgreSQL94PlatformTest { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new PostgreSQL100Platform(); } - public function testGetListSequencesSQL() : void + public function testGetListSequencesSQL(): void { self::assertSame( "SELECT sequence_name AS relname, diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php index 3ed82529e08..563a7cc2414 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php @@ -8,17 +8,17 @@ class PostgreSQL91PlatformTest extends PostgreSqlPlatformTest { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new PostgreSQL91Platform(); } - public function testSupportsColumnCollation() : void + public function testSupportsColumnCollation(): void { self::assertTrue($this->platform->supportsColumnCollation()); } - public function testColumnCollationDeclarationSQL() : void + public function testColumnCollationDeclarationSQL(): void { self::assertSame( 'COLLATE "en_US.UTF-8"', @@ -26,7 +26,7 @@ public function testColumnCollationDeclarationSQL() : void ); } - public function testGetCreateTableSQLWithColumnCollation() : void + public function testGetCreateTableSQLWithColumnCollation(): void { $table = new Table('foo'); $table->addColumn('no_collation', 'string'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php index 04e9d953480..2ae9c4c6f2d 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php @@ -16,7 +16,7 @@ class PostgreSQL92PlatformTest extends AbstractPostgreSqlPlatformTestCase * * @return PostgreSQL92Platform */ - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new PostgreSQL92Platform(); } @@ -24,7 +24,7 @@ public function createPlatform() : AbstractPlatform /** * @group DBAL-553 */ - public function testHasNativeJsonType() : void + public function testHasNativeJsonType(): void { self::assertTrue($this->platform->hasNativeJsonType()); } @@ -32,12 +32,12 @@ public function testHasNativeJsonType() : void /** * @group DBAL-553 */ - public function testReturnsJsonTypeDeclarationSQL() : void + public function testReturnsJsonTypeDeclarationSQL(): void { self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL([])); } - public function testReturnsSmallIntTypeDeclarationSQL() : void + public function testReturnsSmallIntTypeDeclarationSQL(): void { self::assertSame( 'SMALLSERIAL', @@ -58,7 +58,7 @@ public function testReturnsSmallIntTypeDeclarationSQL() : void /** * @group DBAL-553 */ - public function testInitializesJsonTypeMapping() : void + public function testInitializesJsonTypeMapping(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json')); self::assertEquals(Types::JSON, $this->platform->getDoctrineTypeMapping('json')); @@ -67,7 +67,7 @@ public function testInitializesJsonTypeMapping() : void /** * @group DBAL-1220 */ - public function testReturnsCloseActiveDatabaseConnectionsSQL() : void + public function testReturnsCloseActiveDatabaseConnectionsSQL(): void { self::assertSame( "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'foo'", diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php index 36e53491848..86e2a89c487 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php @@ -8,19 +8,19 @@ class PostgreSQL94PlatformTest extends PostgreSQL92PlatformTest { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new PostgreSQL94Platform(); } - public function testReturnsJsonTypeDeclarationSQL() : void + public function testReturnsJsonTypeDeclarationSQL(): void { parent::testReturnsJsonTypeDeclarationSQL(); self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => false])); self::assertSame('JSONB', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => true])); } - public function testInitializesJsonTypeMapping() : void + public function testInitializesJsonTypeMapping(): void { parent::testInitializesJsonTypeMapping(); self::assertTrue($this->platform->hasDoctrineTypeMappingFor('jsonb')); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php index 0b029d3497d..b4ef3b8d3b2 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php @@ -8,17 +8,17 @@ class PostgreSqlPlatformTest extends AbstractPostgreSqlPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new PostgreSqlPlatform(); } - public function testSupportsPartialIndexes() : void + public function testSupportsPartialIndexes(): void { self::assertTrue($this->platform->supportsPartialIndexes()); } - public function testGetCreateTableSQLWithColumnCollation() : void + public function testGetCreateTableSQLWithColumnCollation(): void { $table = new Table('foo'); $table->addColumn('id', 'string'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php b/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php index 8d07f62274d..36340db352d 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php @@ -12,12 +12,12 @@ class ReservedKeywordsValidatorTest extends DbalTestCase /** @var ReservedKeywordsValidator */ private $validator; - protected function setUp() : void + protected function setUp(): void { $this->validator = new ReservedKeywordsValidator([new MySQLKeywords()]); } - public function testReservedTableName() : void + public function testReservedTableName(): void { $table = new Table('TABLE'); $this->validator->acceptTable($table); @@ -28,7 +28,7 @@ public function testReservedTableName() : void ); } - public function testReservedColumnName() : void + public function testReservedColumnName(): void { $table = new Table('TABLE'); $column = $table->addColumn('table', 'string'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php index bf3f7372df3..d899b32d018 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php @@ -10,17 +10,17 @@ class SQLAnywhere11PlatformTest extends SQLAnywherePlatformTest /** @var SQLAnywhere11Platform */ protected $platform; - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLAnywhere11Platform(); } - public function testDoesNotSupportRegexp() : void + public function testDoesNotSupportRegexp(): void { $this->markTestSkipped('This version of the platform now supports regular expressions.'); } - public function testGeneratesRegularExpressionSQLSnippet() : void + public function testGeneratesRegularExpressionSQLSnippet(): void { self::assertEquals('REGEXP', $this->platform->getRegexpExpression()); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php index 5e2882a9168..221fa82f612 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php @@ -12,22 +12,22 @@ class SQLAnywhere12PlatformTest extends SQLAnywhere11PlatformTest /** @var SQLAnywhere12Platform */ protected $platform; - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLAnywhere12Platform(); } - public function testDoesNotSupportSequences() : void + public function testDoesNotSupportSequences(): void { $this->markTestSkipped('This version of the platform now supports sequences.'); } - public function testSupportsSequences() : void + public function testSupportsSequences(): void { self::assertTrue($this->platform->supportsSequences()); } - public function testGeneratesSequenceSqlCommands() : void + public function testGeneratesSequenceSqlCommands(): void { $sequence = new Sequence('myseq', 20, 1); self::assertEquals( @@ -56,7 +56,7 @@ public function testGeneratesSequenceSqlCommands() : void ); } - public function testGeneratesDateTimeTzColumnTypeDeclarationSQL() : void + public function testGeneratesDateTimeTzColumnTypeDeclarationSQL(): void { self::assertEquals( 'TIMESTAMP WITH TIME ZONE', @@ -69,18 +69,18 @@ public function testGeneratesDateTimeTzColumnTypeDeclarationSQL() : void ); } - public function testHasCorrectDateTimeTzFormatString() : void + public function testHasCorrectDateTimeTzFormatString(): void { self::assertEquals('Y-m-d H:i:s.uP', $this->platform->getDateTimeTzFormatString()); } - public function testInitializesDateTimeTzTypeMapping() : void + public function testInitializesDateTimeTzTypeMapping(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('timestamp with time zone')); self::assertEquals('datetime', $this->platform->getDoctrineTypeMapping('timestamp with time zone')); } - public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL() : void + public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL(): void { self::assertEquals( 'CREATE VIRTUAL UNIQUE CLUSTERED INDEX fooindex ON footable (a, b) WITH NULLS NOT DISTINCT FOR OLAP WORKLOAD', diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php index a6a0018a06e..e0c4a24a21a 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php @@ -8,12 +8,12 @@ class SQLAnywhere16PlatformTest extends SQLAnywhere12PlatformTest { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLAnywhere16Platform(); } - public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL() : void + public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL(): void { self::assertEquals( 'CREATE UNIQUE INDEX fooindex ON footable (a, b) WITH NULLS DISTINCT', @@ -62,7 +62,7 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL() : void parent::testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL(); } - public function testThrowsExceptionOnInvalidWithNullsNotDistinctIndexOptions() : void + public function testThrowsExceptionOnInvalidWithNullsNotDistinctIndexOptions(): void { $this->expectException('UnexpectedValueException'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php index c3dcf6ae1af..234a4f36ed2 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php @@ -18,6 +18,7 @@ use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\Type; use InvalidArgumentException; + use function mt_rand; use function strlen; use function substr; @@ -27,7 +28,7 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase /** @var SQLAnywherePlatform */ protected $platform; - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLAnywherePlatform(); } @@ -35,7 +36,7 @@ public function createPlatform() : AbstractPlatform /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return [ "ALTER TABLE mytable ADD quota INT DEFAULT NULL, DROP foo, ALTER baz VARCHAR(1) DEFAULT 'def' NOT NULL, ALTER bloo BIT DEFAULT '0' NOT NULL", @@ -43,17 +44,17 @@ public function getGenerateAlterTableSql() : array ]; } - protected function getGenerateForeignKeySql() : string + protected function getGenerateForeignKeySql(): string { return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY (id))'; } @@ -61,7 +62,7 @@ public function getGenerateTableSql() : string /** * {@inheritDoc} */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return [ 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)', @@ -69,7 +70,7 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array ]; } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } @@ -77,7 +78,7 @@ public function getGenerateUniqueIndexSql() : string /** * {@inheritDoc} */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL, CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES "foreign" ("create", bar, "foo-bar"), CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES foo ("create", bar, "foo-bar"), CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ("create", foo, "bar") REFERENCES "foo-bar" ("create", bar, "foo-bar"))']; } @@ -85,7 +86,7 @@ protected function getQuotedColumnInForeignKeySQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)', @@ -96,7 +97,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return [ 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', @@ -107,7 +108,7 @@ protected function getQuotedNameInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY ("create"))']; } @@ -115,7 +116,7 @@ protected function getQuotedColumnInPrimaryKeySQL() : array /** * {@inheritDoc} */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { return [ 'CREATE TABLE test (id INT NOT NULL, PRIMARY KEY (id))', @@ -126,7 +127,7 @@ public function getCreateTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { return [ 'ALTER TABLE mytable ADD quota INT NOT NULL', @@ -139,7 +140,7 @@ public function getAlterTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { return [ 'CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY (id))', @@ -147,12 +148,12 @@ public function getCreateTableColumnTypeCommentsSQL() : array ]; } - public function testHasCorrectPlatformName() : void + public function testHasCorrectPlatformName(): void { self::assertEquals('sqlanywhere', $this->platform->getName()); } - public function testGeneratesCreateTableSQLWithCommonIndexes() : void + public function testGeneratesCreateTableSQLWithCommonIndexes(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -171,7 +172,7 @@ public function testGeneratesCreateTableSQLWithCommonIndexes() : void ); } - public function testGeneratesCreateTableSQLWithForeignKeyConstraints() : void + public function testGeneratesCreateTableSQLWithForeignKeyConstraints(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -196,7 +197,7 @@ public function testGeneratesCreateTableSQLWithForeignKeyConstraints() : void ); } - public function testGeneratesCreateTableSQLWithCheckConstraints() : void + public function testGeneratesCreateTableSQLWithCheckConstraints(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -210,7 +211,7 @@ public function testGeneratesCreateTableSQLWithCheckConstraints() : void ); } - public function testGeneratesTableAlterationWithRemovedColumnCommentSql() : void + public function testGeneratesTableAlterationWithRemovedColumnCommentSql(): void { $table = new Table('mytable'); $table->addColumn('foo', 'string', ['comment' => 'foo comment']); @@ -234,7 +235,7 @@ public function testGeneratesTableAlterationWithRemovedColumnCommentSql() : void * * @dataProvider getLockHints */ - public function testAppendsLockHint($lockMode, string $lockHint) : void + public function testAppendsLockHint($lockMode, string $lockHint): void { $fromClause = 'FROM users'; $expectedResult = $fromClause . $lockHint; @@ -245,7 +246,7 @@ public function testAppendsLockHint($lockMode, string $lockHint) : void /** * @return mixed[][] */ - public static function getLockHints() : iterable + public static function getLockHints(): iterable { return [ [null, ''], @@ -258,12 +259,12 @@ public static function getLockHints() : iterable ]; } - public function testHasCorrectMaxIdentifierLength() : void + public function testHasCorrectMaxIdentifierLength(): void { self::assertEquals(128, $this->platform->getMaxIdentifierLength()); } - public function testFixesSchemaElementNames() : void + public function testFixesSchemaElementNames(): void { $maxIdentifierLength = $this->platform->getMaxIdentifierLength(); $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; @@ -285,7 +286,7 @@ public function testFixesSchemaElementNames() : void ); } - public function testGeneratesColumnTypesDeclarationSQL() : void + public function testGeneratesColumnTypesDeclarationSQL(): void { $fullColumnDef = [ 'length' => 10, @@ -315,12 +316,12 @@ public function testGeneratesColumnTypesDeclarationSQL() : void self::assertEquals(32767, $this->platform->getVarcharMaxLength()); } - public function testHasNativeGuidType() : void + public function testHasNativeGuidType(): void { self::assertTrue($this->platform->hasNativeGuidType()); } - public function testGeneratesDDLSnippets() : void + public function testGeneratesDDLSnippets(): void { self::assertEquals("CREATE DATABASE 'foobar'", $this->platform->getCreateDatabaseSQL('foobar')); self::assertEquals("CREATE DATABASE 'foobar'", $this->platform->getCreateDatabaseSQL('"foobar"')); @@ -343,7 +344,7 @@ public function testGeneratesDDLSnippets() : void self::assertEquals('DROP VIEW fooview', $this->platform->getDropViewSQL('fooview')); } - public function testGeneratesPrimaryKeyDeclarationSQL() : void + public function testGeneratesPrimaryKeyDeclarationSQL(): void { self::assertEquals( 'CONSTRAINT pk PRIMARY KEY CLUSTERED (a, b)', @@ -360,14 +361,14 @@ public function testGeneratesPrimaryKeyDeclarationSQL() : void ); } - public function testCannotGeneratePrimaryKeyDeclarationSQLWithEmptyColumns() : void + public function testCannotGeneratePrimaryKeyDeclarationSQLWithEmptyColumns(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getPrimaryKeyDeclarationSQL(new Index('pk', [], true, true)); } - public function testGeneratesCreateUnnamedPrimaryKeySQL() : void + public function testGeneratesCreateUnnamedPrimaryKeySQL(): void { self::assertEquals( 'ALTER TABLE foo ADD PRIMARY KEY CLUSTERED (a, b)', @@ -385,7 +386,7 @@ public function testGeneratesCreateUnnamedPrimaryKeySQL() : void ); } - public function testGeneratesUniqueConstraintDeclarationSQL() : void + public function testGeneratesUniqueConstraintDeclarationSQL(): void { self::assertEquals( 'CONSTRAINT unique_constraint UNIQUE CLUSTERED (a, b)', @@ -400,14 +401,14 @@ public function testGeneratesUniqueConstraintDeclarationSQL() : void ); } - public function testCannotGenerateUniqueConstraintDeclarationSQLWithEmptyColumns() : void + public function testCannotGenerateUniqueConstraintDeclarationSQLWithEmptyColumns(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getUniqueConstraintDeclarationSQL('constr', new Index('constr', [], true)); } - public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL() : void + public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL(): void { self::assertEquals( 'CONSTRAINT fk ' . @@ -434,7 +435,7 @@ public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL ); } - public function testGeneratesForeignKeyMatchClausesSQL() : void + public function testGeneratesForeignKeyMatchClausesSQL(): void { self::assertEquals('SIMPLE', $this->platform->getForeignKeyMatchClauseSQL(1)); self::assertEquals('FULL', $this->platform->getForeignKeyMatchClauseSQL(2)); @@ -442,46 +443,46 @@ public function testGeneratesForeignKeyMatchClausesSQL() : void self::assertEquals('UNIQUE FULL', $this->platform->getForeignKeyMatchClauseSQL(130)); } - public function testCannotGenerateInvalidForeignKeyMatchClauseSQL() : void + public function testCannotGenerateInvalidForeignKeyMatchClauseSQL(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getForeignKeyMatchCLauseSQL(3); } - public function testCannotGenerateForeignKeyConstraintSQLWithEmptyLocalColumns() : void + public function testCannotGenerateForeignKeyConstraintSQLWithEmptyLocalColumns(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint([], 'foreign_tbl', ['c', 'd'])); } - public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignColumns() : void + public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignColumns(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(['a', 'b'], 'foreign_tbl', [])); } - public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignTableName() : void + public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignTableName(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(['a', 'b'], '', ['c', 'd'])); } - public function testCannotGenerateCommonIndexWithCreateConstraintSQL() : void + public function testCannotGenerateCommonIndexWithCreateConstraintSQL(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getCreateConstraintSQL(new Index('fooindex', []), new Table('footable')); } - public function testCannotGenerateCustomConstraintWithCreateConstraintSQL() : void + public function testCannotGenerateCustomConstraintWithCreateConstraintSQL(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getCreateConstraintSQL($this->createMock(Constraint::class), 'footable'); } - public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL() : void + public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL(): void { self::assertEquals( 'CREATE VIRTUAL UNIQUE CLUSTERED INDEX fooindex ON footable (a, b) FOR OLAP WORKLOAD', @@ -498,14 +499,14 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL() : void ); } - public function testDoesNotSupportIndexDeclarationInCreateAlterTableStatements() : void + public function testDoesNotSupportIndexDeclarationInCreateAlterTableStatements(): void { $this->expectException(DBALException::class); $this->platform->getIndexDeclarationSQL('index', new Index('index', [])); } - public function testGeneratesDropIndexSQL() : void + public function testGeneratesDropIndexSQL(): void { $index = new Index('fooindex', []); @@ -520,7 +521,7 @@ public function testGeneratesDropIndexSQL() : void /** * @psalm-suppress InvalidArgument */ - public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter() : void + public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter(): void { $this->expectException(InvalidArgumentException::class); @@ -530,14 +531,14 @@ public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter() : void /** * @psalm-suppress InvalidArgument */ - public function testCannotGenerateDropIndexSQLWithInvalidTableParameter() : void + public function testCannotGenerateDropIndexSQLWithInvalidTableParameter(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getDropIndexSQL('index', ['table']); } - public function testGeneratesSQLSnippets() : void + public function testGeneratesSQLSnippets(): void { self::assertEquals('STRING(column1, "string1", column2, "string2")', $this->platform->getConcatExpression( 'column1', @@ -611,14 +612,14 @@ public function testGeneratesSQLSnippets() : void ); } - public function testDoesNotSupportRegexp() : void + public function testDoesNotSupportRegexp(): void { $this->expectException(DBALException::class); $this->platform->getRegexpExpression(); } - public function testHasCorrectDateTimeTzFormatString() : void + public function testHasCorrectDateTimeTzFormatString(): void { // Date time type with timezone is not supported before version 12. // For versions before we have to ensure that the date time with timezone format @@ -626,7 +627,7 @@ public function testHasCorrectDateTimeTzFormatString() : void self::assertEquals($this->platform->getDateTimeFormatString(), $this->platform->getDateTimeTzFormatString()); } - public function testHasCorrectDefaultTransactionIsolationLevel() : void + public function testHasCorrectDefaultTransactionIsolationLevel(): void { self::assertEquals( TransactionIsolationLevel::READ_UNCOMMITTED, @@ -634,7 +635,7 @@ public function testHasCorrectDefaultTransactionIsolationLevel() : void ); } - public function testGeneratesTransactionsCommands() : void + public function testGeneratesTransactionsCommands(): void { self::assertEquals( 'SET TEMPORARY OPTION isolation_level = 0', @@ -654,14 +655,14 @@ public function testGeneratesTransactionsCommands() : void ); } - public function testCannotGenerateTransactionCommandWithInvalidIsolationLevel() : void + public function testCannotGenerateTransactionCommandWithInvalidIsolationLevel(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getSetTransactionIsolationSQL('invalid_transaction_isolation_level'); } - public function testModifiesLimitQuery() : void + public function testModifiesLimitQuery(): void { self::assertEquals( 'SELECT TOP 10 * FROM user', @@ -669,7 +670,7 @@ public function testModifiesLimitQuery() : void ); } - public function testModifiesLimitQueryWithEmptyOffset() : void + public function testModifiesLimitQueryWithEmptyOffset(): void { self::assertEquals( 'SELECT TOP 10 * FROM user', @@ -677,7 +678,7 @@ public function testModifiesLimitQueryWithEmptyOffset() : void ); } - public function testModifiesLimitQueryWithOffset() : void + public function testModifiesLimitQueryWithOffset(): void { self::assertEquals( 'SELECT TOP 10 START AT 6 * FROM user', @@ -689,7 +690,7 @@ public function testModifiesLimitQueryWithOffset() : void ); } - public function testModifiesLimitQueryWithSubSelect() : void + public function testModifiesLimitQueryWithSubSelect(): void { self::assertEquals( 'SELECT TOP 10 * FROM (SELECT u.id as uid, u.name as uname FROM user) AS doctrine_tbl', @@ -697,7 +698,7 @@ public function testModifiesLimitQueryWithSubSelect() : void ); } - public function testModifiesLimitQueryWithoutLimit() : void + public function testModifiesLimitQueryWithoutLimit(): void { self::assertEquals( 'SELECT TOP ALL START AT 11 n FROM Foo', @@ -705,97 +706,97 @@ public function testModifiesLimitQueryWithoutLimit() : void ); } - public function testPrefersIdentityColumns() : void + public function testPrefersIdentityColumns(): void { self::assertTrue($this->platform->prefersIdentityColumns()); } - public function testDoesNotPreferSequences() : void + public function testDoesNotPreferSequences(): void { self::assertFalse($this->platform->prefersSequences()); } - public function testSupportsIdentityColumns() : void + public function testSupportsIdentityColumns(): void { self::assertTrue($this->platform->supportsIdentityColumns()); } - public function testSupportsPrimaryConstraints() : void + public function testSupportsPrimaryConstraints(): void { self::assertTrue($this->platform->supportsPrimaryConstraints()); } - public function testSupportsForeignKeyConstraints() : void + public function testSupportsForeignKeyConstraints(): void { self::assertTrue($this->platform->supportsForeignKeyConstraints()); } - public function testSupportsForeignKeyOnUpdate() : void + public function testSupportsForeignKeyOnUpdate(): void { self::assertTrue($this->platform->supportsForeignKeyOnUpdate()); } - public function testSupportsAlterTable() : void + public function testSupportsAlterTable(): void { self::assertTrue($this->platform->supportsAlterTable()); } - public function testSupportsTransactions() : void + public function testSupportsTransactions(): void { self::assertTrue($this->platform->supportsTransactions()); } - public function testSupportsSchemas() : void + public function testSupportsSchemas(): void { self::assertFalse($this->platform->supportsSchemas()); } - public function testSupportsIndexes() : void + public function testSupportsIndexes(): void { self::assertTrue($this->platform->supportsIndexes()); } - public function testSupportsCommentOnStatement() : void + public function testSupportsCommentOnStatement(): void { self::assertTrue($this->platform->supportsCommentOnStatement()); } - public function testSupportsSavePoints() : void + public function testSupportsSavePoints(): void { self::assertTrue($this->platform->supportsSavepoints()); } - public function testSupportsReleasePoints() : void + public function testSupportsReleasePoints(): void { self::assertTrue($this->platform->supportsReleaseSavepoints()); } - public function testSupportsCreateDropDatabase() : void + public function testSupportsCreateDropDatabase(): void { self::assertTrue($this->platform->supportsCreateDropDatabase()); } - public function testSupportsGettingAffectedRows() : void + public function testSupportsGettingAffectedRows(): void { self::assertTrue($this->platform->supportsGettingAffectedRows()); } - public function testDoesNotSupportSequences() : void + public function testDoesNotSupportSequences(): void { self::assertFalse($this->platform->supportsSequences()); } - public function testDoesNotSupportInlineColumnComments() : void + public function testDoesNotSupportInlineColumnComments(): void { self::assertFalse($this->platform->supportsInlineColumnComments()); } - public function testCannotEmulateSchemas() : void + public function testCannotEmulateSchemas(): void { self::assertFalse($this->platform->canEmulateSchemas()); } - public function testInitializesDoctrineTypeMappings() : void + public function testInitializesDoctrineTypeMappings(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('integer')); self::assertSame('integer', $this->platform->getDoctrineTypeMapping('integer')); @@ -807,17 +808,17 @@ public function testInitializesDoctrineTypeMappings() : void self::assertSame('binary', $this->platform->getDoctrineTypeMapping('varbinary')); } - protected function getBinaryDefaultLength() : int + protected function getBinaryDefaultLength(): int { return 1; } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 32767; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('VARBINARY(1)', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('VARBINARY(1)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -832,7 +833,7 @@ public function testReturnsBinaryTypeDeclarationSQL() : void * @group legacy * @expectedDeprecation Binary field length 32768 is greater than supported by the platform (32767). Reduce the field length or use a BLOB field instead. */ - public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void + public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL(): void { self::assertSame('LONG BINARY', $this->platform->getBinaryTypeDeclarationSQL(['length' => 32768])); self::assertSame('LONG BINARY', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 32768])); @@ -843,7 +844,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return ['ALTER INDEX idx_foo ON mytable RENAME TO idx_bar']; } @@ -853,7 +854,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'ALTER INDEX "create" ON "table" RENAME TO "select"', @@ -864,7 +865,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return [ 'ALTER TABLE mytable RENAME unquoted1 TO unquoted', @@ -882,7 +883,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { $this->markTestIncomplete('Not implemented yet'); } @@ -892,7 +893,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return ['ALTER INDEX idx_foo ON myschema.mytable RENAME TO idx_bar']; } @@ -902,7 +903,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'ALTER INDEX "create" ON "schema"."table" RENAME TO "select"', @@ -913,7 +914,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('UNIQUEIDENTIFIER', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -921,7 +922,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return ['ALTER TABLE foo RENAME bar TO baz']; } @@ -929,7 +930,7 @@ public function getAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'ALTER TABLE "foo" DROP FOREIGN KEY fk1', @@ -945,7 +946,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ 'COMMENT ON COLUMN foo.bar IS \'comment\'', @@ -957,7 +958,7 @@ protected function getCommentOnColumnSQL() : array /** * @group DBAL-1004 */ - public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() : void + public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers(): void { $table1 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'))]); $table2 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'), ['comment' => 'baz'])]); @@ -976,7 +977,7 @@ public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() : /** * {@inheritdoc} */ - public static function getReturnsForeignKeyReferentialActionSQL() : iterable + public static function getReturnsForeignKeyReferentialActionSQL(): iterable { return [ ['CASCADE', 'CASCADE'], @@ -988,22 +989,22 @@ public static function getReturnsForeignKeyReferentialActionSQL() : iterable ]; } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return ''; // not supported by this platform } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'TRUNCATE TABLE "select"'; } - protected function supportsInlineIndexDeclaration() : bool + protected function supportsInlineIndexDeclaration(): bool { return false; } @@ -1011,7 +1012,7 @@ protected function supportsInlineIndexDeclaration() : bool /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return ['ALTER TABLE mytable ALTER name CHAR(2) NOT NULL']; } @@ -1019,7 +1020,7 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return ['ALTER INDEX idx_foo ON mytable RENAME TO idx_foo_renamed']; } @@ -1027,7 +1028,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : arra /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableColumnsSQL() : void + public function testQuotesSchemaNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1038,7 +1039,7 @@ public function testQuotesSchemaNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableConstraintsSQL() : void + public function testQuotesTableNameInListTableConstraintsSQL(): void { self::assertStringContainsStringIgnoringCase("'Foo''Bar\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true); } @@ -1046,7 +1047,7 @@ public function testQuotesTableNameInListTableConstraintsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableConstraintsSQL() : void + public function testQuotesSchemaNameInListTableConstraintsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1057,7 +1058,7 @@ public function testQuotesSchemaNameInListTableConstraintsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1068,7 +1069,7 @@ public function testQuotesTableNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableForeignKeysSQL() : void + public function testQuotesSchemaNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1079,7 +1080,7 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1090,7 +1091,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableIndexesSQL() : void + public function testQuotesSchemaNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php index 65b5e85f219..81c38139686 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php @@ -14,12 +14,12 @@ class SQLAzurePlatformTest extends DbalTestCase /** @var SQLAzurePlatform */ private $platform; - protected function setUp() : void + protected function setUp(): void { $this->platform = new SQLAzurePlatform(); } - public function testCreateFederatedOnTable() : void + public function testCreateFederatedOnTable(): void { $table = new Table('tbl'); $table->addColumn('id', 'integer'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php index 60abcad7c06..17477909061 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php @@ -7,12 +7,12 @@ class SQLServer2008PlatformTest extends AbstractSQLServerPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLServer2008Platform(); } - public function testGeneratesTypeDeclarationForDateTimeTz() : void + public function testGeneratesTypeDeclarationForDateTimeTz(): void { self::assertEquals('DATETIMEOFFSET(6)', $this->platform->getDateTimeTzTypeDeclarationSQL([])); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php index e6d4975daed..0004c65fdad 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php @@ -9,22 +9,22 @@ class SQLServer2012PlatformTest extends AbstractSQLServerPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLServer2012Platform(); } - public function testSupportsSequences() : void + public function testSupportsSequences(): void { self::assertTrue($this->platform->supportsSequences()); } - public function testDoesNotPreferSequences() : void + public function testDoesNotPreferSequences(): void { self::assertFalse($this->platform->prefersSequences()); } - public function testGeneratesSequenceSqlCommands() : void + public function testGeneratesSequenceSqlCommands(): void { $sequence = new Sequence('myseq', 20, 1); self::assertEquals( @@ -45,55 +45,55 @@ public function testGeneratesSequenceSqlCommands() : void ); } - public function testModifyLimitQuery() : void + public function testModifyLimitQuery(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0); self::assertEquals('SELECT * FROM user ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithEmptyOffset() : void + public function testModifyLimitQueryWithEmptyOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10); self::assertEquals('SELECT * FROM user ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithOffset() : void + public function testModifyLimitQueryWithOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10, 5); self::assertEquals('SELECT * FROM user ORDER BY username DESC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithAscOrderBy() : void + public function testModifyLimitQueryWithAscOrderBy(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10); self::assertEquals('SELECT * FROM user ORDER BY username ASC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithLowercaseOrderBy() : void + public function testModifyLimitQueryWithLowercaseOrderBy(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user order by username', 10); self::assertEquals('SELECT * FROM user order by username OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithDescOrderBy() : void + public function testModifyLimitQueryWithDescOrderBy(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10); self::assertEquals('SELECT * FROM user ORDER BY username DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithMultipleOrderBy() : void + public function testModifyLimitQueryWithMultipleOrderBy(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC, usereamil ASC', 10); self::assertEquals('SELECT * FROM user ORDER BY username DESC, usereamil ASC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithSubSelect() : void + public function testModifyLimitQueryWithSubSelect(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result', 10); self::assertEquals('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithSubSelectAndOrder() : void + public function testModifyLimitQueryWithSubSelectAndOrder(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC', 10); self::assertEquals('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); @@ -102,7 +102,7 @@ public function testModifyLimitQueryWithSubSelectAndOrder() : void self::assertEquals('SELECT * FROM (SELECT u.id, u.name) dctrn_result ORDER BY name DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithSubSelectAndMultipleOrder() : void + public function testModifyLimitQueryWithSubSelectAndMultipleOrder(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC, uid ASC', 10, 5); self::assertEquals('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC, uid ASC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY', $sql); @@ -114,7 +114,7 @@ public function testModifyLimitQueryWithSubSelectAndMultipleOrder() : void self::assertEquals('SELECT * FROM (SELECT u.id, u.name) dctrn_result ORDER BY name DESC, id ASC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithFromColumnNames() : void + public function testModifyLimitQueryWithFromColumnNames(): void { $sql = $this->platform->modifyLimitQuery('SELECT a.fromFoo, fromBar FROM foo', 10); self::assertEquals('SELECT a.fromFoo, fromBar FROM foo ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); @@ -123,7 +123,7 @@ public function testModifyLimitQueryWithFromColumnNames() : void /** * @group DBAL-927 */ - public function testModifyLimitQueryWithExtraLongQuery() : void + public function testModifyLimitQueryWithExtraLongQuery(): void { $query = 'SELECT table1.column1, table2.column2, table3.column3, table4.column4, table5.column5, table6.column6, table7.column7, table8.column8 FROM table1, table2, table3, table4, table5, table6, table7, table8 '; $query .= 'WHERE (table1.column1 = table2.column2) AND (table1.column1 = table3.column3) AND (table1.column1 = table4.column4) AND (table1.column1 = table5.column5) AND (table1.column1 = table6.column6) AND (table1.column1 = table7.column7) AND (table1.column1 = table8.column8) AND (table2.column2 = table3.column3) AND (table2.column2 = table4.column4) AND (table2.column2 = table5.column5) AND (table2.column2 = table6.column6) '; @@ -144,7 +144,7 @@ public function testModifyLimitQueryWithExtraLongQuery() : void /** * @group DDC-2470 */ - public function testModifyLimitQueryWithOrderByClause() : void + public function testModifyLimitQueryWithOrderByClause(): void { $sql = 'SELECT m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2 FROM MEDICION m0_ WITH (NOLOCK) INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID WHERE u3_.ID = ? ORDER BY m0_.FECHAINICIO DESC'; $expected = 'SELECT m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2 FROM MEDICION m0_ WITH (NOLOCK) INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID WHERE u3_.ID = ? ORDER BY m0_.FECHAINICIO DESC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY'; @@ -156,7 +156,7 @@ public function testModifyLimitQueryWithOrderByClause() : void /** * @group DBAL-713 */ - public function testModifyLimitQueryWithSubSelectInSelectList() : void + public function testModifyLimitQueryWithSubSelectInSelectList(): void { $sql = $this->platform->modifyLimitQuery( 'SELECT ' . @@ -185,7 +185,7 @@ public function testModifyLimitQueryWithSubSelectInSelectList() : void /** * @group DBAL-713 */ - public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause() : void + public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause(): void { $sql = $this->platform->modifyLimitQuery( 'SELECT ' . @@ -217,7 +217,7 @@ public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause() /** * @group DBAL-834 */ - public function testModifyLimitQueryWithAggregateFunctionInOrderByClause() : void + public function testModifyLimitQueryWithAggregateFunctionInOrderByClause(): void { $sql = $this->platform->modifyLimitQuery( 'SELECT ' . @@ -242,7 +242,7 @@ public function testModifyLimitQueryWithAggregateFunctionInOrderByClause() : voi ); } - public function testModifyLimitQueryWithFromSubquery() : void + public function testModifyLimitQueryWithFromSubquery(): void { $sql = $this->platform->modifyLimitQuery('SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result', 10); @@ -251,7 +251,7 @@ public function testModifyLimitQueryWithFromSubquery() : void self::assertEquals($sql, $expected); } - public function testModifyLimitQueryWithFromSubqueryAndOrder() : void + public function testModifyLimitQueryWithFromSubqueryAndOrder(): void { $sql = $this->platform->modifyLimitQuery('SELECT DISTINCT id_0, value_1 FROM (SELECT k0_.id AS id_0, k0_.value AS value_1 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result ORDER BY value_1 DESC', 10); @@ -260,7 +260,7 @@ public function testModifyLimitQueryWithFromSubqueryAndOrder() : void self::assertEquals($sql, $expected); } - public function testModifyLimitQueryWithComplexOrderByExpression() : void + public function testModifyLimitQueryWithComplexOrderByExpression(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM table ORDER BY (table.x * table.y) DESC', 10); @@ -272,7 +272,7 @@ public function testModifyLimitQueryWithComplexOrderByExpression() : void /** * @throws DBALException */ - public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable() : void + public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' . 'FROM (' @@ -295,7 +295,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBas /** * @throws DBALException */ - public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable() : void + public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' . 'FROM (' @@ -318,7 +318,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoi /** * @throws DBALException */ - public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables() : void + public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables(): void { $querySql = 'SELECT DISTINCT id_0, name_1, foo_2 ' . 'FROM (' @@ -338,7 +338,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBo self::assertEquals($alteredSql, $sql); } - public function testModifyLimitSubquerySimple() : void + public function testModifyLimitSubquerySimple(): void { $querySql = 'SELECT DISTINCT id_0 FROM ' . '(SELECT k0_.id AS id_0, k0_.field AS field_1 ' @@ -349,7 +349,7 @@ public function testModifyLimitSubquerySimple() : void self::assertEquals($alteredSql, $sql); } - public function testModifyLimitQueryWithTopNSubQueryWithOrderBy() : void + public function testModifyLimitQueryWithTopNSubQueryWithOrderBy(): void { $querySql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC)'; $expectedSql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC) ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY'; @@ -362,7 +362,7 @@ public function testModifyLimitQueryWithTopNSubQueryWithOrderBy() : void self::assertEquals($expectedSql, $sql); } - public function testModifyLimitQueryWithNewlineBeforeOrderBy() : void + public function testModifyLimitQueryWithNewlineBeforeOrderBy(): void { $querySql = "SELECT * FROM test\nORDER BY col DESC"; $expectedSql = "SELECT * FROM test\nORDER BY col DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY"; diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php index 77cf7b17b41..0ff64ba7111 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php @@ -8,7 +8,7 @@ class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLServerPlatform(); } @@ -19,7 +19,7 @@ public function createPlatform() : AbstractPlatform * @group DDC-2310 * @dataProvider getLockHints */ - public function testAppendsLockHint($lockMode, string $lockHint) : void + public function testAppendsLockHint($lockMode, string $lockHint): void { $fromClause = 'FROM users'; $expectedResult = $fromClause . $lockHint; @@ -31,7 +31,7 @@ public function testAppendsLockHint($lockMode, string $lockHint) : void * @group DBAL-2408 * @dataProvider getModifyLimitQueries */ - public function testScrubInnerOrderBy(string $query, int $limit, ?int $offset, string $expectedResult) : void + public function testScrubInnerOrderBy(string $query, int $limit, ?int $offset, string $expectedResult): void { self::assertSame($expectedResult, $this->platform->modifyLimitQuery($query, $limit, $offset)); } @@ -39,7 +39,7 @@ public function testScrubInnerOrderBy(string $query, int $limit, ?int $offset, s /** * @return mixed[][] */ - public static function getLockHints() : iterable + public static function getLockHints(): iterable { return [ [null, ''], @@ -55,7 +55,7 @@ public static function getLockHints() : iterable /** * @return mixed[][] */ - public static function getModifyLimitQueries() : iterable + public static function getModifyLimitQueries(): iterable { return [ // Test re-ordered query with correctly-scrubbed ORDER BY clause diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php index 8e01e26b227..5c99cd455ff 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php @@ -19,12 +19,12 @@ class SqlitePlatformTest extends AbstractPlatformTestCase /** * @return SqlitePlatform */ - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SqlitePlatform(); } - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL)'; } @@ -32,7 +32,7 @@ public function getGenerateTableSql() : string /** * {@inheritDoc} */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return [ 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)', @@ -40,14 +40,14 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array ]; } - public function testGeneratesSqlSnippets() : void + public function testGeneratesSqlSnippets(): void { self::assertEquals('REGEXP', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct'); self::assertEquals('SUBSTR(column, 5, LENGTH(column))', $this->platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct'); self::assertEquals('SUBSTR(column, 0, 5)', $this->platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct'); } - public function testGeneratesTransactionCommands() : void + public function testGeneratesTransactionCommands(): void { self::assertEquals( 'PRAGMA read_uncommitted = 0', @@ -67,12 +67,12 @@ public function testGeneratesTransactionCommands() : void ); } - public function testPrefersIdentityColumns() : void + public function testPrefersIdentityColumns(): void { self::assertTrue($this->platform->prefersIdentityColumns()); } - public function testIgnoresUnsignedIntegerDeclarationForAutoIncrementalIntegers() : void + public function testIgnoresUnsignedIntegerDeclarationForAutoIncrementalIntegers(): void { self::assertSame( 'INTEGER PRIMARY KEY AUTOINCREMENT', @@ -84,7 +84,7 @@ public function testIgnoresUnsignedIntegerDeclarationForAutoIncrementalIntegers( * @group DBAL-752 * @group DBAL-924 */ - public function testGeneratesTypeDeclarationForTinyIntegers() : void + public function testGeneratesTypeDeclarationForTinyIntegers(): void { self::assertEquals( 'TINYINT', @@ -114,7 +114,7 @@ public function testGeneratesTypeDeclarationForTinyIntegers() : void * @group DBAL-752 * @group DBAL-924 */ - public function testGeneratesTypeDeclarationForSmallIntegers() : void + public function testGeneratesTypeDeclarationForSmallIntegers(): void { self::assertEquals( 'SMALLINT', @@ -148,7 +148,7 @@ public function testGeneratesTypeDeclarationForSmallIntegers() : void * @group DBAL-752 * @group DBAL-924 */ - public function testGeneratesTypeDeclarationForMediumIntegers() : void + public function testGeneratesTypeDeclarationForMediumIntegers(): void { self::assertEquals( 'MEDIUMINT', @@ -178,7 +178,7 @@ public function testGeneratesTypeDeclarationForMediumIntegers() : void ); } - public function testGeneratesTypeDeclarationForIntegers() : void + public function testGeneratesTypeDeclarationForIntegers(): void { self::assertEquals( 'INTEGER', @@ -212,7 +212,7 @@ public function testGeneratesTypeDeclarationForIntegers() : void * @group DBAL-752 * @group DBAL-924 */ - public function testGeneratesTypeDeclarationForBigIntegers() : void + public function testGeneratesTypeDeclarationForBigIntegers(): void { self::assertEquals( 'BIGINT', @@ -242,7 +242,7 @@ public function testGeneratesTypeDeclarationForBigIntegers() : void ); } - public function testGeneratesTypeDeclarationForStrings() : void + public function testGeneratesTypeDeclarationForStrings(): void { self::assertEquals( 'CHAR(10)', @@ -262,48 +262,48 @@ public function testGeneratesTypeDeclarationForStrings() : void ); } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } - public function testGeneratesForeignKeyCreationSql() : void + public function testGeneratesForeignKeyCreationSql(): void { $this->expectException(DBALException::class); parent::testGeneratesForeignKeyCreationSql(); } - public function testGeneratesConstraintCreationSql() : void + public function testGeneratesConstraintCreationSql(): void { $this->expectException(DBALException::class); parent::testGeneratesConstraintCreationSql(); } - protected function getGenerateForeignKeySql() : string + protected function getGenerateForeignKeySql(): string { return ''; } - public function testModifyLimitQuery() : void + public function testModifyLimitQuery(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0); self::assertEquals('SELECT * FROM user LIMIT 10', $sql); } - public function testModifyLimitQueryWithEmptyOffset() : void + public function testModifyLimitQueryWithEmptyOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10); self::assertEquals('SELECT * FROM user LIMIT 10', $sql); } - public function testModifyLimitQueryWithOffsetAndEmptyLimit() : void + public function testModifyLimitQueryWithOffsetAndEmptyLimit(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', null, 10); self::assertEquals('SELECT * FROM user LIMIT -1 OFFSET 10', $sql); @@ -312,7 +312,7 @@ public function testModifyLimitQueryWithOffsetAndEmptyLimit() : void /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return [ 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT id, bar, bloo FROM mytable', @@ -327,7 +327,7 @@ public function getGenerateAlterTableSql() : array /** * @group DDC-1845 */ - public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey() : void + public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey(): void { $table = new Table('test'); $table->addColumn('"like"', 'integer', ['notnull' => true, 'autoincrement' => true]); @@ -340,7 +340,7 @@ public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey() : void ); } - public function testAlterTableAddColumns() : void + public function testAlterTableAddColumns(): void { $diff = new TableDiff('user'); $diff->addedColumns['foo'] = new Column('foo', Type::getType('string')); @@ -357,7 +357,7 @@ public function testAlterTableAddColumns() : void /** * @dataProvider complexDiffProvider */ - public function testAlterTableAddComplexColumns(TableDiff $diff) : void + public function testAlterTableAddComplexColumns(TableDiff $diff): void { $this->expectException(DBALException::class); @@ -367,7 +367,7 @@ public function testAlterTableAddComplexColumns(TableDiff $diff) : void /** * @return mixed[][] */ - public static function complexDiffProvider() : iterable + public static function complexDiffProvider(): iterable { $date = new TableDiff('user'); $date->addedColumns['time'] = new Column('time', Type::getType('date'), ['default' => 'CURRENT_DATE']); @@ -381,7 +381,7 @@ public static function complexDiffProvider() : iterable ]; } - public function testCreateTableWithDeferredForeignKeys() : void + public function testCreateTableWithDeferredForeignKeys(): void { $table = new Table('user'); $table->addColumn('id', 'integer'); @@ -409,7 +409,7 @@ public function testCreateTableWithDeferredForeignKeys() : void self::assertEquals($sql, $this->platform->getCreateTableSQL($table)); } - public function testAlterTable() : void + public function testAlterTable(): void { $table = new Table('user'); $table->addColumn('id', 'integer'); @@ -456,7 +456,7 @@ public function testAlterTable() : void /** * {@inheritDoc} */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))']; } @@ -464,7 +464,7 @@ protected function getQuotedColumnInPrimaryKeySQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)', @@ -475,7 +475,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return [ 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', @@ -486,7 +486,7 @@ protected function getQuotedNameInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return [ 'CREATE TABLE "quoted" (' . @@ -497,17 +497,17 @@ protected function getQuotedColumnInForeignKeySQL() : array ]; } - protected function getBinaryDefaultLength() : int + protected function getBinaryDefaultLength(): int { return 0; } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 0; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -523,7 +523,7 @@ public function testReturnsBinaryTypeDeclarationSQL() : void * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return [ 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT id FROM mytable', @@ -540,7 +540,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'CREATE TEMPORARY TABLE __temp__table AS SELECT id FROM "table"', @@ -556,7 +556,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return [ 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT unquoted1, unquoted2, unquoted3, "create", "table", "select", "quoted1", "quoted2", "quoted3" FROM mytable', @@ -579,7 +579,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { return [ 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT unquoted1, unquoted2, unquoted3, "create", "table", "select" FROM mytable', @@ -599,7 +599,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array /** * @group DBAL-807 */ - public function testAlterTableRenameIndexInSchema() : void + public function testAlterTableRenameIndexInSchema(): void { $this->markTestIncomplete( 'Test currently produces broken SQL due to SQLLitePlatform::getAlterTable being broken ' . @@ -610,7 +610,7 @@ public function testAlterTableRenameIndexInSchema() : void /** * @group DBAL-807 */ - public function testQuotesAlterTableRenameIndexInSchema() : void + public function testQuotesAlterTableRenameIndexInSchema(): void { $this->markTestIncomplete( 'Test currently produces broken SQL due to SQLLitePlatform::getAlterTable being broken ' . @@ -621,7 +621,7 @@ public function testQuotesAlterTableRenameIndexInSchema() : void /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -629,7 +629,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return [ 'CREATE TEMPORARY TABLE __temp__foo AS SELECT bar FROM foo', @@ -644,7 +644,7 @@ public function getAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'DROP INDEX IDX_8C736521A81E660E', @@ -666,7 +666,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ 'COMMENT ON COLUMN foo.bar IS \'comment\'', @@ -675,37 +675,37 @@ protected function getCommentOnColumnSQL() : array ]; } - protected static function getInlineColumnCommentDelimiter() : string + protected static function getInlineColumnCommentDelimiter(): string { return "\n"; } - protected static function getInlineColumnRegularCommentSQL() : string + protected static function getInlineColumnRegularCommentSQL(): string { return "--Regular comment\n"; } - protected static function getInlineColumnCommentRequiringEscapingSQL() : string + protected static function getInlineColumnCommentRequiringEscapingSQL(): string { return "--Using inline comment delimiter \n-- works\n"; } - protected static function getInlineColumnEmptyCommentSQL() : string + protected static function getInlineColumnEmptyCommentSQL(): string { return "--\n"; } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return 'INDEX "select" (foo)'; } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'DELETE FROM "select"'; } @@ -713,7 +713,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL() : string /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return [ 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT name FROM mytable', @@ -727,7 +727,7 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return [ 'DROP INDEX idx_foo', @@ -745,7 +745,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : arra /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableConstraintsSQL() : void + public function testQuotesTableNameInListTableConstraintsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -756,7 +756,7 @@ public function testQuotesTableNameInListTableConstraintsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableColumnsSQL() : void + public function testQuotesTableNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -767,7 +767,7 @@ public function testQuotesTableNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -778,7 +778,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -786,22 +786,22 @@ public function testQuotesTableNameInListTableForeignKeysSQL() : void ); } - public function testDateAddStaticNumberOfDays() : void + public function testDateAddStaticNumberOfDays(): void { self::assertSame("DATE(rentalBeginsOn,'+12 DAY')", $this->platform->getDateAddDaysExpression('rentalBeginsOn', 12)); } - public function testDateAddNumberOfDaysFromColumn() : void + public function testDateAddNumberOfDaysFromColumn(): void { self::assertSame("DATE(rentalBeginsOn,'+' || duration || ' DAY')", $this->platform->getDateAddDaysExpression('rentalBeginsOn', 'duration')); } - public function testSupportsColumnCollation() : void + public function testSupportsColumnCollation(): void { self::assertTrue($this->platform->supportsColumnCollation()); } - public function testColumnCollationDeclarationSQL() : void + public function testColumnCollationDeclarationSQL(): void { self::assertSame( 'COLLATE NOCASE', @@ -809,7 +809,7 @@ public function testColumnCollationDeclarationSQL() : void ); } - public function testGetCreateTableSQLWithColumnCollation() : void + public function testGetCreateTableSQLWithColumnCollation(): void { $table = new Table('foo'); $table->addColumn('no_collation', 'string'); diff --git a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php index 00dbe37b0d0..067581e81ab 100644 --- a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php @@ -10,6 +10,7 @@ use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; + use function iterator_to_array; class StatementTest extends DbalTestCase @@ -23,7 +24,7 @@ class StatementTest extends DbalTestCase /** @var DriverStatement|MockObject */ protected $wrappedStmt; - protected function setUp() : void + protected function setUp(): void { $this->wrappedStmt = $this->createMock(DriverStatement::class); $this->conn = $this->createConnection(); @@ -33,7 +34,7 @@ protected function setUp() : void /** * @group DBAL-726 */ - public function testBindParam() : void + public function testBindParam(): void { $column = 'mycolumn'; $variable = 'myvalue'; @@ -48,7 +49,7 @@ public function testBindParam() : void self::assertTrue($this->stmt->bindParam($column, $variable, $type, $length)); } - public function testBindValue() : void + public function testBindValue(): void { $param = 'myparam'; $value = 'myvalue'; @@ -62,7 +63,7 @@ public function testBindValue() : void self::assertTrue($this->stmt->bindValue($param, $value, $type)); } - public function testCloseCursor() : void + public function testCloseCursor(): void { $this->wrappedStmt->expects($this->once()) ->method('closeCursor') @@ -71,7 +72,7 @@ public function testCloseCursor() : void self::assertTrue($this->stmt->closeCursor()); } - public function testColumnCount() : void + public function testColumnCount(): void { $columnCount = 666; @@ -82,7 +83,7 @@ public function testColumnCount() : void self::assertSame($columnCount, $this->stmt->columnCount()); } - public function testErrorCode() : void + public function testErrorCode(): void { $errorCode = '666'; @@ -93,7 +94,7 @@ public function testErrorCode() : void self::assertSame($errorCode, $this->stmt->errorCode()); } - public function testErrorInfo() : void + public function testErrorInfo(): void { $errorInfo = ['666', 'Evil error.']; @@ -104,7 +105,7 @@ public function testErrorInfo() : void self::assertSame($errorInfo, $this->stmt->errorInfo()); } - public function testExecute() : void + public function testExecute(): void { $params = [ 'foo', @@ -119,7 +120,7 @@ public function testExecute() : void self::assertTrue($this->stmt->execute($params)); } - public function testSetFetchMode() : void + public function testSetFetchMode(): void { $fetchMode = FetchMode::CUSTOM_OBJECT; $arg1 = 'MyClass'; @@ -138,7 +139,7 @@ public function testSetFetchMode() : void self::assertSame($fetchMode, $re->getValue($this->stmt)); } - public function testGetIterator() : void + public function testGetIterator(): void { $this->wrappedStmt->expects($this->exactly(3)) ->method('fetch') @@ -147,7 +148,7 @@ public function testGetIterator() : void self::assertSame(['foo', 'bar'], iterator_to_array($this->stmt->getIterator())); } - public function testRowCount() : void + public function testRowCount(): void { $rowCount = 666; @@ -168,7 +169,7 @@ protected function createConnection() ->getMock(); } - protected function createStatement(DriverStatement $wrappedStatement, Connection $connection) : Statement + protected function createStatement(DriverStatement $wrappedStatement, Connection $connection): Statement { return new Statement($wrappedStatement, $connection); } diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php index 0a8492f795f..f6379ce8371 100644 --- a/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php @@ -10,7 +10,7 @@ */ class CompositeExpressionTest extends DbalTestCase { - public function testCount() : void + public function testCount(): void { $expr = new CompositeExpression(CompositeExpression::TYPE_OR, ['u.group_id = 1']); @@ -21,7 +21,7 @@ public function testCount() : void self::assertCount(2, $expr); } - public function testAdd() : void + public function testAdd(): void { $expr = new CompositeExpression(CompositeExpression::TYPE_OR, ['u.group_id = 1']); @@ -49,7 +49,7 @@ public function testAdd() : void * * @dataProvider provideDataForConvertToString */ - public function testCompositeUsageAndGeneration(string $type, array $parts, string $expects) : void + public function testCompositeUsageAndGeneration(string $type, array $parts, string $expects): void { $expr = new CompositeExpression($type, $parts); @@ -59,7 +59,7 @@ public function testCompositeUsageAndGeneration(string $type, array $parts, stri /** * @return mixed[][] */ - public static function provideDataForConvertToString() : iterable + public static function provideDataForConvertToString(): iterable { return [ [ diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php index 817007d67d6..68ae37c5fa8 100644 --- a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php @@ -15,7 +15,7 @@ class ExpressionBuilderTest extends DbalTestCase /** @var ExpressionBuilder */ protected $expr; - protected function setUp() : void + protected function setUp(): void { $conn = $this->createMock(Connection::class); @@ -31,7 +31,7 @@ protected function setUp() : void * * @dataProvider provideDataForAndX */ - public function testAndX(array $parts, string $expected) : void + public function testAndX(array $parts, string $expected): void { $composite = $this->expr->andX(); @@ -45,7 +45,7 @@ public function testAndX(array $parts, string $expected) : void /** * @return mixed[][] */ - public static function provideDataForAndX() : iterable + public static function provideDataForAndX(): iterable { return [ [ @@ -92,7 +92,7 @@ public static function provideDataForAndX() : iterable * * @dataProvider provideDataForOrX */ - public function testOrX(array $parts, string $expected) : void + public function testOrX(array $parts, string $expected): void { $composite = $this->expr->orX(); @@ -106,7 +106,7 @@ public function testOrX(array $parts, string $expected) : void /** * @return mixed[][] */ - public static function provideDataForOrX() : iterable + public static function provideDataForOrX(): iterable { return [ [ @@ -151,7 +151,7 @@ public static function provideDataForOrX() : iterable /** * @dataProvider provideDataForComparison */ - public function testComparison(string $leftExpr, string $operator, string $rightExpr, string $expected) : void + public function testComparison(string $leftExpr, string $operator, string $rightExpr, string $expected): void { $part = $this->expr->comparison($leftExpr, $operator, $rightExpr); @@ -161,7 +161,7 @@ public function testComparison(string $leftExpr, string $operator, string $right /** * @return mixed[][] */ - public static function provideDataForComparison() : iterable + public static function provideDataForComparison(): iterable { return [ ['u.user_id', ExpressionBuilder::EQ, '1', 'u.user_id = 1'], @@ -173,72 +173,72 @@ public static function provideDataForComparison() : iterable ]; } - public function testEq() : void + public function testEq(): void { self::assertEquals('u.user_id = 1', $this->expr->eq('u.user_id', '1')); } - public function testNeq() : void + public function testNeq(): void { self::assertEquals('u.user_id <> 1', $this->expr->neq('u.user_id', '1')); } - public function testLt() : void + public function testLt(): void { self::assertEquals('u.salary < 10000', $this->expr->lt('u.salary', '10000')); } - public function testLte() : void + public function testLte(): void { self::assertEquals('u.salary <= 10000', $this->expr->lte('u.salary', '10000')); } - public function testGt() : void + public function testGt(): void { self::assertEquals('u.salary > 10000', $this->expr->gt('u.salary', '10000')); } - public function testGte() : void + public function testGte(): void { self::assertEquals('u.salary >= 10000', $this->expr->gte('u.salary', '10000')); } - public function testIsNull() : void + public function testIsNull(): void { self::assertEquals('u.deleted IS NULL', $this->expr->isNull('u.deleted')); } - public function testIsNotNull() : void + public function testIsNotNull(): void { self::assertEquals('u.updated IS NOT NULL', $this->expr->isNotNull('u.updated')); } - public function testIn() : void + public function testIn(): void { self::assertEquals('u.groups IN (1, 3, 4, 7)', $this->expr->in('u.groups', [1, 3, 4, 7])); } - public function testInWithPlaceholder() : void + public function testInWithPlaceholder(): void { self::assertEquals('u.groups IN (?)', $this->expr->in('u.groups', '?')); } - public function testNotIn() : void + public function testNotIn(): void { self::assertEquals('u.groups NOT IN (1, 3, 4, 7)', $this->expr->notIn('u.groups', [1, 3, 4, 7])); } - public function testNotInWithPlaceholder() : void + public function testNotInWithPlaceholder(): void { self::assertEquals('u.groups NOT IN (:values)', $this->expr->notIn('u.groups', ':values')); } - public function testLikeWithoutEscape() : void + public function testLikeWithoutEscape(): void { self::assertEquals("a.song LIKE 'a virgin'", $this->expr->like('a.song', "'a virgin'")); } - public function testLikeWithEscape() : void + public function testLikeWithEscape(): void { self::assertEquals( "a.song LIKE 'a virgin' ESCAPE '💩'", @@ -246,7 +246,7 @@ public function testLikeWithEscape() : void ); } - public function testNotLikeWithoutEscape() : void + public function testNotLikeWithoutEscape(): void { self::assertEquals( "s.last_words NOT LIKE 'this'", @@ -254,7 +254,7 @@ public function testNotLikeWithoutEscape() : void ); } - public function testNotLikeWithEscape() : void + public function testNotLikeWithEscape(): void { self::assertEquals( "p.description NOT LIKE '20💩%' ESCAPE '💩'", diff --git a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php index e19adad8940..7d401ddc911 100644 --- a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php @@ -17,7 +17,7 @@ class QueryBuilderTest extends DbalTestCase /** @var Connection */ protected $conn; - protected function setUp() : void + protected function setUp(): void { $this->conn = $this->createMock(Connection::class); @@ -31,7 +31,7 @@ protected function setUp() : void /** * @group DBAL-2291 */ - public function testSimpleSelectWithoutFrom() : void + public function testSimpleSelectWithoutFrom(): void { $qb = new QueryBuilder($this->conn); @@ -40,7 +40,7 @@ public function testSimpleSelectWithoutFrom() : void self::assertEquals('SELECT some_function()', (string) $qb); } - public function testSimpleSelect() : void + public function testSimpleSelect(): void { $qb = new QueryBuilder($this->conn); @@ -50,7 +50,7 @@ public function testSimpleSelect() : void self::assertEquals('SELECT u.id FROM users u', (string) $qb); } - public function testSimpleSelectWithDistinct() : void + public function testSimpleSelectWithDistinct(): void { $qb = new QueryBuilder($this->conn); @@ -61,7 +61,7 @@ public function testSimpleSelectWithDistinct() : void self::assertEquals('SELECT DISTINCT u.id FROM users u', (string) $qb); } - public function testSelectWithSimpleWhere() : void + public function testSelectWithSimpleWhere(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -73,7 +73,7 @@ public function testSelectWithSimpleWhere() : void self::assertEquals('SELECT u.id FROM users u WHERE u.nickname = ?', (string) $qb); } - public function testSelectWithLeftJoin() : void + public function testSelectWithLeftJoin(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -85,7 +85,7 @@ public function testSelectWithLeftJoin() : void self::assertEquals('SELECT u.*, p.* FROM users u LEFT JOIN phones p ON p.user_id = u.id', (string) $qb); } - public function testSelectWithJoin() : void + public function testSelectWithJoin(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -97,7 +97,7 @@ public function testSelectWithJoin() : void self::assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb); } - public function testSelectWithJoinNoCondition() : void + public function testSelectWithJoinNoCondition(): void { $qb = new QueryBuilder($this->conn); @@ -108,7 +108,7 @@ public function testSelectWithJoinNoCondition() : void self::assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p', (string) $qb); } - public function testSelectWithInnerJoin() : void + public function testSelectWithInnerJoin(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -120,7 +120,7 @@ public function testSelectWithInnerJoin() : void self::assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb); } - public function testSelectWithRightJoin() : void + public function testSelectWithRightJoin(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -132,7 +132,7 @@ public function testSelectWithRightJoin() : void self::assertEquals('SELECT u.*, p.* FROM users u RIGHT JOIN phones p ON p.user_id = u.id', (string) $qb); } - public function testSelectWithAndWhereConditions() : void + public function testSelectWithAndWhereConditions(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -145,7 +145,7 @@ public function testSelectWithAndWhereConditions() : void self::assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) AND (u.name = ?)', (string) $qb); } - public function testSelectWithOrWhereConditions() : void + public function testSelectWithOrWhereConditions(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -158,7 +158,7 @@ public function testSelectWithOrWhereConditions() : void self::assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb); } - public function testSelectWithOrOrWhereConditions() : void + public function testSelectWithOrOrWhereConditions(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -171,7 +171,7 @@ public function testSelectWithOrOrWhereConditions() : void self::assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb); } - public function testSelectWithAndOrWhereConditions() : void + public function testSelectWithAndOrWhereConditions(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -186,7 +186,7 @@ public function testSelectWithAndOrWhereConditions() : void self::assertEquals('SELECT u.*, p.* FROM users u WHERE (((u.username = ?) AND (u.username = ?)) OR (u.name = ?)) AND (u.name = ?)', (string) $qb); } - public function testSelectGroupBy() : void + public function testSelectGroupBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -198,7 +198,7 @@ public function testSelectGroupBy() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id', (string) $qb); } - public function testSelectEmptyGroupBy() : void + public function testSelectEmptyGroupBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -210,7 +210,7 @@ public function testSelectEmptyGroupBy() : void self::assertEquals('SELECT u.*, p.* FROM users u', (string) $qb); } - public function testSelectEmptyAddGroupBy() : void + public function testSelectEmptyAddGroupBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -222,7 +222,7 @@ public function testSelectEmptyAddGroupBy() : void self::assertEquals('SELECT u.*, p.* FROM users u', (string) $qb); } - public function testSelectAddGroupBy() : void + public function testSelectAddGroupBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -235,7 +235,7 @@ public function testSelectAddGroupBy() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo', (string) $qb); } - public function testSelectAddGroupBys() : void + public function testSelectAddGroupBys(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -248,7 +248,7 @@ public function testSelectAddGroupBys() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo, u.bar', (string) $qb); } - public function testSelectHaving() : void + public function testSelectHaving(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -261,7 +261,7 @@ public function testSelectHaving() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb); } - public function testSelectAndHaving() : void + public function testSelectAndHaving(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -274,7 +274,7 @@ public function testSelectAndHaving() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb); } - public function testSelectHavingAndHaving() : void + public function testSelectHavingAndHaving(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -288,7 +288,7 @@ public function testSelectHavingAndHaving() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) AND (u.username = ?)', (string) $qb); } - public function testSelectHavingOrHaving() : void + public function testSelectHavingOrHaving(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -302,7 +302,7 @@ public function testSelectHavingOrHaving() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb); } - public function testSelectOrHavingOrHaving() : void + public function testSelectOrHavingOrHaving(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -316,7 +316,7 @@ public function testSelectOrHavingOrHaving() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb); } - public function testSelectHavingAndOrHaving() : void + public function testSelectHavingAndOrHaving(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -331,7 +331,7 @@ public function testSelectHavingAndOrHaving() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING ((u.name = ?) OR (u.username = ?)) AND (u.username = ?)', (string) $qb); } - public function testSelectOrderBy() : void + public function testSelectOrderBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -343,7 +343,7 @@ public function testSelectOrderBy() : void self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC', (string) $qb); } - public function testSelectAddOrderBy() : void + public function testSelectAddOrderBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -356,7 +356,7 @@ public function testSelectAddOrderBy() : void self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb); } - public function testSelectAddAddOrderBy() : void + public function testSelectAddAddOrderBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -369,7 +369,7 @@ public function testSelectAddAddOrderBy() : void self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb); } - public function testEmptySelect() : void + public function testEmptySelect(): void { $qb = new QueryBuilder($this->conn); $qb2 = $qb->select(); @@ -378,7 +378,7 @@ public function testEmptySelect() : void self::assertEquals(QueryBuilder::SELECT, $qb->getType()); } - public function testSelectAddSelect() : void + public function testSelectAddSelect(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -390,7 +390,7 @@ public function testSelectAddSelect() : void self::assertEquals('SELECT u.*, p.* FROM users u', (string) $qb); } - public function testEmptyAddSelect() : void + public function testEmptyAddSelect(): void { $qb = new QueryBuilder($this->conn); $qb2 = $qb->addSelect(); @@ -399,7 +399,7 @@ public function testEmptyAddSelect() : void self::assertEquals(QueryBuilder::SELECT, $qb->getType()); } - public function testSelectMultipleFrom() : void + public function testSelectMultipleFrom(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -412,7 +412,7 @@ public function testSelectMultipleFrom() : void self::assertEquals('SELECT u.*, p.* FROM users u, phonenumbers p', (string) $qb); } - public function testUpdate() : void + public function testUpdate(): void { $qb = new QueryBuilder($this->conn); $qb->update('users', 'u') @@ -423,7 +423,7 @@ public function testUpdate() : void self::assertEquals('UPDATE users u SET u.foo = ?, u.bar = ?', (string) $qb); } - public function testUpdateWithoutAlias() : void + public function testUpdateWithoutAlias(): void { $qb = new QueryBuilder($this->conn); $qb->update('users') @@ -433,7 +433,7 @@ public function testUpdateWithoutAlias() : void self::assertEquals('UPDATE users SET foo = ?, bar = ?', (string) $qb); } - public function testUpdateWhere() : void + public function testUpdateWhere(): void { $qb = new QueryBuilder($this->conn); $qb->update('users', 'u') @@ -443,7 +443,7 @@ public function testUpdateWhere() : void self::assertEquals('UPDATE users u SET u.foo = ? WHERE u.foo = ?', (string) $qb); } - public function testEmptyUpdate() : void + public function testEmptyUpdate(): void { $qb = new QueryBuilder($this->conn); $qb2 = $qb->update(); @@ -452,7 +452,7 @@ public function testEmptyUpdate() : void self::assertSame($qb2, $qb); } - public function testDelete() : void + public function testDelete(): void { $qb = new QueryBuilder($this->conn); $qb->delete('users', 'u'); @@ -461,7 +461,7 @@ public function testDelete() : void self::assertEquals('DELETE FROM users u', (string) $qb); } - public function testDeleteWithoutAlias() : void + public function testDeleteWithoutAlias(): void { $qb = new QueryBuilder($this->conn); $qb->delete('users'); @@ -470,7 +470,7 @@ public function testDeleteWithoutAlias() : void self::assertEquals('DELETE FROM users', (string) $qb); } - public function testDeleteWhere() : void + public function testDeleteWhere(): void { $qb = new QueryBuilder($this->conn); $qb->delete('users', 'u') @@ -479,7 +479,7 @@ public function testDeleteWhere() : void self::assertEquals('DELETE FROM users u WHERE u.foo = ?', (string) $qb); } - public function testEmptyDelete() : void + public function testEmptyDelete(): void { $qb = new QueryBuilder($this->conn); $qb2 = $qb->delete(); @@ -488,7 +488,7 @@ public function testEmptyDelete() : void self::assertSame($qb2, $qb); } - public function testInsertValues() : void + public function testInsertValues(): void { $qb = new QueryBuilder($this->conn); $qb->insert('users') @@ -503,7 +503,7 @@ public function testInsertValues() : void self::assertEquals('INSERT INTO users (foo, bar) VALUES(?, ?)', (string) $qb); } - public function testInsertReplaceValues() : void + public function testInsertReplaceValues(): void { $qb = new QueryBuilder($this->conn); $qb->insert('users') @@ -524,7 +524,7 @@ public function testInsertReplaceValues() : void self::assertEquals('INSERT INTO users (bar, foo) VALUES(?, ?)', (string) $qb); } - public function testInsertSetValue() : void + public function testInsertSetValue(): void { $qb = new QueryBuilder($this->conn); $qb->insert('users') @@ -536,7 +536,7 @@ public function testInsertSetValue() : void self::assertEquals('INSERT INTO users (foo, bar) VALUES(?, ?)', (string) $qb); } - public function testInsertValuesSetValue() : void + public function testInsertValuesSetValue(): void { $qb = new QueryBuilder($this->conn); $qb->insert('users') @@ -549,7 +549,7 @@ public function testInsertValuesSetValue() : void self::assertEquals('INSERT INTO users (foo, bar) VALUES(?, ?)', (string) $qb); } - public function testEmptyInsert() : void + public function testEmptyInsert(): void { $qb = new QueryBuilder($this->conn); $qb2 = $qb->insert(); @@ -558,13 +558,13 @@ public function testEmptyInsert() : void self::assertSame($qb2, $qb); } - public function testGetConnection() : void + public function testGetConnection(): void { $qb = new QueryBuilder($this->conn); self::assertSame($this->conn, $qb->getConnection()); } - public function testGetState() : void + public function testGetState(): void { $qb = new QueryBuilder($this->conn); @@ -583,7 +583,7 @@ public function testGetState() : void /** * @dataProvider maxResultsProvider */ - public function testSetMaxResults(?int $maxResults) : void + public function testSetMaxResults(?int $maxResults): void { $qb = new QueryBuilder($this->conn); $qb->setMaxResults($maxResults); @@ -595,7 +595,7 @@ public function testSetMaxResults(?int $maxResults) : void /** * @return mixed[][] */ - public static function maxResultsProvider() : iterable + public static function maxResultsProvider(): iterable { return [ 'non-null' => [10], @@ -603,7 +603,7 @@ public static function maxResultsProvider() : iterable ]; } - public function testSetFirstResult() : void + public function testSetFirstResult(): void { $qb = new QueryBuilder($this->conn); $qb->setFirstResult(10); @@ -612,7 +612,7 @@ public function testSetFirstResult() : void self::assertEquals(10, $qb->getFirstResult()); } - public function testResetQueryPart() : void + public function testResetQueryPart(): void { $qb = new QueryBuilder($this->conn); @@ -623,7 +623,7 @@ public function testResetQueryPart() : void self::assertEquals('SELECT u.* FROM users u', (string) $qb); } - public function testResetQueryParts() : void + public function testResetQueryParts(): void { $qb = new QueryBuilder($this->conn); @@ -634,7 +634,7 @@ public function testResetQueryParts() : void self::assertEquals('SELECT u.* FROM users u', (string) $qb); } - public function testCreateNamedParameter() : void + public function testCreateNamedParameter(): void { $qb = new QueryBuilder($this->conn); @@ -647,7 +647,7 @@ public function testCreateNamedParameter() : void self::assertEquals(ParameterType::INTEGER, $qb->getParameterType('dcValue1')); } - public function testCreateNamedParameterCustomPlaceholder() : void + public function testCreateNamedParameterCustomPlaceholder(): void { $qb = new QueryBuilder($this->conn); @@ -660,7 +660,7 @@ public function testCreateNamedParameterCustomPlaceholder() : void self::assertEquals(ParameterType::INTEGER, $qb->getParameterType('test')); } - public function testCreatePositionalParameter() : void + public function testCreatePositionalParameter(): void { $qb = new QueryBuilder($this->conn); @@ -676,7 +676,7 @@ public function testCreatePositionalParameter() : void /** * @group DBAL-172 */ - public function testReferenceJoinFromJoin() : void + public function testReferenceJoinFromJoin(): void { $qb = new QueryBuilder($this->conn); @@ -695,7 +695,7 @@ public function testReferenceJoinFromJoin() : void /** * @group DBAL-172 */ - public function testSelectFromMasterWithWhereOnJoinedTables() : void + public function testSelectFromMasterWithWhereOnJoinedTables(): void { $qb = new QueryBuilder($this->conn); @@ -713,7 +713,7 @@ public function testSelectFromMasterWithWhereOnJoinedTables() : void /** * @group DBAL-442 */ - public function testSelectWithMultipleFromAndJoins() : void + public function testSelectWithMultipleFromAndJoins(): void { $qb = new QueryBuilder($this->conn); @@ -731,7 +731,7 @@ public function testSelectWithMultipleFromAndJoins() : void /** * @group DBAL-774 */ - public function testSelectWithJoinsWithMultipleOnConditionsParseOrder() : void + public function testSelectWithJoinsWithMultipleOnConditionsParseOrder(): void { $qb = new QueryBuilder($this->conn); @@ -756,7 +756,7 @@ public function testSelectWithJoinsWithMultipleOnConditionsParseOrder() : void /** * @group DBAL-774 */ - public function testSelectWithMultipleFromsAndJoinsWithMultipleOnConditionsParseOrder() : void + public function testSelectWithMultipleFromsAndJoinsWithMultipleOnConditionsParseOrder(): void { $qb = new QueryBuilder($this->conn); @@ -782,7 +782,7 @@ public function testSelectWithMultipleFromsAndJoinsWithMultipleOnConditionsParse ); } - public function testClone() : void + public function testClone(): void { $qb = new QueryBuilder($this->conn); @@ -802,7 +802,7 @@ public function testClone() : void self::assertNotSame($qb->getParameters(), $qbClone->getParameters()); } - public function testSimpleSelectWithoutTableAlias() : void + public function testSimpleSelectWithoutTableAlias(): void { $qb = new QueryBuilder($this->conn); @@ -812,7 +812,7 @@ public function testSimpleSelectWithoutTableAlias() : void self::assertEquals('SELECT id FROM users', (string) $qb); } - public function testSelectWithSimpleWhereWithoutTableAlias() : void + public function testSelectWithSimpleWhereWithoutTableAlias(): void { $qb = new QueryBuilder($this->conn); @@ -823,7 +823,7 @@ public function testSelectWithSimpleWhereWithoutTableAlias() : void self::assertEquals('SELECT id, name FROM users WHERE awesome=9001', (string) $qb); } - public function testComplexSelectWithoutTableAliases() : void + public function testComplexSelectWithoutTableAliases(): void { $qb = new QueryBuilder($this->conn); @@ -838,7 +838,7 @@ public function testComplexSelectWithoutTableAliases() : void self::assertEquals('SELECT DISTINCT users.id FROM users INNER JOIN permissions p ON p.user_id = users.id, articles INNER JOIN comments c ON c.article_id = articles.id WHERE (users.id = articles.user_id) AND (p.read = 1)', $qb->getSQL()); } - public function testComplexSelectWithSomeTableAliases() : void + public function testComplexSelectWithSomeTableAliases(): void { $qb = new QueryBuilder($this->conn); @@ -851,7 +851,7 @@ public function testComplexSelectWithSomeTableAliases() : void self::assertEquals('SELECT u.id FROM users u INNER JOIN permissions p ON p.user_id = u.id, articles INNER JOIN comments c ON c.article_id = articles.id', $qb->getSQL()); } - public function testSelectAllFromTableWithoutTableAlias() : void + public function testSelectAllFromTableWithoutTableAlias(): void { $qb = new QueryBuilder($this->conn); @@ -861,7 +861,7 @@ public function testSelectAllFromTableWithoutTableAlias() : void self::assertEquals('SELECT users.* FROM users', (string) $qb); } - public function testSelectAllWithoutTableAlias() : void + public function testSelectAllWithoutTableAlias(): void { $qb = new QueryBuilder($this->conn); @@ -874,7 +874,7 @@ public function testSelectAllWithoutTableAlias() : void /** * @group DBAL-959 */ - public function testGetParameterType() : void + public function testGetParameterType(): void { $qb = new QueryBuilder($this->conn); @@ -895,7 +895,7 @@ public function testGetParameterType() : void /** * @group DBAL-959 */ - public function testGetParameterTypes() : void + public function testGetParameterTypes(): void { $qb = new QueryBuilder($this->conn); @@ -922,7 +922,7 @@ public function testGetParameterTypes() : void /** * @group DBAL-1137 */ - public function testJoinWithNonUniqueAliasThrowsException() : void + public function testJoinWithNonUniqueAliasThrowsException(): void { $qb = new QueryBuilder($this->conn); diff --git a/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php b/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php index 621520029b1..bfa7a5fcc30 100644 --- a/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php +++ b/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php @@ -17,7 +17,7 @@ class SQLParserUtilsTest extends DbalTestCase /** * @return mixed[][] */ - public static function dataGetPlaceholderPositions() : iterable + public static function dataGetPlaceholderPositions(): iterable { return [ // none @@ -98,7 +98,7 @@ public static function dataGetPlaceholderPositions() : iterable * * @dataProvider dataGetPlaceholderPositions */ - public function testGetPlaceholderPositions(string $query, bool $isPositional, array $expectedParamPos) : void + public function testGetPlaceholderPositions(string $query, bool $isPositional, array $expectedParamPos): void { $actualParamPos = SQLParserUtils::getPlaceholderPositions($query, $isPositional); self::assertEquals($expectedParamPos, $actualParamPos); @@ -107,7 +107,7 @@ public function testGetPlaceholderPositions(string $query, bool $isPositional, a /** * @return mixed[][] */ - public static function dataExpandListParameters() : iterable + public static function dataExpandListParameters(): iterable { return [ 'Positional: Very simple with one needle' => [ @@ -439,7 +439,7 @@ public function testExpandListParameters( string $expectedQuery, array $expectedParams, array $expectedTypes - ) : void { + ): void { [$query, $params, $types] = SQLParserUtils::expandListParameters($query, $params, $types); self::assertEquals($expectedQuery, $query, 'Query was not rewritten correctly.'); @@ -450,7 +450,7 @@ public function testExpandListParameters( /** * @return mixed[][] */ - public static function dataQueryWithMissingParameters() : iterable + public static function dataQueryWithMissingParameters(): iterable { return [ [ @@ -492,7 +492,7 @@ public static function dataQueryWithMissingParameters() : iterable * * @dataProvider dataQueryWithMissingParameters */ - public function testExceptionIsThrownForMissingParam(string $query, array $params, array $types = []) : void + public function testExceptionIsThrownForMissingParam(string $query, array $params, array $types = []): void { $this->expectException(SQLParserUtilsException::class); $this->expectExceptionMessage('Value for :param not found in params array. Params array key should be "param"'); diff --git a/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php index 0bdaa85ef6d..b37d24b2825 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php @@ -13,7 +13,7 @@ class ColumnDiffTest extends TestCase /** * @group DBAL-1255 */ - public function testPreservesOldColumnNameQuotation() : void + public function testPreservesOldColumnNameQuotation(): void { $fromColumn = new Column('"foo"', Type::getType(Types::INTEGER)); $toColumn = new Column('bar', Type::getType(Types::INTEGER)); diff --git a/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php b/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php index 269df62de32..e2b10b51069 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php @@ -12,7 +12,7 @@ class ColumnTest extends TestCase { - public function testGet() : void + public function testGet(): void { $column = $this->createColumn(); @@ -38,7 +38,7 @@ public function testGet() : void self::assertFalse($column->hasCustomSchemaOption('foo')); } - public function testToArray() : void + public function testToArray(): void { $expected = [ 'name' => 'foo', @@ -64,7 +64,7 @@ public function testToArray() : void * @group legacy * @expectedDeprecation The "unknown_option" column option is not supported, setting it is deprecated and will cause an error in Doctrine DBAL 3.0 */ - public function testSettingUnknownOptionIsStillSupported() : void + public function testSettingUnknownOptionIsStillSupported(): void { $this->expectNotToPerformAssertions(); @@ -75,7 +75,7 @@ public function testSettingUnknownOptionIsStillSupported() : void * @group legacy * @expectedDeprecation The "unknown_option" column option is not supported, setting it is deprecated and will cause an error in Doctrine DBAL 3.0 */ - public function testOptionsShouldNotBeIgnored() : void + public function testOptionsShouldNotBeIgnored(): void { $col1 = new Column('bar', Type::getType(Types::INTEGER), ['unknown_option' => 'bar', 'notnull' => true]); self::assertTrue($col1->getNotnull()); @@ -84,7 +84,7 @@ public function testOptionsShouldNotBeIgnored() : void self::assertFalse($col2->getNotnull()); } - public function createColumn() : Column + public function createColumn(): Column { $options = [ 'length' => 200, @@ -107,7 +107,7 @@ public function createColumn() : Column * @group DBAL-64 * @group DBAL-830 */ - public function testQuotedColumnName() : void + public function testQuotedColumnName(): void { $string = Type::getType('string'); $column = new Column('`bar`', $string, []); @@ -131,7 +131,7 @@ public function testQuotedColumnName() : void * @dataProvider getIsQuoted * @group DBAL-830 */ - public function testIsQuoted(string $columnName, bool $isQuoted) : void + public function testIsQuoted(string $columnName, bool $isQuoted): void { $type = Type::getType('string'); $column = new Column($columnName, $type); @@ -142,7 +142,7 @@ public function testIsQuoted(string $columnName, bool $isQuoted) : void /** * @return mixed[][] */ - public static function getIsQuoted() : iterable + public static function getIsQuoted(): iterable { return [ ['bar', false], @@ -155,7 +155,7 @@ public static function getIsQuoted() : iterable /** * @group DBAL-42 */ - public function testColumnComment() : void + public function testColumnComment(): void { $column = new Column('bar', Type::getType('string')); self::assertNull($column->getComment()); diff --git a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php index cc77a153a4a..017cc5adcb5 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php @@ -15,12 +15,13 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\TestCase; + use function array_keys; use function get_class; class ComparatorTest extends TestCase { - public function testCompareSame1() : void + public function testCompareSame1(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -44,7 +45,7 @@ public function testCompareSame1() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareSame2() : void + public function testCompareSame2(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -70,7 +71,7 @@ public function testCompareSame2() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareMissingTable() : void + public function testCompareMissingTable(): void { $schemaConfig = new SchemaConfig(); $table = new Table('bugdb', ['integerfield1' => new Column('integerfield1', Type::getType('integer'))]); @@ -84,7 +85,7 @@ public function testCompareMissingTable() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareNewTable() : void + public function testCompareNewTable(): void { $schemaConfig = new SchemaConfig(); $table = new Table('bugdb', ['integerfield1' => new Column('integerfield1', Type::getType('integer'))]); @@ -98,7 +99,7 @@ public function testCompareNewTable() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareOnlyAutoincrementChanged() : void + public function testCompareOnlyAutoincrementChanged(): void { $column1 = new Column('foo', Type::getType('integer'), ['autoincrement' => true]); $column2 = new Column('foo', Type::getType('integer'), ['autoincrement' => false]); @@ -109,7 +110,7 @@ public function testCompareOnlyAutoincrementChanged() : void self::assertEquals(['autoincrement'], $changedProperties); } - public function testCompareMissingField() : void + public function testCompareMissingField(): void { $missingColumn = new Column('integerfield1', Type::getType('integer')); $schema1 = new Schema([ @@ -147,7 +148,7 @@ public function testCompareMissingField() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareNewField() : void + public function testCompareNewField(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -184,7 +185,7 @@ public function testCompareNewField() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareChangedColumnsChangeType() : void + public function testCompareChangedColumnsChangeType(): void { $column1 = new Column('charfield1', Type::getType('string')); $column2 = new Column('charfield1', Type::getType('integer')); @@ -194,7 +195,7 @@ public function testCompareChangedColumnsChangeType() : void self::assertEquals([], $c->diffColumn($column1, $column1)); } - public function testCompareColumnsMultipleTypeInstances() : void + public function testCompareColumnsMultipleTypeInstances(): void { $integerType1 = Type::getType('integer'); Type::overrideType('integer', get_class($integerType1)); @@ -207,7 +208,7 @@ public function testCompareColumnsMultipleTypeInstances() : void self::assertEquals([], $c->diffColumn($column1, $column2)); } - public function testCompareColumnsOverriddenType() : void + public function testCompareColumnsOverriddenType(): void { $oldStringInstance = Type::getType('string'); $integerType = Type::getType('integer'); @@ -224,7 +225,7 @@ public function testCompareColumnsOverriddenType() : void self::assertEquals([], $c->diffColumn($column1, $column2)); } - public function testCompareChangedColumnsChangeCustomSchemaOption() : void + public function testCompareChangedColumnsChangeCustomSchemaOption(): void { $column1 = new Column('charfield1', Type::getType('string')); $column2 = new Column('charfield1', Type::getType('string')); @@ -240,7 +241,7 @@ public function testCompareChangedColumnsChangeCustomSchemaOption() : void self::assertEquals([], $c->diffColumn($column1, $column1)); } - public function testCompareChangeColumnsMultipleNewColumnsRename() : void + public function testCompareChangeColumnsMultipleNewColumnsRename(): void { $tableA = new Table('foo'); $tableA->addColumn('datefield1', 'datetime'); @@ -260,7 +261,7 @@ public function testCompareChangeColumnsMultipleNewColumnsRename() : void self::assertCount(0, $tableDiff->changedColumns, 'Nothing should be changed as all fields old & new have diff names.'); } - public function testCompareRemovedIndex() : void + public function testCompareRemovedIndex(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -314,7 +315,7 @@ public function testCompareRemovedIndex() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareNewIndex() : void + public function testCompareNewIndex(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -366,7 +367,7 @@ public function testCompareNewIndex() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareChangedIndex() : void + public function testCompareChangedIndex(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -429,7 +430,7 @@ public function testCompareChangedIndex() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareChangedIndexFieldPositions() : void + public function testCompareChangedIndexFieldPositions(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -477,7 +478,7 @@ public function testCompareChangedIndexFieldPositions() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareSequences() : void + public function testCompareSequences(): void { $seq1 = new Sequence('foo', 1, 1); $seq2 = new Sequence('foo', 1, 2); @@ -491,7 +492,7 @@ public function testCompareSequences() : void self::assertFalse($c->diffSequence($seq1, $seq4)); } - public function testRemovedSequence() : void + public function testRemovedSequence(): void { $schema1 = new Schema(); $seq = $schema1->createSequence('foo'); @@ -505,7 +506,7 @@ public function testRemovedSequence() : void self::assertSame($seq, $diffSchema->removedSequences[0]); } - public function testAddedSequence() : void + public function testAddedSequence(): void { $schema1 = new Schema(); @@ -519,7 +520,7 @@ public function testAddedSequence() : void self::assertSame($seq, $diffSchema->newSequences[0]); } - public function testTableAddForeignKey() : void + public function testTableAddForeignKey(): void { $tableForeign = new Table('bar'); $tableForeign->addColumn('id', 'integer'); @@ -538,7 +539,7 @@ public function testTableAddForeignKey() : void self::assertCount(1, $tableDiff->addedForeignKeys); } - public function testTableRemoveForeignKey() : void + public function testTableRemoveForeignKey(): void { $tableForeign = new Table('bar'); $tableForeign->addColumn('id', 'integer'); @@ -557,7 +558,7 @@ public function testTableRemoveForeignKey() : void self::assertCount(1, $tableDiff->removedForeignKeys); } - public function testTableUpdateForeignKey() : void + public function testTableUpdateForeignKey(): void { $tableForeign = new Table('bar'); $tableForeign->addColumn('id', 'integer'); @@ -577,7 +578,7 @@ public function testTableUpdateForeignKey() : void self::assertCount(1, $tableDiff->changedForeignKeys); } - public function testMovedForeignKeyForeignTable() : void + public function testMovedForeignKeyForeignTable(): void { $tableForeign = new Table('bar'); $tableForeign->addColumn('id', 'integer'); @@ -600,7 +601,7 @@ public function testMovedForeignKeyForeignTable() : void self::assertCount(1, $tableDiff->changedForeignKeys); } - public function testTablesCaseInsensitive() : void + public function testTablesCaseInsensitive(): void { $schemaA = new Schema(); $schemaA->createTable('foo'); @@ -620,7 +621,7 @@ public function testTablesCaseInsensitive() : void $this->assertSchemaTableChangeCount($diff, 1, 0, 1); } - public function testSequencesCaseInsensitive() : void + public function testSequencesCaseInsensitive(): void { $schemaA = new Schema(); $schemaA->createSequence('foo'); @@ -640,7 +641,7 @@ public function testSequencesCaseInsensitive() : void $this->assertSchemaSequenceChangeCount($diff, 1, 0, 1); } - public function testCompareColumnCompareCaseInsensitive() : void + public function testCompareColumnCompareCaseInsensitive(): void { $tableA = new Table('foo'); $tableA->addColumn('id', 'integer'); @@ -654,7 +655,7 @@ public function testCompareColumnCompareCaseInsensitive() : void self::assertFalse($tableDiff); } - public function testCompareIndexBasedOnPropertiesNotName() : void + public function testCompareIndexBasedOnPropertiesNotName(): void { $tableA = new Table('foo'); $tableA->addColumn('id', 'integer'); @@ -675,7 +676,7 @@ public function testCompareIndexBasedOnPropertiesNotName() : void ); } - public function testCompareForeignKeyBasedOnPropertiesNotName() : void + public function testCompareForeignKeyBasedOnPropertiesNotName(): void { $tableA = new Table('foo'); $tableA->addColumn('id', 'integer'); @@ -691,7 +692,7 @@ public function testCompareForeignKeyBasedOnPropertiesNotName() : void self::assertFalse($tableDiff); } - public function testCompareForeignKeyRestrictNoActionAreTheSame() : void + public function testCompareForeignKeyRestrictNoActionAreTheSame(): void { $fk1 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'NO ACTION']); $fk2 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'RESTRICT']); @@ -703,7 +704,7 @@ public function testCompareForeignKeyRestrictNoActionAreTheSame() : void /** * @group DBAL-492 */ - public function testCompareForeignKeyNamesUnqualifiedAsNoSchemaInformationIsAvailable() : void + public function testCompareForeignKeyNamesUnqualifiedAsNoSchemaInformationIsAvailable(): void { $fk1 = new ForeignKeyConstraint(['foo'], 'foo.bar', ['baz'], 'fk1'); $fk2 = new ForeignKeyConstraint(['foo'], 'baz.bar', ['baz'], 'fk1'); @@ -712,7 +713,7 @@ public function testCompareForeignKeyNamesUnqualifiedAsNoSchemaInformationIsAvai self::assertFalse($c->diffForeignKey($fk1, $fk2)); } - public function testDetectRenameColumn() : void + public function testDetectRenameColumn(): void { $tableA = new Table('foo'); $tableA->addColumn('foo', 'integer'); @@ -736,7 +737,7 @@ public function testDetectRenameColumn() : void * * @group DBAL-24 */ - public function testDetectRenameColumnAmbiguous() : void + public function testDetectRenameColumnAmbiguous(): void { $tableA = new Table('foo'); $tableA->addColumn('foo', 'integer'); @@ -759,7 +760,7 @@ public function testDetectRenameColumnAmbiguous() : void /** * @group DBAL-1063 */ - public function testDetectRenameIndex() : void + public function testDetectRenameIndex(): void { $table1 = new Table('foo'); $table1->addColumn('foo', 'integer'); @@ -786,7 +787,7 @@ public function testDetectRenameIndex() : void * * @group DBAL-1063 */ - public function testDetectRenameIndexAmbiguous() : void + public function testDetectRenameIndexAmbiguous(): void { $table1 = new Table('foo'); $table1->addColumn('foo', 'integer'); @@ -809,7 +810,7 @@ public function testDetectRenameIndexAmbiguous() : void self::assertCount(0, $tableDiff->renamedIndexes); } - public function testDetectChangeIdentifierType() : void + public function testDetectChangeIdentifierType(): void { $this->markTestSkipped('DBAL-2 was reopened, this test cannot work anymore.'); @@ -829,7 +830,7 @@ public function testDetectChangeIdentifierType() : void /** * @group DBAL-105 */ - public function testDiff() : void + public function testDiff(): void { $table = new Table('twitter_users'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -856,7 +857,7 @@ public function testDiff() : void /** * @group DBAL-112 */ - public function testChangedSequence() : void + public function testChangedSequence(): void { $schema = new Schema(); $sequence = $schema->createSequence('baz'); @@ -874,7 +875,7 @@ public function testChangedSequence() : void * @group DBAL-106 * @psalm-suppress NullArgument */ - public function testDiffDecimalWithNullPrecision() : void + public function testDiffDecimalWithNullPrecision(): void { $column = new Column('foo', Type::getType('decimal')); $column->setPrecision(null); @@ -888,7 +889,7 @@ public function testDiffDecimalWithNullPrecision() : void /** * @group DBAL-204 */ - public function testFqnSchemaComparison() : void + public function testFqnSchemaComparison(): void { $config = new SchemaConfig(); $config->setName('foo'); @@ -908,7 +909,7 @@ public function testFqnSchemaComparison() : void /** * @group DBAL-669 */ - public function testNamespacesComparison() : void + public function testNamespacesComparison(): void { $config = new SchemaConfig(); $config->setName('schemaName'); @@ -935,7 +936,7 @@ public function testNamespacesComparison() : void /** * @group DBAL-204 */ - public function testFqnSchemaComparisonDifferentSchemaNameButSameTableNoDiff() : void + public function testFqnSchemaComparisonDifferentSchemaNameButSameTableNoDiff(): void { $config = new SchemaConfig(); $config->setName('foo'); @@ -955,7 +956,7 @@ public function testFqnSchemaComparisonDifferentSchemaNameButSameTableNoDiff() : /** * @group DBAL-204 */ - public function testFqnSchemaComparisonNoSchemaSame() : void + public function testFqnSchemaComparisonNoSchemaSame(): void { $config = new SchemaConfig(); $config->setName('foo'); @@ -974,7 +975,7 @@ public function testFqnSchemaComparisonNoSchemaSame() : void /** * @group DDC-1657 */ - public function testAutoIncrementSequences() : void + public function testAutoIncrementSequences(): void { $oldSchema = new Schema(); $table = $oldSchema->createTable('foo'); @@ -998,7 +999,7 @@ public function testAutoIncrementSequences() : void * * @group DBAL-562 */ - public function testAutoIncrementNoSequences() : void + public function testAutoIncrementNoSequences(): void { $oldSchema = new Schema(); $table = $oldSchema->createTable('foo'); @@ -1023,7 +1024,7 @@ public function testAutoIncrementNoSequences() : void * array because of the dropped table, and once on changedTables array. We * now check that the key is present once. */ - public function testAvoidMultipleDropForeignKey() : void + public function testAvoidMultipleDropForeignKey(): void { $oldSchema = new Schema(); @@ -1056,7 +1057,7 @@ public function testAvoidMultipleDropForeignKey() : void self::assertCount(1, $schemaDiff->orphanedForeignKeys); } - public function testCompareChangedColumn() : void + public function testCompareChangedColumn(): void { $oldSchema = new Schema(); @@ -1078,7 +1079,7 @@ public function testCompareChangedColumn() : void self::assertEquals($expected, Comparator::compareSchemas($oldSchema, $newSchema)); } - public function testCompareChangedBinaryColumn() : void + public function testCompareChangedBinaryColumn(): void { $oldSchema = new Schema(); @@ -1103,7 +1104,7 @@ public function testCompareChangedBinaryColumn() : void /** * @group DBAL-617 */ - public function testCompareQuotedAndUnquotedForeignKeyColumns() : void + public function testCompareQuotedAndUnquotedForeignKeyColumns(): void { $fk1 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'NO ACTION']); $fk2 = new ForeignKeyConstraint(['`foo`'], 'bar', ['`baz`'], 'fk1', ['onDelete' => 'NO ACTION']); @@ -1114,7 +1115,7 @@ public function testCompareQuotedAndUnquotedForeignKeyColumns() : void self::assertFalse($diff); } - public function assertSchemaTableChangeCount(SchemaDiff $diff, int $newTableCount = 0, int $changeTableCount = 0, int $removeTableCount = 0) : void + public function assertSchemaTableChangeCount(SchemaDiff $diff, int $newTableCount = 0, int $changeTableCount = 0, int $removeTableCount = 0): void { self::assertCount($newTableCount, $diff->newTables); self::assertCount($changeTableCount, $diff->changedTables); @@ -1126,13 +1127,13 @@ public function assertSchemaSequenceChangeCount( int $newSequenceCount = 0, int $changeSequenceCount = 0, int $removeSequenceCount = 0 - ) : void { + ): void { self::assertCount($newSequenceCount, $diff->newSequences, 'Expected number of new sequences is wrong.'); self::assertCount($changeSequenceCount, $diff->changedSequences, 'Expected number of changed sequences is wrong.'); self::assertCount($removeSequenceCount, $diff->removedSequences, 'Expected number of removed sequences is wrong.'); } - public function testDiffColumnPlatformOptions() : void + public function testDiffColumnPlatformOptions(): void { $column1 = new Column('foo', Type::getType('string'), ['platformOptions' => ['foo' => 'foo', 'bar' => 'bar']]); $column2 = new Column('foo', Type::getType('string'), ['platformOptions' => ['foo' => 'foo', 'foobar' => 'foobar']]); @@ -1149,7 +1150,7 @@ public function testDiffColumnPlatformOptions() : void self::assertEquals([], $comparator->diffColumn($column4, $column1)); } - public function testComplexDiffColumn() : void + public function testComplexDiffColumn(): void { $column1 = new Column('foo', Type::getType('string'), [ 'platformOptions' => ['foo' => 'foo'], @@ -1169,7 +1170,7 @@ public function testComplexDiffColumn() : void /** * @group DBAL-669 */ - public function testComparesNamespaces() : void + public function testComparesNamespaces(): void { $comparator = new Comparator(); $fromSchema = $this->getMockBuilder(Schema::class) @@ -1215,7 +1216,7 @@ public function testComparesNamespaces() : void self::assertEquals($expected, $comparator->compare($fromSchema, $toSchema)); } - public function testCompareGuidColumns() : void + public function testCompareGuidColumns(): void { $comparator = new Comparator(); @@ -1234,7 +1235,7 @@ public function testCompareGuidColumns() : void * @group DBAL-1009 * @dataProvider getCompareColumnComments */ - public function testCompareColumnComments(?string $comment1, ?string $comment2, bool $equals) : void + public function testCompareColumnComments(?string $comment1, ?string $comment2, bool $equals): void { $column1 = new Column('foo', Type::getType('integer'), ['comment' => $comment1]); $column2 = new Column('foo', Type::getType('integer'), ['comment' => $comment2]); @@ -1255,7 +1256,7 @@ public function testCompareColumnComments(?string $comment1, ?string $comment2, /** * @return mixed[][] */ - public static function getCompareColumnComments() : iterable + public static function getCompareColumnComments(): iterable { return [ [null, null, true], @@ -1280,7 +1281,7 @@ public static function getCompareColumnComments() : iterable ]; } - public function testForeignKeyRemovalWithRenamedLocalColumn() : void + public function testForeignKeyRemovalWithRenamedLocalColumn(): void { $fromSchema = new Schema([ 'table1' => new Table( diff --git a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php index 53f9a41cbda..39d12c346c0 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\DB2SchemaManager; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function in_array; /** @@ -23,7 +24,7 @@ final class DB2SchemaManagerTest extends TestCase /** @var DB2SchemaManager */ private $manager; - protected function setUp() : void + protected function setUp(): void { $eventManager = new EventManager(); $driverMock = $this->createMock(Driver::class); @@ -41,7 +42,7 @@ protected function setUp() : void * * @group DBAL-2701 */ - public function testListTableNamesFiltersAssetNamesCorrectly() : void + public function testListTableNamesFiltersAssetNamesCorrectly(): void { $this->conn->getConfiguration()->setFilterSchemaAssetsExpression('/^(?!T_)/'); $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([ @@ -63,7 +64,7 @@ public function testListTableNamesFiltersAssetNamesCorrectly() : void /** * @group DBAL-2701 */ - public function testAssetFilteringSetsACallable() : void + public function testAssetFilteringSetsACallable(): void { $filterExpression = '/^(?!T_)/'; $this->conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression); @@ -89,7 +90,7 @@ public function testAssetFilteringSetsACallable() : void $this->assertEquals($filterExpression, $this->conn->getConfiguration()->getFilterSchemaAssetsExpression()); } - public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable() : void + public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable(): void { $accepted = ['T_FOO', 'T_BAR']; $this->conn->getConfiguration()->setSchemaAssetsFilter(static function ($assetName) use ($accepted) { @@ -114,7 +115,7 @@ public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable() : voi $this->assertNull($this->conn->getConfiguration()->getFilterSchemaAssetsExpression()); } - public function testSettingNullExpressionWillResetCallable() : void + public function testSettingNullExpressionWillResetCallable(): void { $accepted = ['T_FOO', 'T_BAR']; $this->conn->getConfiguration()->setSchemaAssetsFilter(static function ($assetName) use ($accepted) { @@ -151,7 +152,7 @@ public function testSettingNullExpressionWillResetCallable() : void $this->assertNull($this->conn->getConfiguration()->getSchemaAssetsFilter()); } - public function testSettingNullAsCallableClearsExpression() : void + public function testSettingNullAsCallableClearsExpression(): void { $filterExpression = '/^(?!T_)/'; $this->conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression); diff --git a/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php b/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php index 5a59088e42a..763cd336b09 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php @@ -15,7 +15,7 @@ class ForeignKeyConstraintTest extends TestCase * @group DBAL-1062 * @dataProvider getIntersectsIndexColumnsData */ - public function testIntersectsIndexColumns(array $indexColumns, bool $expectedResult) : void + public function testIntersectsIndexColumns(array $indexColumns, bool $expectedResult): void { $foreignKey = new ForeignKeyConstraint(['foo', 'bar'], 'foreign_table', ['fk_foo', 'fk_bar']); @@ -32,7 +32,7 @@ public function testIntersectsIndexColumns(array $indexColumns, bool $expectedRe /** * @return mixed[][] */ - public static function getIntersectsIndexColumnsData() : iterable + public static function getIntersectsIndexColumnsData(): iterable { return [ [['baz'], false], @@ -64,7 +64,7 @@ public static function getIntersectsIndexColumnsData() : iterable * @group DBAL-1062 * @dataProvider getUnqualifiedForeignTableNameData */ - public function testGetUnqualifiedForeignTableName($foreignTableName, string $expectedUnqualifiedTableName) : void + public function testGetUnqualifiedForeignTableName($foreignTableName, string $expectedUnqualifiedTableName): void { $foreignKey = new ForeignKeyConstraint(['foo', 'bar'], $foreignTableName, ['fk_foo', 'fk_bar']); @@ -74,7 +74,7 @@ public function testGetUnqualifiedForeignTableName($foreignTableName, string $ex /** * @return mixed[][] */ - public static function getUnqualifiedForeignTableNameData() : iterable + public static function getUnqualifiedForeignTableNameData(): iterable { return [ ['schema.foreign_table', 'foreign_table'], diff --git a/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php b/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php index d21e676b273..fa5e979e2a0 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php @@ -10,12 +10,12 @@ class IndexTest extends TestCase /** * @param mixed[] $options */ - private function createIndex(bool $unique = false, bool $primary = false, array $options = []) : Index + private function createIndex(bool $unique = false, bool $primary = false, array $options = []): Index { return new Index('foo', ['bar', 'baz'], $unique, $primary, [], $options); } - public function testCreateIndex() : void + public function testCreateIndex(): void { $idx = $this->createIndex(); self::assertEquals('foo', $idx->getName()); @@ -26,14 +26,14 @@ public function testCreateIndex() : void self::assertFalse($idx->isPrimary()); } - public function testCreatePrimary() : void + public function testCreatePrimary(): void { $idx = $this->createIndex(false, true); self::assertTrue($idx->isUnique()); self::assertTrue($idx->isPrimary()); } - public function testCreateUnique() : void + public function testCreateUnique(): void { $idx = $this->createIndex(true, false); self::assertTrue($idx->isUnique()); @@ -43,7 +43,7 @@ public function testCreateUnique() : void /** * @group DBAL-50 */ - public function testFulfilledByUnique() : void + public function testFulfilledByUnique(): void { $idx1 = $this->createIndex(true, false); $idx2 = $this->createIndex(true, false); @@ -56,7 +56,7 @@ public function testFulfilledByUnique() : void /** * @group DBAL-50 */ - public function testFulfilledByPrimary() : void + public function testFulfilledByPrimary(): void { $idx1 = $this->createIndex(true, true); $idx2 = $this->createIndex(true, true); @@ -69,7 +69,7 @@ public function testFulfilledByPrimary() : void /** * @group DBAL-50 */ - public function testFulfilledByIndex() : void + public function testFulfilledByIndex(): void { $idx1 = $this->createIndex(); $idx2 = $this->createIndex(); @@ -81,7 +81,7 @@ public function testFulfilledByIndex() : void self::assertTrue($idx1->isFullfilledBy($uniq)); } - public function testFulfilledWithPartial() : void + public function testFulfilledWithPartial(): void { $without = new Index('without', ['col1', 'col2'], true, false, [], []); $partial = new Index('partial', ['col1', 'col2'], true, false, [], ['where' => 'col1 IS NULL']); @@ -96,7 +96,7 @@ public function testFulfilledWithPartial() : void self::assertTrue($another->isFullfilledBy($partial)); } - public function testOverrulesWithPartial() : void + public function testOverrulesWithPartial(): void { $without = new Index('without', ['col1', 'col2'], true, false, [], []); $partial = new Index('partial', ['col1', 'col2'], true, false, [], ['where' => 'col1 IS NULL']); @@ -118,7 +118,7 @@ public function testOverrulesWithPartial() : void * * @dataProvider indexLengthProvider */ - public function testFulfilledWithLength(array $columns, array $lengths1, array $lengths2, bool $expected) : void + public function testFulfilledWithLength(array $columns, array $lengths1, array $lengths2, bool $expected): void { $index1 = new Index('index1', $columns, false, false, [], ['lengths' => $lengths1]); $index2 = new Index('index2', $columns, false, false, [], ['lengths' => $lengths2]); @@ -130,7 +130,7 @@ public function testFulfilledWithLength(array $columns, array $lengths1, array $ /** * @return mixed[][] */ - public static function indexLengthProvider() : iterable + public static function indexLengthProvider(): iterable { return [ 'empty' => [['column'], [], [], true], @@ -144,7 +144,7 @@ public static function indexLengthProvider() : iterable /** * @group DBAL-220 */ - public function testFlags() : void + public function testFlags(): void { $idx1 = $this->createIndex(); self::assertFalse($idx1->hasFlag('clustered')); @@ -163,7 +163,7 @@ public function testFlags() : void /** * @group DBAL-285 */ - public function testIndexQuotes() : void + public function testIndexQuotes(): void { $index = new Index('foo', ['`bar`', '`baz`']); @@ -175,7 +175,7 @@ public function testIndexQuotes() : void self::assertFalse($index->hasColumnAtPosition('baz', 0)); } - public function testOptions() : void + public function testOptions(): void { $idx1 = $this->createIndex(); self::assertFalse($idx1->hasOption('where')); diff --git a/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php b/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php index e65507b7826..bed295b67d5 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php @@ -14,11 +14,12 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\TestCase; + use function array_merge; class MySqlInheritCharsetTest extends TestCase { - public function testInheritTableOptionsFromDatabase() : void + public function testInheritTableOptionsFromDatabase(): void { // default, no overrides $options = $this->getTableOptionsForOverride(); @@ -35,7 +36,7 @@ public function testInheritTableOptionsFromDatabase() : void self::assertSame($options['charset'], 'utf8mb4'); } - public function testTableOptions() : void + public function testTableOptions(): void { $eventManager = new EventManager(); $driverMock = $this->createMock(Driver::class); @@ -70,7 +71,7 @@ public function testTableOptions() : void * * @return string[] */ - private function getTableOptionsForOverride(array $overrideOptions = []) : array + private function getTableOptionsForOverride(array $overrideOptions = []): array { $eventManager = new EventManager(); $driverMock = $this->createMock(Driver::class); diff --git a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php index f599becad40..9196b086583 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Schema\MySqlSchemaManager; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function array_map; class MySqlSchemaManagerTest extends TestCase @@ -22,7 +23,7 @@ class MySqlSchemaManagerTest extends TestCase /** @var Connection&MockObject */ private $conn; - protected function setUp() : void + protected function setUp(): void { $eventManager = new EventManager(); $driverMock = $this->createMock(Driver::class); @@ -34,7 +35,7 @@ protected function setUp() : void $this->manager = new MySqlSchemaManager($this->conn); } - public function testCompositeForeignKeys() : void + public function testCompositeForeignKeys(): void { $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue($this->getFKDefinition())); $fkeys = $this->manager->listTableForeignKeys('dummy'); @@ -48,7 +49,7 @@ public function testCompositeForeignKeys() : void /** * @return string[][] */ - public function getFKDefinition() : array + public function getFKDefinition(): array { return [ [ diff --git a/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php index 4cf69f28f7c..7b494341e6d 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php @@ -16,13 +16,13 @@ class MySQLSchemaTest extends TestCase /** @var AbstractPlatform */ private $platform; - protected function setUp() : void + protected function setUp(): void { $this->comparator = new Comparator(); $this->platform = new MySqlPlatform(); } - public function testSwitchPrimaryKeyOrder() : void + public function testSwitchPrimaryKeyOrder(): void { $tableOld = new Table('test'); $tableOld->addColumn('foo_id', 'integer'); @@ -47,7 +47,7 @@ public function testSwitchPrimaryKeyOrder() : void /** * @group DBAL-132 */ - public function testGenerateForeignKeySQL() : void + public function testGenerateForeignKeySQL(): void { $tableOld = new Table('test'); $tableOld->addColumn('foo_id', 'integer'); @@ -64,7 +64,7 @@ public function testGenerateForeignKeySQL() : void /** * @group DDC-1737 */ - public function testClobNoAlterTable() : void + public function testClobNoAlterTable(): void { $tableOld = new Table('test'); $tableOld->addColumn('id', 'integer'); diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php index 92bc0c83dd6..141e1e4f1e3 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php @@ -13,7 +13,7 @@ class SchemaDiffTest extends TestCase { - public function testSchemaDiffToSql() : void + public function testSchemaDiffToSql(): void { $diff = $this->createSchemaDiff(); $platform = $this->createPlatform(true); @@ -25,7 +25,7 @@ public function testSchemaDiffToSql() : void self::assertEquals($expected, $sql); } - public function testSchemaDiffToSaveSql() : void + public function testSchemaDiffToSaveSql(): void { $diff = $this->createSchemaDiff(); $platform = $this->createPlatform(false); @@ -108,7 +108,7 @@ private function createPlatform(bool $unsafe) return $platform; } - public function createSchemaDiff() : SchemaDiff + public function createSchemaDiff(): SchemaDiff { $diff = new SchemaDiff(); $diff->newNamespaces['foo_ns'] = 'foo_ns'; diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php index 69796236235..cc665df5bd1 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php @@ -11,12 +11,13 @@ use Doctrine\DBAL\Schema\Visitor\Visitor; use PHPUnit\Framework\TestCase; use ReflectionProperty; + use function current; use function strlen; class SchemaTest extends TestCase { - public function testAddTable() : void + public function testAddTable(): void { $tableName = 'public.foo'; $table = new Table($tableName); @@ -32,7 +33,7 @@ public function testAddTable() : void self::assertTrue($schema->hasTable($tableName)); } - public function testTableMatchingCaseInsensitive() : void + public function testTableMatchingCaseInsensitive(): void { $table = new Table('Foo'); @@ -45,7 +46,7 @@ public function testTableMatchingCaseInsensitive() : void self::assertSame($table, $schema->getTable('Foo')); } - public function testGetUnknownTableThrowsException() : void + public function testGetUnknownTableThrowsException(): void { $this->expectException(SchemaException::class); @@ -53,7 +54,7 @@ public function testGetUnknownTableThrowsException() : void $schema->getTable('unknown'); } - public function testCreateTableTwiceThrowsException() : void + public function testCreateTableTwiceThrowsException(): void { $this->expectException(SchemaException::class); @@ -64,7 +65,7 @@ public function testCreateTableTwiceThrowsException() : void $schema = new Schema($tables); } - public function testRenameTable() : void + public function testRenameTable(): void { $tableName = 'foo'; $table = new Table($tableName); @@ -77,7 +78,7 @@ public function testRenameTable() : void self::assertSame($table, $schema->getTable('bar')); } - public function testDropTable() : void + public function testDropTable(): void { $tableName = 'foo'; $table = new Table($tableName); @@ -90,7 +91,7 @@ public function testDropTable() : void self::assertFalse($schema->hasTable('foo')); } - public function testCreateTable() : void + public function testCreateTable(): void { $schema = new Schema(); @@ -103,7 +104,7 @@ public function testCreateTable() : void self::assertTrue($schema->hasTable('foo')); } - public function testAddSequences() : void + public function testAddSequences(): void { $sequence = new Sequence('a_seq', 1, 1); @@ -116,7 +117,7 @@ public function testAddSequences() : void self::assertArrayHasKey('public.a_seq', $sequences); } - public function testSequenceAccessCaseInsensitive() : void + public function testSequenceAccessCaseInsensitive(): void { $sequence = new Sequence('a_Seq'); @@ -130,7 +131,7 @@ public function testSequenceAccessCaseInsensitive() : void self::assertEquals($sequence, $schema->getSequence('A_SEQ')); } - public function testGetUnknownSequenceThrowsException() : void + public function testGetUnknownSequenceThrowsException(): void { $this->expectException(SchemaException::class); @@ -138,7 +139,7 @@ public function testGetUnknownSequenceThrowsException() : void $schema->getSequence('unknown'); } - public function testCreateSequence() : void + public function testCreateSequence(): void { $schema = new Schema(); $sequence = $schema->createSequence('a_seq', 10, 20); @@ -154,7 +155,7 @@ public function testCreateSequence() : void self::assertArrayHasKey('public.a_seq', $sequences); } - public function testDropSequence() : void + public function testDropSequence(): void { $sequence = new Sequence('a_seq', 1, 1); @@ -164,7 +165,7 @@ public function testDropSequence() : void self::assertFalse($schema->hasSequence('a_seq')); } - public function testAddSequenceTwiceThrowsException() : void + public function testAddSequenceTwiceThrowsException(): void { $this->expectException(SchemaException::class); @@ -173,7 +174,7 @@ public function testAddSequenceTwiceThrowsException() : void $schema = new Schema([], [$sequence, $sequence]); } - public function testConfigMaxIdentifierLength() : void + public function testConfigMaxIdentifierLength(): void { $schemaConfig = new SchemaConfig(); $schemaConfig->setMaxIdentifierLength(5); @@ -187,7 +188,7 @@ public function testConfigMaxIdentifierLength() : void self::assertEquals(5, strlen($index->getName())); } - public function testDeepClone() : void + public function testDeepClone(): void { $schema = new Schema(); $sequence = $schema->createSequence('baz'); @@ -222,7 +223,7 @@ public function testDeepClone() : void /** * @group DBAL-219 */ - public function testHasTableForQuotedAsset() : void + public function testHasTableForQuotedAsset(): void { $schema = new Schema(); @@ -235,7 +236,7 @@ public function testHasTableForQuotedAsset() : void /** * @group DBAL-669 */ - public function testHasNamespace() : void + public function testHasNamespace(): void { $schema = new Schema(); @@ -259,7 +260,7 @@ public function testHasNamespace() : void /** * @group DBAL-669 */ - public function testCreatesNamespace() : void + public function testCreatesNamespace(): void { $schema = new Schema(); @@ -285,7 +286,7 @@ public function testCreatesNamespace() : void /** * @group DBAL-669 */ - public function testThrowsExceptionOnCreatingNamespaceTwice() : void + public function testThrowsExceptionOnCreatingNamespaceTwice(): void { $schema = new Schema(); @@ -299,7 +300,7 @@ public function testThrowsExceptionOnCreatingNamespaceTwice() : void /** * @group DBAL-669 */ - public function testCreatesNamespaceThroughAddingTableImplicitly() : void + public function testCreatesNamespaceThroughAddingTableImplicitly(): void { $schema = new Schema(); @@ -329,7 +330,7 @@ public function testCreatesNamespaceThroughAddingTableImplicitly() : void /** * @group DBAL-669 */ - public function testCreatesNamespaceThroughAddingSequenceImplicitly() : void + public function testCreatesNamespaceThroughAddingSequenceImplicitly(): void { $schema = new Schema(); @@ -359,7 +360,7 @@ public function testCreatesNamespaceThroughAddingSequenceImplicitly() : void /** * @group DBAL-669 */ - public function testVisitsVisitor() : void + public function testVisitsVisitor(): void { $schema = new Schema(); $visitor = $this->createMock(Visitor::class); @@ -405,7 +406,7 @@ public function testVisitsVisitor() : void /** * @group DBAL-669 */ - public function testVisitsNamespaceVisitor() : void + public function testVisitsNamespaceVisitor(): void { $schema = new Schema(); $visitor = $this->createMock(AbstractVisitor::class); diff --git a/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php b/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php index d13d0a908a6..a6314904c4e 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php @@ -11,7 +11,7 @@ class SequenceTest extends DbalTestCase /** * @group DDC-1657 */ - public function testIsAutoincrementFor() : void + public function testIsAutoincrementFor(): void { $table = new Table('foo'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -26,7 +26,7 @@ public function testIsAutoincrementFor() : void self::assertFalse($sequence3->isAutoIncrementsFor($table)); } - public function testIsAutoincrementForCaseInsensitive() : void + public function testIsAutoincrementForCaseInsensitive(): void { $table = new Table('foo'); $table->addColumn('ID', 'integer', ['autoincrement' => true]); diff --git a/tests/Doctrine/Tests/DBAL/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/SqliteSchemaManagerTest.php index 3677212f240..5a473d13c92 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SqliteSchemaManagerTest.php @@ -14,7 +14,7 @@ class SqliteSchemaManagerTest extends TestCase * @dataProvider getDataColumnCollation * @group 2865 */ - public function testParseColumnCollation(?string $collation, string $column, string $sql) : void + public function testParseColumnCollation(?string $collation, string $column, string $sql): void { $conn = $this->createMock(Connection::class); $conn->method('getDatabasePlatform')->willReturn(new SqlitePlatform()); @@ -29,7 +29,7 @@ public function testParseColumnCollation(?string $collation, string $column, str /** * @return mixed[][] */ - public static function getDataColumnCollation() : iterable + public static function getDataColumnCollation(): iterable { return [ ['RTRIM', 'a', 'CREATE TABLE "a" ("a" text DEFAULT "aa" COLLATE "RTRIM" NOT NULL)'], @@ -55,7 +55,7 @@ public static function getDataColumnCollation() : iterable * @dataProvider getDataColumnComment * @group 2865 */ - public function testParseColumnCommentFromSQL(?string $comment, string $column, string $sql) : void + public function testParseColumnCommentFromSQL(?string $comment, string $column, string $sql): void { $conn = $this->createMock(Connection::class); $conn->method('getDatabasePlatform')->willReturn(new SqlitePlatform()); @@ -70,7 +70,7 @@ public function testParseColumnCommentFromSQL(?string $comment, string $column, /** * @return mixed[][] */ - public static function getDataColumnComment() : iterable + public static function getDataColumnComment(): iterable { return [ 'Single column with no comment' => [ diff --git a/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php b/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php index ad24ca599a6..c2dc73b3cb8 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php @@ -19,7 +19,7 @@ class SingleDatabaseSynchronizerTest extends TestCase /** @var SingleDatabaseSynchronizer */ private $synchronizer; - protected function setUp() : void + protected function setUp(): void { $this->conn = DriverManager::getConnection([ 'driver' => 'pdo_sqlite', @@ -28,7 +28,7 @@ protected function setUp() : void $this->synchronizer = new SingleDatabaseSynchronizer($this->conn); } - public function testGetCreateSchema() : void + public function testGetCreateSchema(): void { $schema = new Schema(); $table = $schema->createTable('test'); @@ -39,7 +39,7 @@ public function testGetCreateSchema() : void self::assertEquals(['CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'], $sql); } - public function testGetUpdateSchema() : void + public function testGetUpdateSchema(): void { $schema = new Schema(); $table = $schema->createTable('test'); @@ -50,7 +50,7 @@ public function testGetUpdateSchema() : void self::assertEquals(['CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'], $sql); } - public function testGetDropSchema() : void + public function testGetDropSchema(): void { $schema = new Schema(); $table = $schema->createTable('test'); @@ -63,7 +63,7 @@ public function testGetDropSchema() : void self::assertEquals(['DROP TABLE test'], $sql); } - public function testGetDropAllSchema() : void + public function testGetDropAllSchema(): void { $schema = new Schema(); $table = $schema->createTable('test'); diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php index 7ae17019f83..2a5608608bb 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php @@ -14,7 +14,7 @@ class TableDiffTest extends TestCase /** @var AbstractPlatform|MockObject */ private $platform; - public function setUp() : void + public function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); } @@ -22,7 +22,7 @@ public function setUp() : void /** * @group DBAL-1013 */ - public function testReturnsName() : void + public function testReturnsName(): void { $tableDiff = new TableDiff('foo'); @@ -32,7 +32,7 @@ public function testReturnsName() : void /** * @group DBAL-1016 */ - public function testPrefersNameFromTableObject() : void + public function testPrefersNameFromTableObject(): void { $tableMock = $this->getMockBuilder(Table::class) ->disableOriginalConstructor() @@ -52,7 +52,7 @@ public function testPrefersNameFromTableObject() : void /** * @group DBAL-1013 */ - public function testReturnsNewName() : void + public function testReturnsNewName(): void { $tableDiff = new TableDiff('foo'); diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php index d330e758184..f98062b50b2 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php @@ -12,25 +12,26 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalTestCase; + use function array_shift; use function current; class TableTest extends DbalTestCase { - public function testCreateWithInvalidTableName() : void + public function testCreateWithInvalidTableName(): void { $this->expectException(DBALException::class); new Table(''); } - public function testGetName() : void + public function testGetName(): void { $table = new Table('foo', [], [], []); self::assertEquals('foo', $table->getName()); } - public function testColumns() : void + public function testColumns(): void { $type = Type::getType('integer'); $columns = []; @@ -48,7 +49,7 @@ public function testColumns() : void self::assertCount(2, $table->getColumns()); } - public function testColumnsCaseInsensitive() : void + public function testColumnsCaseInsensitive(): void { $table = new Table('foo'); $column = $table->addColumn('Foo', 'integer'); @@ -62,7 +63,7 @@ public function testColumnsCaseInsensitive() : void self::assertSame($column, $table->getColumn('FOO')); } - public function testCreateColumn() : void + public function testCreateColumn(): void { $type = Type::getType('integer'); @@ -74,7 +75,7 @@ public function testCreateColumn() : void self::assertSame($type, $table->getColumn('bar')->getType()); } - public function testDropColumn() : void + public function testDropColumn(): void { $type = Type::getType('integer'); $columns = []; @@ -91,7 +92,7 @@ public function testDropColumn() : void self::assertFalse($table->hasColumn('bar')); } - public function testGetUnknownColumnThrowsException() : void + public function testGetUnknownColumnThrowsException(): void { $this->expectException(SchemaException::class); @@ -99,7 +100,7 @@ public function testGetUnknownColumnThrowsException() : void $table->getColumn('unknown'); } - public function testAddColumnTwiceThrowsException() : void + public function testAddColumnTwiceThrowsException(): void { $this->expectException(SchemaException::class); @@ -110,7 +111,7 @@ public function testAddColumnTwiceThrowsException() : void $table = new Table('foo', $columns, [], []); } - public function testCreateIndex() : void + public function testCreateIndex(): void { $type = Type::getType('integer'); $columns = [new Column('foo', $type), new Column('bar', $type), new Column('baz', $type)]; @@ -123,7 +124,7 @@ public function testCreateIndex() : void self::assertTrue($table->hasIndex('foo_bar_baz_uniq')); } - public function testIndexCaseInsensitive() : void + public function testIndexCaseInsensitive(): void { $type = Type::getType('integer'); $columns = [ @@ -140,7 +141,7 @@ public function testIndexCaseInsensitive() : void self::assertTrue($table->hasIndex('FOO_IDX')); } - public function testAddIndexes() : void + public function testAddIndexes(): void { $type = Type::getType('integer'); $columns = [ @@ -162,7 +163,7 @@ public function testAddIndexes() : void self::assertInstanceOf(Index::class, $table->getIndex('bar_idx')); } - public function testGetUnknownIndexThrowsException() : void + public function testGetUnknownIndexThrowsException(): void { $this->expectException(SchemaException::class); @@ -170,7 +171,7 @@ public function testGetUnknownIndexThrowsException() : void $table->getIndex('unknownIndex'); } - public function testAddTwoPrimaryThrowsException() : void + public function testAddTwoPrimaryThrowsException(): void { $this->expectException(SchemaException::class); @@ -183,7 +184,7 @@ public function testAddTwoPrimaryThrowsException() : void $table = new Table('foo', $columns, $indexes, []); } - public function testAddTwoIndexesWithSameNameThrowsException() : void + public function testAddTwoIndexesWithSameNameThrowsException(): void { $this->expectException(SchemaException::class); @@ -196,7 +197,7 @@ public function testAddTwoIndexesWithSameNameThrowsException() : void $table = new Table('foo', $columns, $indexes, []); } - public function testConstraints() : void + public function testConstraints(): void { $constraint = new ForeignKeyConstraint([], 'foo', []); @@ -207,7 +208,7 @@ public function testConstraints() : void self::assertSame($constraint, array_shift($constraints)); } - public function testOptions() : void + public function testOptions(): void { $table = new Table('foo', [], [], [], false, ['foo' => 'bar']); @@ -215,7 +216,7 @@ public function testOptions() : void self::assertEquals('bar', $table->getOption('foo')); } - public function testBuilderSetPrimaryKey() : void + public function testBuilderSetPrimaryKey(): void { $table = new Table('foo'); @@ -228,7 +229,7 @@ public function testBuilderSetPrimaryKey() : void self::assertTrue($table->getIndex('primary')->isPrimary()); } - public function testBuilderAddUniqueIndex() : void + public function testBuilderAddUniqueIndex(): void { $table = new Table('foo'); @@ -240,7 +241,7 @@ public function testBuilderAddUniqueIndex() : void self::assertFalse($table->getIndex('my_idx')->isPrimary()); } - public function testBuilderAddIndex() : void + public function testBuilderAddIndex(): void { $table = new Table('foo'); @@ -252,7 +253,7 @@ public function testBuilderAddIndex() : void self::assertFalse($table->getIndex('my_idx')->isPrimary()); } - public function testBuilderAddIndexWithInvalidNameThrowsException() : void + public function testBuilderAddIndexWithInvalidNameThrowsException(): void { $this->expectException(SchemaException::class); @@ -261,7 +262,7 @@ public function testBuilderAddIndexWithInvalidNameThrowsException() : void $table->addIndex(['bar'], 'invalid name %&/'); } - public function testBuilderAddIndexWithUnknownColumnThrowsException() : void + public function testBuilderAddIndexWithUnknownColumnThrowsException(): void { $this->expectException(SchemaException::class); @@ -269,7 +270,7 @@ public function testBuilderAddIndexWithUnknownColumnThrowsException() : void $table->addIndex(['bar'], 'invalidName'); } - public function testBuilderOptions() : void + public function testBuilderOptions(): void { $table = new Table('foo'); $table->addOption('foo', 'bar'); @@ -277,7 +278,7 @@ public function testBuilderOptions() : void self::assertEquals('bar', $table->getOption('foo')); } - public function testAddForeignKeyConstraintUnknownLocalColumnThrowsException() : void + public function testAddForeignKeyConstraintUnknownLocalColumnThrowsException(): void { $this->expectException(SchemaException::class); @@ -290,7 +291,7 @@ public function testAddForeignKeyConstraintUnknownLocalColumnThrowsException() : $table->addForeignKeyConstraint($foreignTable, ['foo'], ['id']); } - public function testAddForeignKeyConstraintUnknownForeignColumnThrowsException() : void + public function testAddForeignKeyConstraintUnknownForeignColumnThrowsException(): void { $this->expectException(SchemaException::class); @@ -303,7 +304,7 @@ public function testAddForeignKeyConstraintUnknownForeignColumnThrowsException() $table->addForeignKeyConstraint($foreignTable, ['id'], ['foo']); } - public function testAddForeignKeyConstraint() : void + public function testAddForeignKeyConstraint(): void { $table = new Table('foo'); $table->addColumn('id', 'integer'); @@ -323,7 +324,7 @@ public function testAddForeignKeyConstraint() : void self::assertEquals('bar', $constraint->getOption('foo')); } - public function testAddIndexWithCaseSensitiveColumnProblem() : void + public function testAddIndexWithCaseSensitiveColumnProblem(): void { $table = new Table('foo'); $table->addColumn('id', 'integer'); @@ -335,7 +336,7 @@ public function testAddIndexWithCaseSensitiveColumnProblem() : void self::assertTrue($table->getIndex('my_idx')->spansColumns(['id'])); } - public function testAddPrimaryKeyColumnsAreExplicitlySetToNotNull() : void + public function testAddPrimaryKeyColumnsAreExplicitlySetToNotNull(): void { $table = new Table('foo'); $column = $table->addColumn('id', 'integer', ['notnull' => false]); @@ -350,7 +351,7 @@ public function testAddPrimaryKeyColumnsAreExplicitlySetToNotNull() : void /** * @group DDC-133 */ - public function testAllowImplicitSchemaTableInAutogeneratedIndexNames() : void + public function testAllowImplicitSchemaTableInAutogeneratedIndexNames(): void { $table = new Table('foo.bar'); $table->addColumn('baz', 'integer', []); @@ -362,7 +363,7 @@ public function testAllowImplicitSchemaTableInAutogeneratedIndexNames() : void /** * @group DBAL-50 */ - public function testAddForeignKeyIndexImplicitly() : void + public function testAddForeignKeyIndexImplicitly(): void { $table = new Table('foo'); $table->addColumn('id', 'integer'); @@ -383,7 +384,7 @@ public function testAddForeignKeyIndexImplicitly() : void /** * @group DBAL-1063 */ - public function testAddForeignKeyDoesNotCreateDuplicateIndex() : void + public function testAddForeignKeyDoesNotCreateDuplicateIndex(): void { $table = new Table('foo'); $table->addColumn('bar', 'integer'); @@ -402,7 +403,7 @@ public function testAddForeignKeyDoesNotCreateDuplicateIndex() : void /** * @group DBAL-1063 */ - public function testAddForeignKeyAddsImplicitIndexIfIndexColumnsDoNotSpan() : void + public function testAddForeignKeyAddsImplicitIndexIfIndexColumnsDoNotSpan(): void { $table = new Table('foo'); $table->addColumn('bar', 'integer'); @@ -430,7 +431,7 @@ public function testAddForeignKeyAddsImplicitIndexIfIndexColumnsDoNotSpan() : vo * @group DBAL-50 * @group DBAL-1063 */ - public function testOverrulingIndexDoesNotDropOverruledIndex() : void + public function testOverrulingIndexDoesNotDropOverruledIndex(): void { $table = new Table('bar'); $table->addColumn('baz', 'integer', []); @@ -448,7 +449,7 @@ public function testOverrulingIndexDoesNotDropOverruledIndex() : void /** * @group DBAL-1063 */ - public function testAllowsAddingDuplicateIndexesBasedOnColumns() : void + public function testAllowsAddingDuplicateIndexesBasedOnColumns(): void { $table = new Table('foo'); $table->addColumn('bar', 'integer'); @@ -465,7 +466,7 @@ public function testAllowsAddingDuplicateIndexesBasedOnColumns() : void /** * @group DBAL-1063 */ - public function testAllowsAddingFulfillingIndexesBasedOnColumns() : void + public function testAllowsAddingFulfillingIndexesBasedOnColumns(): void { $table = new Table('foo'); $table->addColumn('bar', 'integer'); @@ -484,7 +485,7 @@ public function testAllowsAddingFulfillingIndexesBasedOnColumns() : void * @group DBAL-50 * @group DBAL-1063 */ - public function testPrimaryKeyOverrulingUniqueIndexDoesNotDropUniqueIndex() : void + public function testPrimaryKeyOverrulingUniqueIndexDoesNotDropUniqueIndex(): void { $table = new Table('bar'); $table->addColumn('baz', 'integer', []); @@ -499,7 +500,7 @@ public function testPrimaryKeyOverrulingUniqueIndexDoesNotDropUniqueIndex() : vo self::assertTrue($table->hasIndex('idx_unique')); } - public function testAddingFulfillingRegularIndexOverridesImplicitForeignKeyConstraintIndex() : void + public function testAddingFulfillingRegularIndexOverridesImplicitForeignKeyConstraintIndex(): void { $foreignTable = new Table('foreign'); $foreignTable->addColumn('id', 'integer'); @@ -516,7 +517,7 @@ public function testAddingFulfillingRegularIndexOverridesImplicitForeignKeyConst self::assertTrue($localTable->hasIndex('explicit_idx')); } - public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstraintIndex() : void + public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstraintIndex(): void { $foreignTable = new Table('foreign'); $foreignTable->addColumn('id', 'integer'); @@ -533,7 +534,7 @@ public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstr self::assertTrue($localTable->hasIndex('explicit_idx')); } - public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstraintIndex() : void + public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstraintIndex(): void { $foreignTable = new Table('foreign'); $foreignTable->addColumn('id', 'integer'); @@ -550,7 +551,7 @@ public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstra self::assertTrue($localTable->hasIndex('explicit_idx')); } - public function testAddingFulfillingExplicitIndexOverridingImplicitForeignKeyConstraintIndexWithSameNameDoesNotThrowException() : void + public function testAddingFulfillingExplicitIndexOverridingImplicitForeignKeyConstraintIndexWithSameNameDoesNotThrowException(): void { $foreignTable = new Table('foreign'); $foreignTable->addColumn('id', 'integer'); @@ -574,7 +575,7 @@ public function testAddingFulfillingExplicitIndexOverridingImplicitForeignKeyCon /** * @group DBAL-64 */ - public function testQuotedTableName() : void + public function testQuotedTableName(): void { $table = new Table('`bar`'); @@ -589,7 +590,7 @@ public function testQuotedTableName() : void /** * @group DBAL-79 */ - public function testTableHasPrimaryKey() : void + public function testTableHasPrimaryKey(): void { $table = new Table('test'); @@ -604,7 +605,7 @@ public function testTableHasPrimaryKey() : void /** * @group DBAL-91 */ - public function testAddIndexWithQuotedColumns() : void + public function testAddIndexWithQuotedColumns(): void { $table = new Table('test'); $table->addColumn('"foo"', 'integer'); @@ -617,7 +618,7 @@ public function testAddIndexWithQuotedColumns() : void /** * @group DBAL-91 */ - public function testAddForeignKeyWithQuotedColumnsAndTable() : void + public function testAddForeignKeyWithQuotedColumnsAndTable(): void { $table = new Table('test'); $table->addColumn('"foo"', 'integer'); @@ -630,7 +631,7 @@ public function testAddForeignKeyWithQuotedColumnsAndTable() : void /** * @group DBAL-177 */ - public function testQuoteSchemaPrefixed() : void + public function testQuoteSchemaPrefixed(): void { $table = new Table('`test`.`test`'); self::assertEquals('test.test', $table->getName()); @@ -640,7 +641,7 @@ public function testQuoteSchemaPrefixed() : void /** * @group DBAL-204 */ - public function testFullQualifiedTableName() : void + public function testFullQualifiedTableName(): void { $table = new Table('`test`.`test`'); self::assertEquals('test.test', $table->getFullQualifiedName('test')); @@ -654,7 +655,7 @@ public function testFullQualifiedTableName() : void /** * @group DBAL-224 */ - public function testDropIndex() : void + public function testDropIndex(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -669,7 +670,7 @@ public function testDropIndex() : void /** * @group DBAL-224 */ - public function testDropPrimaryKey() : void + public function testDropPrimaryKey(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -684,7 +685,7 @@ public function testDropPrimaryKey() : void /** * @group DBAL-234 */ - public function testRenameIndex() : void + public function testRenameIndex(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -756,7 +757,7 @@ public function testRenameIndex() : void /** * @group DBAL-2508 */ - public function testKeepsIndexOptionsOnRenamingRegularIndex() : void + public function testKeepsIndexOptionsOnRenamingRegularIndex(): void { $table = new Table('foo'); $table->addColumn('id', 'integer'); @@ -770,7 +771,7 @@ public function testKeepsIndexOptionsOnRenamingRegularIndex() : void /** * @group DBAL-2508 */ - public function testKeepsIndexOptionsOnRenamingUniqueIndex() : void + public function testKeepsIndexOptionsOnRenamingUniqueIndex(): void { $table = new Table('foo'); $table->addColumn('id', 'integer'); @@ -784,7 +785,7 @@ public function testKeepsIndexOptionsOnRenamingUniqueIndex() : void /** * @group DBAL-234 */ - public function testThrowsExceptionOnRenamingNonExistingIndex() : void + public function testThrowsExceptionOnRenamingNonExistingIndex(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -798,7 +799,7 @@ public function testThrowsExceptionOnRenamingNonExistingIndex() : void /** * @group DBAL-234 */ - public function testThrowsExceptionOnRenamingToAlreadyExistingIndex() : void + public function testThrowsExceptionOnRenamingToAlreadyExistingIndex(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -815,7 +816,7 @@ public function testThrowsExceptionOnRenamingToAlreadyExistingIndex() : void * @dataProvider getNormalizesAssetNames * @group DBAL-831 */ - public function testNormalizesColumnNames(string $assetName) : void + public function testNormalizesColumnNames(string $assetName): void { $table = new Table('test'); @@ -872,7 +873,7 @@ public function testNormalizesColumnNames(string $assetName) : void /** * @return mixed[][] */ - public static function getNormalizesAssetNames() : iterable + public static function getNormalizesAssetNames(): iterable { return [ ['foo'], @@ -886,7 +887,7 @@ public static function getNormalizesAssetNames() : iterable ]; } - public function testTableComment() : void + public function testTableComment(): void { $table = new Table('bar'); self::assertNull($table->getComment()); diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php index c60c2c41e71..ae7ba2a1efc 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php @@ -18,7 +18,7 @@ class CreateSchemaSqlCollectorTest extends TestCase /** @var CreateSchemaSqlCollector */ private $visitor; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -45,7 +45,7 @@ protected function setUp() : void ->willReturn(['foo']); } - public function testAcceptsNamespace() : void + public function testAcceptsNamespace(): void { $this->platformMock->expects($this->at(0)) ->method('supportsSchemas') @@ -64,7 +64,7 @@ public function testAcceptsNamespace() : void self::assertSame(['foo'], $this->visitor->getQueries()); } - public function testAcceptsTable() : void + public function testAcceptsTable(): void { $table = $this->createTableMock(); @@ -73,7 +73,7 @@ public function testAcceptsTable() : void self::assertSame(['foo'], $this->visitor->getQueries()); } - public function testAcceptsForeignKey() : void + public function testAcceptsForeignKey(): void { $this->platformMock->expects($this->at(0)) ->method('supportsCreateDropForeignKeyConstraints') @@ -95,7 +95,7 @@ public function testAcceptsForeignKey() : void self::assertSame(['foo'], $this->visitor->getQueries()); } - public function testAcceptsSequences() : void + public function testAcceptsSequences(): void { $sequence = $this->createSequenceMock(); @@ -104,7 +104,7 @@ public function testAcceptsSequences() : void self::assertSame(['foo'], $this->visitor->getQueries()); } - public function testResetsQueries() : void + public function testResetsQueries(): void { foreach (['supportsSchemas', 'supportsCreateDropForeignKeyConstraints'] as $method) { $this->platformMock->expects($this->any()) diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php index 12e3678cbf6..bd663dc93e6 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php @@ -14,7 +14,7 @@ */ class DropSchemaSqlCollectorTest extends TestCase { - public function testGetQueriesUsesAcceptedForeignKeys() : void + public function testGetQueriesUsesAcceptedForeignKeys(): void { $tableOne = $this->createMock(Table::class); $tableTwo = $this->createMock(Table::class); @@ -45,7 +45,7 @@ public function testGetQueriesUsesAcceptedForeignKeys() : void $collector->getQueries(); } - private function getStubKeyConstraint(string $name) : ForeignKeyConstraint + private function getStubKeyConstraint(string $name): ForeignKeyConstraint { $constraint = $this->createMock(ForeignKeyConstraint::class); @@ -64,7 +64,7 @@ private function getStubKeyConstraint(string $name) : ForeignKeyConstraint return $constraint; } - public function testGivenForeignKeyWithZeroLengthAcceptForeignKeyThrowsException() : void + public function testGivenForeignKeyWithZeroLengthAcceptForeignKeyThrowsException(): void { $collector = new DropSchemaSqlCollector( $this->getMockForAbstractClass(AbstractPlatform::class) diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php index 982da52ec44..bf4127e0143 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Schema\SchemaConfig; use Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets; use PHPUnit\Framework\TestCase; + use function array_keys; class RemoveNamespacedAssetsTest extends TestCase @@ -14,7 +15,7 @@ class RemoveNamespacedAssetsTest extends TestCase /** * @group DBAL-204 */ - public function testRemoveNamespacedAssets() : void + public function testRemoveNamespacedAssets(): void { $config = new SchemaConfig(); $config->setName('test'); @@ -33,7 +34,7 @@ public function testRemoveNamespacedAssets() : void /** * @group DBAL-204 */ - public function testCleanupForeignKeys() : void + public function testCleanupForeignKeys(): void { $config = new SchemaConfig(); $config->setName('test'); @@ -56,7 +57,7 @@ public function testCleanupForeignKeys() : void /** * @group DBAL-204 */ - public function testCleanupForeignKeysDifferentOrder() : void + public function testCleanupForeignKeysDifferentOrder(): void { $config = new SchemaConfig(); $config->setName('test'); diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php index 60c7f2a1f5b..93ccef355f9 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php @@ -8,7 +8,7 @@ class SchemaSqlCollectorTest extends TestCase { - public function testCreateSchema() : void + public function testCreateSchema(): void { $platformMock = $this->getMockBuilder(MySqlPlatform::class) ->onlyMethods(['getCreateTableSql', 'getCreateSequenceSql', 'getCreateForeignKeySql']) @@ -30,7 +30,7 @@ public function testCreateSchema() : void self::assertEquals(['foo', 'foo', 'bar', 'baz'], $sql); } - public function testDropSchema() : void + public function testDropSchema(): void { $platformMock = $this->getMockBuilder(MySqlPlatform::class) ->onlyMethods(['getDropTableSql', 'getDropSequenceSql', 'getDropForeignKeySql']) @@ -52,7 +52,7 @@ public function testDropSchema() : void self::assertEquals(['fk', 'seq', 'tbl', 'tbl'], $sql); } - public function createFixtureSchema() : Schema + public function createFixtureSchema(): Schema { $schema = new Schema(); $tableA = $schema->createTable('foo'); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php index c782b06b919..ada144c9922 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php @@ -14,7 +14,7 @@ */ class PoolingShardConnectionTest extends TestCase { - public function testConnect() : void + public function testConnect(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -48,7 +48,7 @@ public function testConnect() : void self::assertFalse($conn->isConnected(2)); } - public function testNoGlobalServerException() : void + public function testNoGlobalServerException(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Connection Parameters require 'global' and 'shards' configurations."); @@ -64,7 +64,7 @@ public function testNoGlobalServerException() : void ]); } - public function testNoShardsServersException() : void + public function testNoShardsServersException(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Connection Parameters require 'global' and 'shards' configurations."); @@ -77,7 +77,7 @@ public function testNoShardsServersException() : void ]); } - public function testNoShardsChoserException() : void + public function testNoShardsChoserException(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Missing Shard Choser configuration 'shardChoser'"); @@ -93,7 +93,7 @@ public function testNoShardsChoserException() : void ]); } - public function testShardChoserWrongInstance() : void + public function testShardChoserWrongInstance(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("The 'shardChoser' configuration is not a valid instance of Doctrine\DBAL\Sharding\ShardChoser\ShardChoser"); @@ -110,7 +110,7 @@ public function testShardChoserWrongInstance() : void ]); } - public function testShardNonNumericId() : void + public function testShardNonNumericId(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage('Shard Id has to be a non-negative number.'); @@ -126,7 +126,7 @@ public function testShardNonNumericId() : void ]); } - public function testShardMissingId() : void + public function testShardMissingId(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Missing 'id' for one configured shard. Please specify a unique shard-id."); @@ -142,7 +142,7 @@ public function testShardMissingId() : void ]); } - public function testDuplicateShardId() : void + public function testDuplicateShardId(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage('Shard 1 is duplicated in the configuration.'); @@ -159,7 +159,7 @@ public function testDuplicateShardId() : void ]); } - public function testSwitchShardWithOpenTransactionException() : void + public function testSwitchShardWithOpenTransactionException(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -178,7 +178,7 @@ public function testSwitchShardWithOpenTransactionException() : void $conn->connect(1); } - public function testGetActiveShardId() : void + public function testGetActiveShardId(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -202,7 +202,7 @@ public function testGetActiveShardId() : void self::assertNull($conn->getActiveShardId()); } - public function testGetParamsOverride() : void + public function testGetParamsOverride(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -241,7 +241,7 @@ public function testGetParamsOverride() : void ], $conn->getParams()); } - public function testGetHostOverride() : void + public function testGetHostOverride(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -260,7 +260,7 @@ public function testGetHostOverride() : void self::assertEquals('foo', $conn->getHost()); } - public function testGetPortOverride() : void + public function testGetPortOverride(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -279,7 +279,7 @@ public function testGetPortOverride() : void self::assertEquals(3307, $conn->getPort()); } - public function testGetUsernameOverride() : void + public function testGetUsernameOverride(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -298,7 +298,7 @@ public function testGetUsernameOverride() : void self::assertEquals('bar', $conn->getUsername()); } - public function testGetPasswordOverride() : void + public function testGetPasswordOverride(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php index eafbd69cfcb..dc42a38e024 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php @@ -13,7 +13,7 @@ class PoolingShardManagerTest extends TestCase /** * @return PoolingShardConnection|MockObject */ - private function createConnectionMock() : PoolingShardConnection + private function createConnectionMock(): PoolingShardConnection { return $this->getMockBuilder(PoolingShardConnection::class) ->onlyMethods(['connect', 'getParams', 'fetchAll']) @@ -21,7 +21,7 @@ private function createConnectionMock() : PoolingShardConnection ->getMock(); } - private function createPassthroughShardChoser() : ShardChoser + private function createPassthroughShardChoser(): ShardChoser { $mock = $this->createMock(ShardChoser::class); $mock->expects($this->any()) @@ -33,7 +33,7 @@ private function createPassthroughShardChoser() : ShardChoser return $mock; } - private function createStaticShardChooser() : ShardChoser + private function createStaticShardChooser(): ShardChoser { $mock = $this->createMock(ShardChoser::class); $mock->expects($this->any()) @@ -43,7 +43,7 @@ private function createStaticShardChooser() : ShardChoser return $mock; } - public function testSelectGlobal() : void + public function testSelectGlobal(): void { $conn = $this->createConnectionMock(); $conn->expects($this->once())->method('connect')->with($this->equalTo(0)); @@ -58,7 +58,7 @@ public function testSelectGlobal() : void self::assertNull($shardManager->getCurrentDistributionValue()); } - public function testSelectShard() : void + public function testSelectShard(): void { $shardId = 10; $conn = $this->createConnectionMock(); @@ -71,12 +71,12 @@ public function testSelectShard() : void self::assertEquals($shardId, $shardManager->getCurrentDistributionValue()); } - public function testGetShards() : void + public function testGetShards(): void { $conn = $this->createConnectionMock(); $conn->expects($this->any())->method('getParams')->will( $this->returnValue( - ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createPassthroughShardChoser()] + ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createPassthroughShardChoser()] ) ); @@ -86,7 +86,7 @@ public function testGetShards() : void self::assertEquals([['id' => 1], ['id' => 2]], $shards); } - public function testQueryAll() : void + public function testQueryAll(): void { $sql = 'SELECT * FROM table'; $params = [1]; @@ -94,21 +94,21 @@ public function testQueryAll() : void $conn = $this->createConnectionMock(); $conn->expects($this->at(0))->method('getParams')->will($this->returnValue( - ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createPassthroughShardChoser()] + ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createPassthroughShardChoser()] )); $conn->expects($this->at(1))->method('getParams')->will($this->returnValue( - ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createPassthroughShardChoser()] + ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createPassthroughShardChoser()] )); $conn->expects($this->at(2))->method('connect')->with($this->equalTo(1)); $conn->expects($this->at(3)) ->method('fetchAll') ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue([ ['id' => 1] ])); + ->will($this->returnValue([['id' => 1]])); $conn->expects($this->at(4))->method('connect')->with($this->equalTo(2)); $conn->expects($this->at(5)) ->method('fetchAll') ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue([ ['id' => 2] ])); + ->will($this->returnValue([['id' => 2]])); $shardManager = new PoolingShardManager($conn); $result = $shardManager->queryAll($sql, $params, $types); @@ -116,7 +116,7 @@ public function testQueryAll() : void self::assertEquals([['id' => 1], ['id' => 2]], $result); } - public function testQueryAllWithStaticShardChoser() : void + public function testQueryAllWithStaticShardChoser(): void { $sql = 'SELECT * FROM table'; $params = [1]; @@ -124,21 +124,21 @@ public function testQueryAllWithStaticShardChoser() : void $conn = $this->createConnectionMock(); $conn->expects($this->at(0))->method('getParams')->will($this->returnValue( - ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createStaticShardChooser()] + ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createStaticShardChooser()] )); $conn->expects($this->at(1))->method('getParams')->will($this->returnValue( - ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createStaticShardChooser()] + ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createStaticShardChooser()] )); $conn->expects($this->at(2))->method('connect')->with($this->equalTo(1)); $conn->expects($this->at(3)) ->method('fetchAll') ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue([ ['id' => 1] ])); + ->will($this->returnValue([['id' => 1]])); $conn->expects($this->at(4))->method('connect')->with($this->equalTo(2)); $conn->expects($this->at(5)) ->method('fetchAll') ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue([ ['id' => 2] ])); + ->will($this->returnValue([['id' => 2]])); $shardManager = new PoolingShardManager($conn); $result = $shardManager->queryAll($sql, $params, $types); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php index 7907c67b5a3..8ad29bfcef6 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Sharding\SQLAzure\SQLAzureShardManager; use PHPUnit\Framework\TestCase; + use function strpos; abstract class AbstractTestCase extends TestCase @@ -17,7 +18,7 @@ abstract class AbstractTestCase extends TestCase /** @var SQLAzureShardManager */ protected $sm; - protected function setUp() : void + protected function setUp(): void { if (! isset($GLOBALS['db_driver']) || strpos($GLOBALS['db_driver'], 'sqlsrv') === false) { $this->markTestSkipped('No driver or sqlserver driver specified.'); @@ -52,7 +53,7 @@ protected function setUp() : void $this->sm = new SQLAzureShardManager($this->conn); } - protected function createShopSchema() : Schema + protected function createShopSchema(): Schema { $schema = new Schema(); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php index 6e31d8716ed..98ab482a7c6 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php @@ -3,11 +3,12 @@ namespace Doctrine\Tests\DBAL\Sharding\SQLAzure; use Doctrine\DBAL\Sharding\SQLAzure\SQLAzureFederationsSynchronizer; + use function count; class FunctionalTest extends AbstractTestCase { - public function testSharding() : void + public function testSharding(): void { $schema = $this->createShopSchema(); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php index 3549cf40b0e..f12379fafee 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php @@ -9,7 +9,7 @@ class MultiTenantVisitorTest extends TestCase { - public function testMultiTenantPrimaryKey() : void + public function testMultiTenantPrimaryKey(): void { $platform = new SQLAzurePlatform(); $visitor = new MultiTenantVisitor(); @@ -24,7 +24,7 @@ public function testMultiTenantPrimaryKey() : void self::assertTrue($foo->hasColumn('tenant_id')); } - public function testMultiTenantNonPrimaryKey() : void + public function testMultiTenantNonPrimaryKey(): void { $platform = new SQLAzurePlatform(); $visitor = new MultiTenantVisitor(); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php index 2185a9fc8d1..6996df162e6 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php @@ -6,7 +6,7 @@ class SQLAzureFederationsSynchronizerTest extends AbstractTestCase { - public function testCreateSchema() : void + public function testCreateSchema(): void { $schema = $this->createShopSchema(); @@ -23,7 +23,7 @@ public function testCreateSchema() : void ], $sql); } - public function testUpdateSchema() : void + public function testUpdateSchema(): void { $schema = $this->createShopSchema(); @@ -35,7 +35,7 @@ public function testUpdateSchema() : void self::assertEquals([], $sql); } - public function testDropSchema() : void + public function testDropSchema(): void { $schema = $this->createShopSchema(); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php index 242c7a0fe52..950ae251a6c 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php @@ -10,7 +10,7 @@ class SQLAzureShardManagerTest extends TestCase { - public function testNoFederationName() : void + public function testNoFederationName(): void { $this->expectException(ShardingException::class); $this->expectExceptionMessage('SQLAzure requires a federation name to be set during sharding configuration.'); @@ -19,7 +19,7 @@ public function testNoFederationName() : void new SQLAzureShardManager($conn); } - public function testNoDistributionKey() : void + public function testNoDistributionKey(): void { $this->expectException(ShardingException::class); $this->expectExceptionMessage('SQLAzure requires a distribution key to be set during sharding configuration.'); @@ -28,7 +28,7 @@ public function testNoDistributionKey() : void new SQLAzureShardManager($conn); } - public function testNoDistributionType() : void + public function testNoDistributionType(): void { $this->expectException(ShardingException::class); @@ -36,7 +36,7 @@ public function testNoDistributionType() : void new SQLAzureShardManager($conn); } - public function testGetDefaultDistributionValue() : void + public function testGetDefaultDistributionValue(): void { $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]); @@ -44,7 +44,7 @@ public function testGetDefaultDistributionValue() : void self::assertNull($sm->getCurrentDistributionValue()); } - public function testSelectGlobalTransactionActive() : void + public function testSelectGlobalTransactionActive(): void { $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]); $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(true)); @@ -56,7 +56,7 @@ public function testSelectGlobalTransactionActive() : void $sm->selectGlobal(); } - public function testSelectGlobal() : void + public function testSelectGlobal(): void { $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]); $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(false)); @@ -66,7 +66,7 @@ public function testSelectGlobal() : void $sm->selectGlobal(); } - public function testSelectShard() : void + public function testSelectShard(): void { $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]); $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(true)); @@ -85,7 +85,7 @@ public function testSelectShard() : void * * @return Connection&MockObject */ - private function createConnection(array $params) : Connection + private function createConnection(array $params): Connection { $conn = $this->getMockBuilder(Connection::class) ->onlyMethods(['getParams', 'exec', 'isTransactionActive']) diff --git a/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php b/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php index 5b65deecc77..ea509cb98f4 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php @@ -8,7 +8,7 @@ class MultiTenantShardChoserTest extends TestCase { - public function testPickShard() : void + public function testPickShard(): void { $choser = new MultiTenantShardChoser(); $conn = $this->createConnectionMock(); @@ -17,7 +17,7 @@ public function testPickShard() : void self::assertEquals(2, $choser->pickShard(2, $conn)); } - private function createConnectionMock() : PoolingShardConnection + private function createConnectionMock(): PoolingShardConnection { return $this->getMockBuilder(PoolingShardConnection::class) ->onlyMethods(['connect', 'getParams', 'fetchAll']) diff --git a/tests/Doctrine/Tests/DBAL/StatementTest.php b/tests/Doctrine/Tests/DBAL/StatementTest.php index 728cc5ab58a..69cae985148 100644 --- a/tests/Doctrine/Tests/DBAL/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/StatementTest.php @@ -27,7 +27,7 @@ class StatementTest extends DbalTestCase /** @var PDOStatement&MockObject */ private $pdoStatement; - protected function setUp() : void + protected function setUp(): void { $this->pdoStatement = $this->getMockBuilder(PDOStatement::class) ->onlyMethods(['execute', 'bindParam', 'bindValue', 'fetchAll']) @@ -57,7 +57,7 @@ protected function setUp() : void ->will($this->returnValue($driver)); } - public function testExecuteCallsLoggerStartQueryWithParametersWhenValuesBound() : void + public function testExecuteCallsLoggerStartQueryWithParametersWhenValuesBound(): void { $name = 'foo'; $var = 'bar'; @@ -80,7 +80,7 @@ public function testExecuteCallsLoggerStartQueryWithParametersWhenValuesBound() $statement->execute(); } - public function testExecuteCallsLoggerStartQueryWithParametersWhenParamsPassedToExecute() : void + public function testExecuteCallsLoggerStartQueryWithParametersWhenParamsPassedToExecute(): void { $name = 'foo'; $var = 'bar'; @@ -101,7 +101,7 @@ public function testExecuteCallsLoggerStartQueryWithParametersWhenParamsPassedTo $statement->execute($values); } - public function testExecuteCallsStartQueryWithTheParametersBoundViaBindParam() : void + public function testExecuteCallsStartQueryWithTheParametersBoundViaBindParam(): void { $name = 'foo'; $var = 'bar'; @@ -123,7 +123,7 @@ public function testExecuteCallsStartQueryWithTheParametersBoundViaBindParam() : $statement->execute(); } - public function testExecuteCallsLoggerStopQueryOnException() : void + public function testExecuteCallsLoggerStopQueryOnException(): void { $logger = $this->createMock(SQLLogger::class); @@ -153,7 +153,7 @@ public function testExecuteCallsLoggerStopQueryOnException() : void $statement->execute(); } - public function testPDOCustomClassConstructorArgs() : void + public function testPDOCustomClassConstructorArgs(): void { $statement = new Statement('', $this->conn); diff --git a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php index b55059ab715..38da4465441 100644 --- a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php +++ b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php @@ -22,7 +22,7 @@ class RunSqlCommandTest extends TestCase /** @var Connection&MockObject */ private $connectionMock; - protected function setUp() : void + protected function setUp(): void { $application = new Application(); $application->add(new RunSqlCommand()); @@ -40,7 +40,7 @@ protected function setUp() : void $this->command->setHelperSet($helperSet); } - public function testMissingSqlArgument() : void + public function testMissingSqlArgument(): void { try { $this->commandTester->execute([ @@ -53,7 +53,7 @@ public function testMissingSqlArgument() : void } } - public function testIncorrectDepthOption() : void + public function testIncorrectDepthOption(): void { try { $this->commandTester->execute([ @@ -67,7 +67,7 @@ public function testIncorrectDepthOption() : void } } - public function testSelectStatementsPrintsResult() : void + public function testSelectStatementsPrintsResult(): void { $this->expectConnectionFetchAll(); @@ -81,7 +81,7 @@ public function testSelectStatementsPrintsResult() : void self::assertRegExp('@array.*1.*@', $this->commandTester->getDisplay()); } - public function testUpdateStatementsPrintsAffectedLines() : void + public function testUpdateStatementsPrintsAffectedLines(): void { $this->expectConnectionExecuteUpdate(); @@ -94,7 +94,7 @@ public function testUpdateStatementsPrintsAffectedLines() : void self::assertNotRegExp('@array.*1.*@', $this->commandTester->getDisplay()); } - private function expectConnectionExecuteUpdate() : void + private function expectConnectionExecuteUpdate(): void { $this->connectionMock ->expects($this->exactly(1)) @@ -104,7 +104,7 @@ private function expectConnectionExecuteUpdate() : void ->method('fetchAll'); } - private function expectConnectionFetchAll() : void + private function expectConnectionFetchAll(): void { $this->connectionMock ->expects($this->exactly(0)) @@ -114,7 +114,7 @@ private function expectConnectionFetchAll() : void ->method('fetchAll'); } - public function testStatementsWithFetchResultPrintsResult() : void + public function testStatementsWithFetchResultPrintsResult(): void { $this->expectConnectionFetchAll(); diff --git a/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php b/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php index ba99024231b..47d9e5ff12b 100644 --- a/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php +++ b/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php @@ -10,13 +10,14 @@ use Doctrine\DBAL\Tools\Dumper; use Doctrine\Tests\DbalTestCase; use stdClass; + use function print_r; use function strpos; use function substr; class DumperTest extends DbalTestCase { - public function testExportObject() : void + public function testExportObject(): void { $obj = new stdClass(); $obj->foo = 'bar'; @@ -26,7 +27,7 @@ public function testExportObject() : void self::assertEquals('stdClass', $var->__CLASS__); } - public function testExportObjectWithReference() : void + public function testExportObjectWithReference(): void { $foo = 'bar'; $bar = ['foo' => & $foo]; @@ -39,7 +40,7 @@ public function testExportObjectWithReference() : void self::assertEquals('tab', $bar['foo']); } - public function testExportArray() : void + public function testExportArray(): void { $array = ['a' => 'b', 'b' => ['c', 'd' => ['e', 'f']]]; $var = Dumper::export($array, 2); @@ -48,7 +49,7 @@ public function testExportArray() : void self::assertEquals($expected, $var); } - public function testExportDateTime() : void + public function testExportDateTime(): void { $obj = new DateTime('2010-10-10 10:10:10', new DateTimeZone('UTC')); @@ -57,7 +58,7 @@ public function testExportDateTime() : void self::assertEquals('2010-10-10T10:10:10+00:00', $var->date); } - public function testExportDateTimeImmutable() : void + public function testExportDateTimeImmutable(): void { $obj = new DateTimeImmutable('2010-10-10 10:10:10', new DateTimeZone('UTC')); @@ -66,7 +67,7 @@ public function testExportDateTimeImmutable() : void self::assertEquals('2010-10-10T10:10:10+00:00', $var->date); } - public function testExportDateTimeZone() : void + public function testExportDateTimeZone(): void { $obj = new DateTimeImmutable('2010-10-10 12:34:56', new DateTimeZone('Europe/Rome')); @@ -75,7 +76,7 @@ public function testExportDateTimeZone() : void self::assertEquals('2010-10-10T12:34:56+02:00', $var->date); } - public function testExportArrayTraversable() : void + public function testExportArrayTraversable(): void { $obj = new ArrayObject(['foobar']); @@ -93,7 +94,7 @@ public function testExportArrayTraversable() : void * * @dataProvider provideAttributesCases */ - public function testExportParentAttributes(TestAsset\ParentClass $class, array $expected) : void + public function testExportParentAttributes(TestAsset\ParentClass $class, array $expected): void { $print_r_class = print_r($class, true); $print_r_expected = print_r($expected, true); @@ -113,7 +114,7 @@ public function testExportParentAttributes(TestAsset\ParentClass $class, array $ /** * @return mixed[][] */ - public static function provideAttributesCases() : iterable + public static function provideAttributesCases(): iterable { return [ 'different-attributes' => [ diff --git a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php index bc6ab4d413f..00912413f5c 100644 --- a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function serialize; class ArrayTest extends DbalTestCase @@ -18,30 +19,30 @@ class ArrayTest extends DbalTestCase /** @var ArrayType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('array'); } - public function testArrayConvertsToDatabaseValue() : void + public function testArrayConvertsToDatabaseValue(): void { self::assertIsString($this->type->convertToDatabaseValue([], $this->platform)); } - public function testArrayConvertsToPHPValue() : void + public function testArrayConvertsToPHPValue(): void { self::assertIsArray($this->type->convertToPHPValue(serialize([]), $this->platform)); } - public function testConversionFailure() : void + public function testConversionFailure(): void { $this->expectException(ConversionException::class); $this->expectExceptionMessage("Could not convert database value to 'array' as an error was triggered by the unserialization: 'unserialize(): Error at offset 0 of 7 bytes'"); $this->type->convertToPHPValue('abcdefg', $this->platform); } - public function testNullConversion() : void + public function testNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } @@ -49,7 +50,7 @@ public function testNullConversion() : void /** * @group DBAL-73 */ - public function testFalseConversion() : void + public function testFalseConversion(): void { self::assertFalse($this->type->convertToPHPValue(serialize(false), $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php index 062c77781f1..e033cd0f36b 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php @@ -10,6 +10,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use stdClass; + use function date_default_timezone_get; use function date_default_timezone_set; @@ -24,7 +25,7 @@ abstract class BaseDateTypeTestCase extends TestCase /** @var string */ private $currentTimezone; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->getMockForAbstractClass(AbstractPlatform::class); $this->currentTimezone = date_default_timezone_get(); @@ -32,12 +33,12 @@ protected function setUp() : void self::assertInstanceOf(Type::class, $this->type); } - protected function tearDown() : void + protected function tearDown(): void { date_default_timezone_set($this->currentTimezone); } - public function testDateConvertsToDatabaseValue() : void + public function testDateConvertsToDatabaseValue(): void { self::assertIsString($this->type->convertToDatabaseValue(new DateTime(), $this->platform)); } @@ -47,19 +48,19 @@ public function testDateConvertsToDatabaseValue() : void * * @dataProvider invalidPHPValuesProvider */ - public function testInvalidTypeConversionToDatabaseValue($value) : void + public function testInvalidTypeConversionToDatabaseValue($value): void { $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue($value, $this->platform); } - public function testNullConversion() : void + public function testNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertDateTimeToPHPValue() : void + public function testConvertDateTimeToPHPValue(): void { $date = new DateTime('now'); @@ -73,7 +74,7 @@ public function testConvertDateTimeToPHPValue() : void * by @see \Doctrine\DBAL\Types\DateTimeImmutableType, previous DBAL versions handled it just fine. * This test is just in place to prevent further regressions, even if the type is being misused */ - public function testConvertDateTimeImmutableToPHPValue() : void + public function testConvertDateTimeImmutableToPHPValue(): void { $date = new DateTimeImmutable('now'); @@ -87,7 +88,7 @@ public function testConvertDateTimeImmutableToPHPValue() : void * by @see \Doctrine\DBAL\Types\DateTimeImmutableType, previous DBAL versions handled it just fine. * This test is just in place to prevent further regressions, even if the type is being misused */ - public function testDateTimeImmutableConvertsToDatabaseValue() : void + public function testDateTimeImmutableConvertsToDatabaseValue(): void { self::assertIsString($this->type->convertToDatabaseValue(new DateTimeImmutable(), $this->platform)); } @@ -95,7 +96,7 @@ public function testDateTimeImmutableConvertsToDatabaseValue() : void /** * @return mixed[][] */ - public static function invalidPHPValuesProvider() : iterable + public static function invalidPHPValuesProvider(): iterable { return [ [0], diff --git a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php index d71512f3c01..23514f6160b 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Types\Types; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function base64_encode; use function fopen; use function stream_get_contents; @@ -22,23 +23,23 @@ class BinaryTest extends DbalTestCase /** @var BinaryType */ protected $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('binary'); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::BINARY, $this->type->getBindingType()); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame(Types::BINARY, $this->type->getName()); } - public function testReturnsSQLDeclaration() : void + public function testReturnsSQLDeclaration(): void { $this->platform->expects($this->once()) ->method('getBinaryTypeDeclarationSQL') @@ -47,12 +48,12 @@ public function testReturnsSQLDeclaration() : void self::assertSame('TEST_BINARY', $this->type->getSQLDeclaration([], $this->platform)); } - public function testBinaryNullConvertsToPHPValue() : void + public function testBinaryNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testBinaryStringConvertsToPHPValue() : void + public function testBinaryStringConvertsToPHPValue(): void { $databaseValue = 'binary string'; $phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform); @@ -61,7 +62,7 @@ public function testBinaryStringConvertsToPHPValue() : void self::assertEquals($databaseValue, stream_get_contents($phpValue)); } - public function testBinaryResourceConvertsToPHPValue() : void + public function testBinaryResourceConvertsToPHPValue(): void { $databaseValue = fopen('data://text/plain;base64,' . base64_encode('binary string'), 'r'); $phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform); @@ -74,7 +75,7 @@ public function testBinaryResourceConvertsToPHPValue() : void * * @dataProvider getInvalidDatabaseValues */ - public function testThrowsConversionExceptionOnInvalidDatabaseValue($value) : void + public function testThrowsConversionExceptionOnInvalidDatabaseValue($value): void { $this->expectException(ConversionException::class); @@ -84,7 +85,7 @@ public function testThrowsConversionExceptionOnInvalidDatabaseValue($value) : vo /** * @return mixed[][] */ - public static function getInvalidDatabaseValues() : iterable + public static function getInvalidDatabaseValues(): iterable { return [ [false], diff --git a/tests/Doctrine/Tests/DBAL/Types/BlobTest.php b/tests/Doctrine/Tests/DBAL/Types/BlobTest.php index d1a10a60bfa..23486819798 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BlobTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BlobTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function base64_encode; use function chr; use function fopen; @@ -20,18 +21,18 @@ class BlobTest extends DbalTestCase /** @var BlobType */ protected $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('blob'); } - public function testBlobNullConvertsToPHPValue() : void + public function testBlobNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testBinaryStringConvertsToPHPValue() : void + public function testBinaryStringConvertsToPHPValue(): void { $databaseValue = $this->getBinaryString(); $phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform); @@ -40,7 +41,7 @@ public function testBinaryStringConvertsToPHPValue() : void self::assertSame($databaseValue, stream_get_contents($phpValue)); } - public function testBinaryResourceConvertsToPHPValue() : void + public function testBinaryResourceConvertsToPHPValue(): void { $databaseValue = fopen('data://text/plain;base64,' . base64_encode($this->getBinaryString()), 'r'); $phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform); @@ -51,7 +52,7 @@ public function testBinaryResourceConvertsToPHPValue() : void /** * Creates a binary string containing all possible byte values. */ - private function getBinaryString() : string + private function getBinaryString(): string { $string = ''; diff --git a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php index b5e25c2a77b..0fe4a2d5a5e 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php @@ -16,23 +16,23 @@ class BooleanTest extends DbalTestCase /** @var BooleanType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->getMockForAbstractClass(AbstractPlatform::class); $this->type = Type::getType('boolean'); } - public function testBooleanConvertsToDatabaseValue() : void + public function testBooleanConvertsToDatabaseValue(): void { self::assertIsInt($this->type->convertToDatabaseValue(1, $this->platform)); } - public function testBooleanConvertsToPHPValue() : void + public function testBooleanConvertsToPHPValue(): void { self::assertIsBool($this->type->convertToPHPValue(0, $this->platform)); } - public function testBooleanNullConvertsToPHPValue() : void + public function testBooleanNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php b/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php index f8003c5c617..f2997ec5a92 100644 --- a/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php @@ -6,11 +6,12 @@ use PHPUnit\Framework\TestCase; use stdClass; use Throwable; + use function tmpfile; class ConversionExceptionTest extends TestCase { - public function testConversionFailedPreviousException() : void + public function testConversionFailedPreviousException(): void { $previous = $this->createMock(Throwable::class); @@ -25,7 +26,7 @@ public function testConversionFailedPreviousException() : void * * @dataProvider scalarsProvider */ - public function testConversionFailedInvalidTypeWithScalar($scalarValue) : void + public function testConversionFailedInvalidTypeWithScalar($scalarValue): void { $exception = ConversionException::conversionFailedInvalidType($scalarValue, 'foo', ['bar', 'baz']); @@ -42,7 +43,7 @@ public function testConversionFailedInvalidTypeWithScalar($scalarValue) : void * * @dataProvider nonScalarsProvider */ - public function testConversionFailedInvalidTypeWithNonScalar($nonScalar) : void + public function testConversionFailedInvalidTypeWithNonScalar($nonScalar): void { $exception = ConversionException::conversionFailedInvalidType($nonScalar, 'foo', ['bar', 'baz']); @@ -54,7 +55,7 @@ public function testConversionFailedInvalidTypeWithNonScalar($nonScalar) : void ); } - public function testConversionFailedInvalidTypePreviousException() : void + public function testConversionFailedInvalidTypePreviousException(): void { $previous = $this->createMock(Throwable::class); @@ -64,7 +65,7 @@ public function testConversionFailedInvalidTypePreviousException() : void self::assertSame($previous, $exception->getPrevious()); } - public function testConversionFailedFormatPreservesPreviousException() : void + public function testConversionFailedFormatPreservesPreviousException(): void { $previous = $this->createMock(Throwable::class); @@ -77,7 +78,7 @@ public function testConversionFailedFormatPreservesPreviousException() : void /** * @return mixed[][] */ - public static function nonScalarsProvider() : iterable + public static function nonScalarsProvider(): iterable { return [ [[]], @@ -91,7 +92,7 @@ public static function nonScalarsProvider() : iterable /** * @return mixed[][] */ - public static function scalarsProvider() : iterable + public static function scalarsProvider(): iterable { return [ [''], diff --git a/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php index d023e6bc1ba..e06e9b02f11 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function get_class; class DateImmutableTypeTest extends TestCase @@ -21,28 +22,28 @@ class DateImmutableTypeTest extends TestCase /** @var DateImmutableType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('date_immutable'); $this->platform = $this->createMock(AbstractPlatform::class); } - public function testFactoryCreatesCorrectType() : void + public function testFactoryCreatesCorrectType(): void { self::assertSame(DateImmutableType::class, get_class($this->type)); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('date_immutable', $this->type->getName()); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void + public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void { $date = $this->createMock(DateTimeImmutable::class); @@ -60,31 +61,31 @@ public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void ); } - public function testConvertsNullToDatabaseValue() : void + public function testConvertsNullToDatabaseValue(): void { self::assertNull($this->type->convertToDatabaseValue(null, $this->platform)); } - public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion() : void + public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue(new DateTime(), $this->platform); } - public function testConvertsDateTimeImmutableInstanceToPHPValue() : void + public function testConvertsDateTimeImmutableInstanceToPHPValue(): void { $date = new DateTimeImmutable(); self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform)); } - public function testConvertsNullToPHPValue() : void + public function testConvertsNullToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertsDateStringToPHPValue() : void + public function testConvertsDateStringToPHPValue(): void { $this->platform->expects($this->once()) ->method('getDateFormatString') @@ -96,7 +97,7 @@ public function testConvertsDateStringToPHPValue() : void self::assertSame('2016-01-01', $date->format('Y-m-d')); } - public function testResetTimeFractionsWhenConvertingToPHPValue() : void + public function testResetTimeFractionsWhenConvertingToPHPValue(): void { $this->platform->expects($this->any()) ->method('getDateFormatString') @@ -107,14 +108,14 @@ public function testResetTimeFractionsWhenConvertingToPHPValue() : void self::assertSame('2016-01-01 00:00:00.000000', $date->format('Y-m-d H:i:s.u')); } - public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateString() : void + public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateString(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('invalid date string', $this->platform); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php b/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php index 15ee937e7d2..fa98a4f6eab 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php @@ -20,7 +20,7 @@ final class DateIntervalTest extends DbalTestCase /** @var DateIntervalType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('dateinterval'); @@ -28,7 +28,7 @@ protected function setUp() : void self::assertInstanceOf(DateIntervalType::class, $this->type); } - public function testDateIntervalConvertsToDatabaseValue() : void + public function testDateIntervalConvertsToDatabaseValue(): void { $interval = new DateInterval('P2Y1DT1H2M3S'); @@ -38,7 +38,7 @@ public function testDateIntervalConvertsToDatabaseValue() : void self::assertEquals($expected, $actual); } - public function testDateIntervalConvertsToPHPValue() : void + public function testDateIntervalConvertsToPHPValue(): void { $interval = $this->type->convertToPHPValue('+P02Y00M01DT01H02M03S', $this->platform); @@ -46,7 +46,7 @@ public function testDateIntervalConvertsToPHPValue() : void self::assertEquals('+P02Y00M01DT01H02M03S', $interval->format(DateIntervalType::FORMAT)); } - public function testNegativeDateIntervalConvertsToDatabaseValue() : void + public function testNegativeDateIntervalConvertsToDatabaseValue(): void { $interval = new DateInterval('P2Y1DT1H2M3S'); $interval->invert = 1; @@ -56,7 +56,7 @@ public function testNegativeDateIntervalConvertsToDatabaseValue() : void self::assertEquals('-P02Y00M01DT01H02M03S', $actual); } - public function testNegativeDateIntervalConvertsToPHPValue() : void + public function testNegativeDateIntervalConvertsToPHPValue(): void { $interval = $this->type->convertToPHPValue('-P02Y00M01DT01H02M03S', $this->platform); @@ -64,7 +64,7 @@ public function testNegativeDateIntervalConvertsToPHPValue() : void self::assertEquals('-P02Y00M01DT01H02M03S', $interval->format(DateIntervalType::FORMAT)); } - public function testDateIntervalFormatWithoutSignConvertsToPHPValue() : void + public function testDateIntervalFormatWithoutSignConvertsToPHPValue(): void { $interval = $this->type->convertToPHPValue('P02Y00M01DT01H02M03S', $this->platform); @@ -72,19 +72,19 @@ public function testDateIntervalFormatWithoutSignConvertsToPHPValue() : void self::assertEquals('+P02Y00M01DT01H02M03S', $interval->format(DateIntervalType::FORMAT)); } - public function testInvalidDateIntervalFormatConversion() : void + public function testInvalidDateIntervalFormatConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('abcdefg', $this->platform); } - public function testDateIntervalNullConversion() : void + public function testDateIntervalNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testDateIntervalEmptyStringConversion() : void + public function testDateIntervalEmptyStringConversion(): void { $this->expectException(ConversionException::class); @@ -94,7 +94,7 @@ public function testDateIntervalEmptyStringConversion() : void /** * @group DBAL-1288 */ - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } @@ -104,7 +104,7 @@ public function testRequiresSQLCommentHint() : void * * @dataProvider invalidPHPValuesProvider */ - public function testInvalidTypeConversionToDatabaseValue($value) : void + public function testInvalidTypeConversionToDatabaseValue($value): void { $this->expectException(ConversionException::class); @@ -114,7 +114,7 @@ public function testInvalidTypeConversionToDatabaseValue($value) : void /** * @return mixed[][] */ - public static function invalidPHPValuesProvider() : iterable + public static function invalidPHPValuesProvider(): iterable { return [ [0], diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTest.php index 4bc2cda4556..1d97cceaa2c 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTest.php @@ -5,18 +5,19 @@ use DateTime; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; + use function date_default_timezone_set; class DateTest extends BaseDateTypeTestCase { - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('date'); parent::setUp(); } - public function testDateConvertsToPHPValue() : void + public function testDateConvertsToPHPValue(): void { // Birthday of jwage and also birthday of Doctrine. Send him a present ;) self::assertInstanceOf( @@ -25,14 +26,14 @@ public function testDateConvertsToPHPValue() : void ); } - public function testDateResetsNonDatePartsToZeroUnixTimeValues() : void + public function testDateResetsNonDatePartsToZeroUnixTimeValues(): void { $date = $this->type->convertToPHPValue('1985-09-01', $this->platform); self::assertEquals('00:00:00', $date->format('H:i:s')); } - public function testDateRestsSummerTimeAffection() : void + public function testDateRestsSummerTimeAffection(): void { date_default_timezone_set('Europe/Berlin'); @@ -45,7 +46,7 @@ public function testDateRestsSummerTimeAffection() : void self::assertEquals('2009-11-01', $date->format('Y-m-d')); } - public function testInvalidDateFormatConversion() : void + public function testInvalidDateFormatConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('abcdefg', $this->platform); diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php index 6ace4b4c4e8..921d136d104 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function get_class; class DateTimeImmutableTypeTest extends TestCase @@ -21,28 +22,28 @@ class DateTimeImmutableTypeTest extends TestCase /** @var DateTimeImmutableType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('datetime_immutable'); $this->platform = $this->getMockBuilder(AbstractPlatform::class)->getMock(); } - public function testFactoryCreatesCorrectType() : void + public function testFactoryCreatesCorrectType(): void { self::assertSame(DateTimeImmutableType::class, get_class($this->type)); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('datetime_immutable', $this->type->getName()); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void + public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void { $date = $this->getMockBuilder(DateTimeImmutable::class)->getMock(); @@ -60,31 +61,31 @@ public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void ); } - public function testConvertsNullToDatabaseValue() : void + public function testConvertsNullToDatabaseValue(): void { self::assertNull($this->type->convertToDatabaseValue(null, $this->platform)); } - public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion() : void + public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue(new DateTime(), $this->platform); } - public function testConvertsDateTimeImmutableInstanceToPHPValue() : void + public function testConvertsDateTimeImmutableInstanceToPHPValue(): void { $date = new DateTimeImmutable(); self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform)); } - public function testConvertsNullToPHPValue() : void + public function testConvertsNullToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertsDateTimeStringToPHPValue() : void + public function testConvertsDateTimeStringToPHPValue(): void { $this->platform->expects($this->once()) ->method('getDateTimeFormatString') @@ -99,7 +100,7 @@ public function testConvertsDateTimeStringToPHPValue() : void /** * @group DBAL-415 */ - public function testConvertsDateTimeStringWithMicrosecondsToPHPValue() : void + public function testConvertsDateTimeStringWithMicrosecondsToPHPValue(): void { $this->platform->expects($this->any()) ->method('getDateTimeFormatString') @@ -110,7 +111,7 @@ public function testConvertsDateTimeStringWithMicrosecondsToPHPValue() : void self::assertSame('2016-01-01 15:58:59', $date->format('Y-m-d H:i:s')); } - public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateTimeString() : void + public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateTimeString(): void { $this->platform->expects($this->atLeastOnce()) ->method('getDateTimeFormatString') @@ -121,7 +122,7 @@ public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateTime $this->type->convertToPHPValue('invalid datetime string', $this->platform); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php index 9d43cd9d7b3..72868f328a8 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php @@ -8,14 +8,14 @@ class DateTimeTest extends BaseDateTypeTestCase { - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('datetime'); parent::setUp(); } - public function testDateTimeConvertsToDatabaseValue() : void + public function testDateTimeConvertsToDatabaseValue(): void { $date = new DateTime('1985-09-01 10:10:10'); @@ -25,7 +25,7 @@ public function testDateTimeConvertsToDatabaseValue() : void self::assertEquals($expected, $actual); } - public function testDateTimeConvertsToPHPValue() : void + public function testDateTimeConvertsToPHPValue(): void { // Birthday of jwage and also birthday of Doctrine. Send him a present ;) $date = $this->type->convertToPHPValue('1985-09-01 00:00:00', $this->platform); @@ -33,13 +33,13 @@ public function testDateTimeConvertsToPHPValue() : void self::assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); } - public function testInvalidDateTimeFormatConversion() : void + public function testInvalidDateTimeFormatConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('abcdefg', $this->platform); } - public function testConvertsNonMatchingFormatToPhpValueWithParser() : void + public function testConvertsNonMatchingFormatToPhpValueWithParser(): void { $date = '1985/09/01 10:10:10.12345'; diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php index 808dfaf50ed..eafaedcb729 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function get_class; class DateTimeTzImmutableTypeTest extends TestCase @@ -21,28 +22,28 @@ class DateTimeTzImmutableTypeTest extends TestCase /** @var DateTimeTzImmutableType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('datetimetz_immutable'); $this->platform = $this->createMock(AbstractPlatform::class); } - public function testFactoryCreatesCorrectType() : void + public function testFactoryCreatesCorrectType(): void { self::assertSame(DateTimeTzImmutableType::class, get_class($this->type)); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('datetimetz_immutable', $this->type->getName()); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void + public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void { $date = $this->createMock(DateTimeImmutable::class); @@ -60,31 +61,31 @@ public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void ); } - public function testConvertsNullToDatabaseValue() : void + public function testConvertsNullToDatabaseValue(): void { self::assertNull($this->type->convertToDatabaseValue(null, $this->platform)); } - public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion() : void + public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue(new DateTime(), $this->platform); } - public function testConvertsDateTimeImmutableInstanceToPHPValue() : void + public function testConvertsDateTimeImmutableInstanceToPHPValue(): void { $date = new DateTimeImmutable(); self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform)); } - public function testConvertsNullToPHPValue() : void + public function testConvertsNullToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertsDateTimeWithTimezoneStringToPHPValue() : void + public function testConvertsDateTimeWithTimezoneStringToPHPValue(): void { $this->platform->expects($this->once()) ->method('getDateTimeTzFormatString') @@ -96,7 +97,7 @@ public function testConvertsDateTimeWithTimezoneStringToPHPValue() : void self::assertSame('2016-01-01 15:58:59 UTC', $date->format('Y-m-d H:i:s T')); } - public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateTimeWithTimezoneString() : void + public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateTimeWithTimezoneString(): void { $this->platform->expects($this->atLeastOnce()) ->method('getDateTimeTzFormatString') @@ -107,7 +108,7 @@ public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateTime $this->type->convertToPHPValue('invalid datetime with timezone string', $this->platform); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php index adb75744d6e..f7367f283ec 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php @@ -8,14 +8,14 @@ class DateTimeTzTest extends BaseDateTypeTestCase { - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('datetimetz'); parent::setUp(); } - public function testDateTimeConvertsToDatabaseValue() : void + public function testDateTimeConvertsToDatabaseValue(): void { $date = new DateTime('1985-09-01 10:10:10'); @@ -25,7 +25,7 @@ public function testDateTimeConvertsToDatabaseValue() : void self::assertEquals($expected, $actual); } - public function testDateTimeConvertsToPHPValue() : void + public function testDateTimeConvertsToPHPValue(): void { // Birthday of jwage and also birthday of Doctrine. Send him a present ;) $date = $this->type->convertToPHPValue('1985-09-01 00:00:00', $this->platform); @@ -33,7 +33,7 @@ public function testDateTimeConvertsToPHPValue() : void self::assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); } - public function testInvalidDateFormatConversion() : void + public function testInvalidDateFormatConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('abcdefg', $this->platform); diff --git a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php b/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php index 1528dfd86d9..bf05598ab32 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php @@ -16,18 +16,18 @@ class DecimalTest extends DbalTestCase /** @var DecimalType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('decimal'); } - public function testDecimalConvertsToPHPValue() : void + public function testDecimalConvertsToPHPValue(): void { self::assertIsString($this->type->convertToPHPValue('5.5', $this->platform)); } - public function testDecimalNullConvertsToPHPValue() : void + public function testDecimalNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/FloatTest.php b/tests/Doctrine/Tests/DBAL/Types/FloatTest.php index 4934f716c0f..44623c28b90 100644 --- a/tests/Doctrine/Tests/DBAL/Types/FloatTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/FloatTest.php @@ -16,28 +16,28 @@ class FloatTest extends DbalTestCase /** @var FloatType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('float'); } - public function testFloatConvertsToPHPValue() : void + public function testFloatConvertsToPHPValue(): void { self::assertIsFloat($this->type->convertToPHPValue('5.5', $this->platform)); } - public function testFloatNullConvertsToPHPValue() : void + public function testFloatNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testFloatConvertToDatabaseValue() : void + public function testFloatConvertToDatabaseValue(): void { self::assertIsFloat($this->type->convertToDatabaseValue(5.5, $this->platform)); } - public function testFloatNullConvertToDatabaseValue() : void + public function testFloatNullConvertToDatabaseValue(): void { self::assertNull($this->type->convertToDatabaseValue(null, $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php index df265d8541a..3615b687bd9 100644 --- a/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php @@ -16,24 +16,24 @@ class GuidTypeTest extends DbalTestCase /** @var GuidType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('guid'); } - public function testConvertToPHPValue() : void + public function testConvertToPHPValue(): void { self::assertIsString($this->type->convertToPHPValue('foo', $this->platform)); self::assertIsString($this->type->convertToPHPValue('', $this->platform)); } - public function testNullConversion() : void + public function testNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testNativeGuidSupport() : void + public function testNativeGuidSupport(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); diff --git a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php b/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php index e4ac718c4ea..7241a9237e1 100644 --- a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php @@ -16,19 +16,19 @@ class IntegerTest extends DbalTestCase /** @var IntegerType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('integer'); } - public function testIntegerConvertsToPHPValue() : void + public function testIntegerConvertsToPHPValue(): void { self::assertIsInt($this->type->convertToPHPValue('1', $this->platform)); self::assertIsInt($this->type->convertToPHPValue('0', $this->platform)); } - public function testIntegerNullConvertsToPHPValue() : void + public function testIntegerNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php index 92cb6b6e17f..4603f3d6206 100644 --- a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Types\Types; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function base64_encode; use function fopen; use function json_encode; @@ -21,23 +22,23 @@ class JsonArrayTest extends DbalTestCase /** @var JsonArrayType */ protected $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('json_array'); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame(Types::JSON_ARRAY, $this->type->getName()); } - public function testReturnsSQLDeclaration() : void + public function testReturnsSQLDeclaration(): void { $this->platform->expects($this->once()) ->method('getJsonTypeDeclarationSQL') @@ -46,17 +47,17 @@ public function testReturnsSQLDeclaration() : void self::assertSame('TEST_JSON', $this->type->getSQLDeclaration([], $this->platform)); } - public function testJsonNullConvertsToPHPValue() : void + public function testJsonNullConvertsToPHPValue(): void { self::assertSame([], $this->type->convertToPHPValue(null, $this->platform)); } - public function testJsonEmptyStringConvertsToPHPValue() : void + public function testJsonEmptyStringConvertsToPHPValue(): void { self::assertSame([], $this->type->convertToPHPValue('', $this->platform)); } - public function testJsonStringConvertsToPHPValue() : void + public function testJsonStringConvertsToPHPValue(): void { $value = ['foo' => 'bar', 'bar' => 'foo']; $databaseValue = json_encode($value); @@ -65,7 +66,7 @@ public function testJsonStringConvertsToPHPValue() : void self::assertEquals($value, $phpValue); } - public function testJsonResourceConvertsToPHPValue() : void + public function testJsonResourceConvertsToPHPValue(): void { $value = ['foo' => 'bar', 'bar' => 'foo']; $databaseValue = fopen('data://text/plain;base64,' . base64_encode(json_encode($value)), 'r'); @@ -74,7 +75,7 @@ public function testJsonResourceConvertsToPHPValue() : void self::assertSame($value, $phpValue); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php index 034cc0361bb..0cf41b7f867 100644 --- a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Types\Types; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function base64_encode; use function fopen; use function json_encode; @@ -22,23 +23,23 @@ class JsonTest extends DbalTestCase /** @var JsonType */ protected $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('json'); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame(Types::JSON, $this->type->getName()); } - public function testReturnsSQLDeclaration() : void + public function testReturnsSQLDeclaration(): void { $this->platform->expects($this->once()) ->method('getJsonTypeDeclarationSQL') @@ -47,17 +48,17 @@ public function testReturnsSQLDeclaration() : void self::assertSame('TEST_JSON', $this->type->getSQLDeclaration([], $this->platform)); } - public function testJsonNullConvertsToPHPValue() : void + public function testJsonNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testJsonEmptyStringConvertsToPHPValue() : void + public function testJsonEmptyStringConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue('', $this->platform)); } - public function testJsonStringConvertsToPHPValue() : void + public function testJsonStringConvertsToPHPValue(): void { $value = ['foo' => 'bar', 'bar' => 'foo']; $databaseValue = json_encode($value); @@ -67,7 +68,7 @@ public function testJsonStringConvertsToPHPValue() : void } /** @dataProvider providerFailure */ - public function testConversionFailure(string $data) : void + public function testConversionFailure(string $data): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue($data, $this->platform); @@ -76,12 +77,12 @@ public function testConversionFailure(string $data) : void /** * @return mixed[][] */ - public static function providerFailure() : iterable + public static function providerFailure(): iterable { return [['a'], ['{']]; } - public function testJsonResourceConvertsToPHPValue() : void + public function testJsonResourceConvertsToPHPValue(): void { $value = ['foo' => 'bar', 'bar' => 'foo']; $databaseValue = fopen('data://text/plain;base64,' . base64_encode(json_encode($value)), 'r'); @@ -90,7 +91,7 @@ public function testJsonResourceConvertsToPHPValue() : void self::assertSame($value, $phpValue); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php index da9481d105a..df69e965d6b 100644 --- a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php @@ -9,6 +9,7 @@ use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; use stdClass; + use function serialize; class ObjectTest extends DbalTestCase @@ -19,30 +20,30 @@ class ObjectTest extends DbalTestCase /** @var ObjectType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('object'); } - public function testObjectConvertsToDatabaseValue() : void + public function testObjectConvertsToDatabaseValue(): void { self::assertIsString($this->type->convertToDatabaseValue(new stdClass(), $this->platform)); } - public function testObjectConvertsToPHPValue() : void + public function testObjectConvertsToPHPValue(): void { self::assertIsObject($this->type->convertToPHPValue(serialize(new stdClass()), $this->platform)); } - public function testConversionFailure() : void + public function testConversionFailure(): void { $this->expectException(ConversionException::class); $this->expectExceptionMessage("Could not convert database value to 'object' as an error was triggered by the unserialization: 'unserialize(): Error at offset 0 of 7 bytes'"); $this->type->convertToPHPValue('abcdefg', $this->platform); } - public function testNullConversion() : void + public function testNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } @@ -50,7 +51,7 @@ public function testNullConversion() : void /** * @group DBAL-73 */ - public function testFalseConversion() : void + public function testFalseConversion(): void { self::assertFalse($this->type->convertToPHPValue(serialize(false), $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php b/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php index b1731a99578..31ed1a310dd 100644 --- a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php @@ -16,19 +16,19 @@ class SmallIntTest extends DbalTestCase /** @var SmallIntType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('smallint'); } - public function testSmallIntConvertsToPHPValue() : void + public function testSmallIntConvertsToPHPValue(): void { self::assertIsInt($this->type->convertToPHPValue('1', $this->platform)); self::assertIsInt($this->type->convertToPHPValue('0', $this->platform)); } - public function testSmallIntNullConvertsToPHPValue() : void + public function testSmallIntNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/StringTest.php b/tests/Doctrine/Tests/DBAL/Types/StringTest.php index 4548ff60943..a5175f52f19 100644 --- a/tests/Doctrine/Tests/DBAL/Types/StringTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/StringTest.php @@ -16,13 +16,13 @@ class StringTest extends DbalTestCase /** @var StringType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('string'); } - public function testReturnsSqlDeclarationFromPlatformVarchar() : void + public function testReturnsSqlDeclarationFromPlatformVarchar(): void { $this->platform->expects($this->once()) ->method('getVarcharTypeDeclarationSQL') @@ -31,7 +31,7 @@ public function testReturnsSqlDeclarationFromPlatformVarchar() : void self::assertEquals('TEST_VARCHAR', $this->type->getSqlDeclaration([], $this->platform)); } - public function testReturnsDefaultLengthFromPlatformVarchar() : void + public function testReturnsDefaultLengthFromPlatformVarchar(): void { $this->platform->expects($this->once()) ->method('getVarcharDefaultLength') @@ -40,18 +40,18 @@ public function testReturnsDefaultLengthFromPlatformVarchar() : void self::assertEquals(255, $this->type->getDefaultLength($this->platform)); } - public function testConvertToPHPValue() : void + public function testConvertToPHPValue(): void { self::assertIsString($this->type->convertToPHPValue('foo', $this->platform)); self::assertIsString($this->type->convertToPHPValue('', $this->platform)); } - public function testNullConversion() : void + public function testNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testSQLConversion() : void + public function testSQLConversion(): void { self::assertFalse($this->type->canRequireSQLConversion(), 'String type can never require SQL conversion to work.'); self::assertEquals('t.foo', $this->type->convertToDatabaseValueSQL('t.foo', $this->platform)); diff --git a/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php index ba087f19f40..c9518fe6dbf 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function get_class; class TimeImmutableTypeTest extends TestCase @@ -21,28 +22,28 @@ class TimeImmutableTypeTest extends TestCase /** @var TimeImmutableType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('time_immutable'); $this->platform = $this->getMockBuilder(AbstractPlatform::class)->getMock(); } - public function testFactoryCreatesCorrectType() : void + public function testFactoryCreatesCorrectType(): void { self::assertSame(TimeImmutableType::class, get_class($this->type)); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('time_immutable', $this->type->getName()); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void + public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void { $date = $this->getMockBuilder(DateTimeImmutable::class)->getMock(); @@ -60,31 +61,31 @@ public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void ); } - public function testConvertsNullToDatabaseValue() : void + public function testConvertsNullToDatabaseValue(): void { self::assertNull($this->type->convertToDatabaseValue(null, $this->platform)); } - public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion() : void + public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue(new DateTime(), $this->platform); } - public function testConvertsDateTimeImmutableInstanceToPHPValue() : void + public function testConvertsDateTimeImmutableInstanceToPHPValue(): void { $date = new DateTimeImmutable(); self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform)); } - public function testConvertsNullToPHPValue() : void + public function testConvertsNullToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertsTimeStringToPHPValue() : void + public function testConvertsTimeStringToPHPValue(): void { $this->platform->expects($this->once()) ->method('getTimeFormatString') @@ -96,7 +97,7 @@ public function testConvertsTimeStringToPHPValue() : void self::assertSame('15:58:59', $date->format('H:i:s')); } - public function testResetDateFractionsWhenConvertingToPHPValue() : void + public function testResetDateFractionsWhenConvertingToPHPValue(): void { $this->platform->expects($this->any()) ->method('getTimeFormatString') @@ -107,14 +108,14 @@ public function testResetDateFractionsWhenConvertingToPHPValue() : void self::assertSame('1970-01-01 15:58:59', $date->format('Y-m-d H:i:s')); } - public function testThrowsExceptionDuringConversionToPHPValueWithInvalidTimeString() : void + public function testThrowsExceptionDuringConversionToPHPValueWithInvalidTimeString(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('invalid time string', $this->platform); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php index c9b340c6325..8bec5c2ae37 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php @@ -7,19 +7,19 @@ class TimeTest extends BaseDateTypeTestCase { - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('time'); parent::setUp(); } - public function testTimeConvertsToPHPValue() : void + public function testTimeConvertsToPHPValue(): void { self::assertInstanceOf('DateTime', $this->type->convertToPHPValue('5:30:55', $this->platform)); } - public function testDateFieldResetInPHPValue() : void + public function testDateFieldResetInPHPValue(): void { $time = $this->type->convertToPHPValue('01:23:34', $this->platform); @@ -27,7 +27,7 @@ public function testDateFieldResetInPHPValue() : void self::assertEquals('1970-01-01', $time->format('Y-m-d')); } - public function testInvalidTimeFormatConversion() : void + public function testInvalidTimeFormatConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('abcdefg', $this->platform); diff --git a/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php b/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php index 14cd7497385..be4ba0dddfe 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php @@ -26,7 +26,7 @@ class TypeRegistryTest extends TestCase /** @var BinaryType */ private $otherTestType; - protected function setUp() : void + protected function setUp(): void { $this->testType = new BlobType(); $this->otherTestType = new BinaryType(); @@ -36,7 +36,7 @@ protected function setUp() : void $this->registry->register(self::OTHER_TEST_TYPE_NAME, $this->otherTestType); } - public function testGet() : void + public function testGet(): void { self::assertSame($this->testType, $this->registry->get(self::TEST_TYPE_NAME)); self::assertSame($this->otherTestType, $this->registry->get(self::OTHER_TEST_TYPE_NAME)); @@ -45,7 +45,7 @@ public function testGet() : void $this->registry->get('unknown'); } - public function testGetReturnsSameInstances() : void + public function testGetReturnsSameInstances(): void { self::assertSame( $this->registry->get(self::TEST_TYPE_NAME), @@ -53,7 +53,7 @@ public function testGetReturnsSameInstances() : void ); } - public function testLookupName() : void + public function testLookupName(): void { self::assertSame( self::TEST_TYPE_NAME, @@ -68,14 +68,14 @@ public function testLookupName() : void $this->registry->lookupName(new TextType()); } - public function testHas() : void + public function testHas(): void { self::assertTrue($this->registry->has(self::TEST_TYPE_NAME)); self::assertTrue($this->registry->has(self::OTHER_TEST_TYPE_NAME)); self::assertFalse($this->registry->has('unknown')); } - public function testRegister() : void + public function testRegister(): void { $newType = new TextType(); @@ -85,7 +85,7 @@ public function testRegister() : void self::assertSame($newType, $this->registry->get('some')); } - public function testRegisterWithAlradyRegisteredName() : void + public function testRegisterWithAlradyRegisteredName(): void { $this->registry->register('some', new TextType()); @@ -93,7 +93,7 @@ public function testRegisterWithAlradyRegisteredName() : void $this->registry->register('some', new TextType()); } - public function testRegisterWithAlreadyRegisteredInstance() : void + public function testRegisterWithAlreadyRegisteredInstance(): void { $newType = new TextType(); @@ -103,7 +103,7 @@ public function testRegisterWithAlreadyRegisteredInstance() : void $this->registry->register('other', $newType); } - public function testOverride() : void + public function testOverride(): void { $baseType = new TextType(); $overrideType = new StringType(); @@ -114,7 +114,7 @@ public function testOverride() : void self::assertSame($overrideType, $this->registry->get('some')); } - public function testOverrideAllowsExistingInstance() : void + public function testOverrideAllowsExistingInstance(): void { $type = new TextType(); @@ -124,7 +124,7 @@ public function testOverrideAllowsExistingInstance() : void self::assertSame($type, $this->registry->get('some')); } - public function testOverrideWithAlreadyRegisteredInstance() : void + public function testOverrideWithAlreadyRegisteredInstance(): void { $newType = new TextType(); @@ -135,13 +135,13 @@ public function testOverrideWithAlreadyRegisteredInstance() : void $this->registry->override('second', $newType); } - public function testOverrideWithUnknownType() : void + public function testOverrideWithUnknownType(): void { $this->expectException(DBALException::class); $this->registry->override('unknown', new TextType()); } - public function testGetMap() : void + public function testGetMap(): void { $registeredTypes = $this->registry->getMap(); diff --git a/tests/Doctrine/Tests/DBAL/Types/TypeTest.php b/tests/Doctrine/Tests/DBAL/Types/TypeTest.php index 8dbca8b57f0..314ad868024 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TypeTest.php @@ -13,7 +13,7 @@ class TypeTest extends TestCase /** * @dataProvider defaultTypesProvider() */ - public function testDefaultTypesAreRegistered(string $name) : void + public function testDefaultTypesAreRegistered(string $name): void { self::assertTrue(Type::hasType($name)); } @@ -21,7 +21,7 @@ public function testDefaultTypesAreRegistered(string $name) : void /** * @return iterable */ - public function defaultTypesProvider() : iterable + public function defaultTypesProvider(): iterable { foreach ((new ReflectionClass(Type::class))->getReflectionConstants() as $constant) { if (! $constant->isPublic()) { diff --git a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php index d3609fe2bac..a8652a6115b 100644 --- a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php @@ -20,7 +20,7 @@ class VarDateTimeImmutableTypeTest extends TestCase /** @var VarDateTimeImmutableType */ private $type; - protected function setUp() : void + protected function setUp(): void { if (! Type::hasType('vardatetime_immutable')) { Type::addType('vardatetime_immutable', VarDateTimeImmutableType::class); @@ -30,17 +30,17 @@ protected function setUp() : void $this->platform = $this->getMockForAbstractClass(AbstractPlatform::class); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('datetime_immutable', $this->type->getName()); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void + public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void { $date = $this->getMockBuilder(DateTimeImmutable::class)->getMock(); @@ -55,31 +55,31 @@ public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void ); } - public function testConvertsNullToDatabaseValue() : void + public function testConvertsNullToDatabaseValue(): void { self::assertNull($this->type->convertToDatabaseValue(null, $this->platform)); } - public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion() : void + public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue(new DateTime(), $this->platform); } - public function testConvertsDateTimeImmutableInstanceToPHPValue() : void + public function testConvertsDateTimeImmutableInstanceToPHPValue(): void { $date = new DateTimeImmutable(); self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform)); } - public function testConvertsNullToPHPValue() : void + public function testConvertsNullToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertsDateishStringToPHPValue() : void + public function testConvertsDateishStringToPHPValue(): void { $date = $this->type->convertToPHPValue('2016-01-01 15:58:59.123456 UTC', $this->platform); @@ -87,14 +87,14 @@ public function testConvertsDateishStringToPHPValue() : void self::assertSame('2016-01-01 15:58:59.123456 UTC', $date->format('Y-m-d H:i:s.u T')); } - public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateishString() : void + public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateishString(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('invalid date-ish string', $this->platform); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php index 4e24f53373d..586b36e89cd 100644 --- a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php @@ -18,7 +18,7 @@ class VarDateTimeTest extends DbalTestCase /** @var VarDateTimeType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); if (! Type::hasType('vardatetime')) { @@ -28,7 +28,7 @@ protected function setUp() : void $this->type = Type::getType('vardatetime'); } - public function testDateTimeConvertsToDatabaseValue() : void + public function testDateTimeConvertsToDatabaseValue(): void { $date = new DateTime('1985-09-01 10:10:10'); @@ -38,7 +38,7 @@ public function testDateTimeConvertsToDatabaseValue() : void self::assertEquals($expected, $actual); } - public function testDateTimeConvertsToPHPValue() : void + public function testDateTimeConvertsToPHPValue(): void { // Birthday of jwage and also birthday of Doctrine. Send him a present ;) $date = $this->type->convertToPHPValue('1985-09-01 00:00:00', $this->platform); @@ -47,13 +47,13 @@ public function testDateTimeConvertsToPHPValue() : void self::assertEquals('000000', $date->format('u')); } - public function testInvalidDateTimeFormatConversion() : void + public function testInvalidDateTimeFormatConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('abcdefg', $this->platform); } - public function testConversionWithMicroseconds() : void + public function testConversionWithMicroseconds(): void { $date = $this->type->convertToPHPValue('1985-09-01 00:00:00.123456', $this->platform); self::assertInstanceOf('DateTime', $date); @@ -61,12 +61,12 @@ public function testConversionWithMicroseconds() : void self::assertEquals('123456', $date->format('u')); } - public function testNullConversion() : void + public function testNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertDateTimeToPHPValue() : void + public function testConvertDateTimeToPHPValue(): void { $date = new DateTime('now'); self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform)); diff --git a/tests/Doctrine/Tests/DBAL/UtilTest.php b/tests/Doctrine/Tests/DBAL/UtilTest.php index 92f63872f15..13211764a27 100644 --- a/tests/Doctrine/Tests/DBAL/UtilTest.php +++ b/tests/Doctrine/Tests/DBAL/UtilTest.php @@ -10,7 +10,7 @@ class UtilTest extends DbalTestCase /** * @return mixed[][] */ - public static function dataConvertPositionalToNamedParameters() : iterable + public static function dataConvertPositionalToNamedParameters(): iterable { return [ [ @@ -71,7 +71,7 @@ public static function dataConvertPositionalToNamedParameters() : iterable * * @dataProvider dataConvertPositionalToNamedParameters */ - public function testConvertPositionalToNamedParameters(string $inputSQL, string $expectedOutputSQL, array $expectedOutputParamsMap) : void + public function testConvertPositionalToNamedParameters(string $inputSQL, string $expectedOutputSQL, array $expectedOutputParamsMap): void { [$statement, $params] = OCI8Statement::convertPositionalToNamedPlaceholders($inputSQL); diff --git a/tests/Doctrine/Tests/DbalFunctionalTestCase.php b/tests/Doctrine/Tests/DbalFunctionalTestCase.php index 4546f60090e..dc7786c5208 100644 --- a/tests/Doctrine/Tests/DbalFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DbalFunctionalTestCase.php @@ -7,6 +7,7 @@ use Exception; use PHPUnit\Framework\AssertionFailedError; use Throwable; + use function array_map; use function array_reverse; use function count; @@ -16,6 +17,7 @@ use function is_scalar; use function strpos; use function var_export; + use const PHP_EOL; abstract class DbalFunctionalTestCase extends DbalTestCase @@ -33,7 +35,7 @@ abstract class DbalFunctionalTestCase extends DbalTestCase /** @var DebugStack */ protected $sqlLoggerStack; - protected function resetSharedConn() : void + protected function resetSharedConn(): void { if (! self::$sharedConnection) { return; @@ -43,7 +45,7 @@ protected function resetSharedConn() : void self::$sharedConnection = null; } - protected function setUp() : void + protected function setUp(): void { if (! isset(self::$sharedConnection)) { self::$sharedConnection = TestUtil::getConnection(); @@ -55,14 +57,14 @@ protected function setUp() : void $this->connection->getConfiguration()->setSQLLogger($this->sqlLoggerStack); } - protected function tearDown() : void + protected function tearDown(): void { while ($this->connection->isTransactionActive()) { $this->connection->rollBack(); } } - protected function onNotSuccessfulTest(Throwable $t) : void + protected function onNotSuccessfulTest(Throwable $t): void { if ($t instanceof AssertionFailedError) { throw $t; diff --git a/tests/Doctrine/Tests/DbalPerformanceTestCase.php b/tests/Doctrine/Tests/DbalPerformanceTestCase.php index 9ab40f058b1..67ad9be5c72 100644 --- a/tests/Doctrine/Tests/DbalPerformanceTestCase.php +++ b/tests/Doctrine/Tests/DbalPerformanceTestCase.php @@ -27,7 +27,7 @@ abstract class DbalPerformanceTestCase extends DbalFunctionalTestCase */ private $runTime; - protected function assertPostConditions() : void + protected function assertPostConditions(): void { // If a perf test doesn't start or stop, it fails. self::assertNotNull($this->startTime, 'Test timing was started'); @@ -37,7 +37,7 @@ protected function assertPostConditions() : void /** * begin timing */ - protected function startTiming() : void + protected function startTiming(): void { $this->startTime = microtime(true); } @@ -45,7 +45,7 @@ protected function startTiming() : void /** * end timing */ - protected function stopTiming() : void + protected function stopTiming(): void { $this->runTime = microtime(true) - $this->startTime; } @@ -53,7 +53,7 @@ protected function stopTiming() : void /** * @return float elapsed test execution time */ - public function getTime() : float + public function getTime(): float { return $this->runTime; } diff --git a/tests/Doctrine/Tests/DbalPerformanceTestListener.php b/tests/Doctrine/Tests/DbalPerformanceTestListener.php index c9f0027c015..7e64849848b 100644 --- a/tests/Doctrine/Tests/DbalPerformanceTestListener.php +++ b/tests/Doctrine/Tests/DbalPerformanceTestListener.php @@ -5,6 +5,7 @@ use PHPUnit\Framework\Test; use PHPUnit\Framework\TestListener; use PHPUnit\Framework\TestListenerDefaultImplementation; + use function get_class; use function printf; use function str_replace; @@ -19,7 +20,7 @@ class DbalPerformanceTestListener implements TestListener /** @var array> */ private $timings = []; - public function endTest(Test $test, float $time) : void + public function endTest(Test $test, float $time): void { // This listener only applies to performance tests. if (! ($test instanceof DbalPerformanceTestCase)) { diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index 7df2a66ffaa..54b793129f0 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; use PHPUnit\Framework\Assert; + use function explode; use function extension_loaded; use function unlink; @@ -36,7 +37,7 @@ class TestUtil * * @return Connection The database connection instance. */ - public static function getConnection() : Connection + public static function getConnection(): Connection { if (self::hasRequiredConnectionParams() && ! self::$initialized) { self::initializeDatabase(); @@ -53,7 +54,7 @@ public static function getConnection() : Connection /** * @return mixed[] */ - public static function getConnectionParams() : array + public static function getConnectionParams(): array { if (self::hasRequiredConnectionParams()) { return self::getTestConnectionParameters(); @@ -62,12 +63,12 @@ public static function getConnectionParams() : array return self::getFallbackConnectionParams(); } - private static function hasRequiredConnectionParams() : bool + private static function hasRequiredConnectionParams(): bool { return isset($GLOBALS['db_driver']); } - private static function initializeDatabase() : void + private static function initializeDatabase(): void { $testConnParams = self::getTestConnectionParameters(); $privConnParams = self::getPrivilegedConnectionParameters(); @@ -101,7 +102,7 @@ private static function initializeDatabase() : void /** * @return mixed[] */ - private static function getFallbackConnectionParams() : array + private static function getFallbackConnectionParams(): array { if (! extension_loaded('pdo_sqlite')) { Assert::markTestSkipped('PDO SQLite extension is not loaded'); @@ -120,7 +121,7 @@ private static function getFallbackConnectionParams() : array return $params; } - private static function addDbEventSubscribers(Connection $conn) : void + private static function addDbEventSubscribers(Connection $conn): void { if (! isset($GLOBALS['db_event_subscribers'])) { return; @@ -136,7 +137,7 @@ private static function addDbEventSubscribers(Connection $conn) : void /** * @return mixed[] */ - private static function getPrivilegedConnectionParameters() : array + private static function getPrivilegedConnectionParameters(): array { if (isset($GLOBALS['tmpdb_driver'])) { return self::mapConnectionParameters($GLOBALS, 'tmpdb_'); @@ -151,7 +152,7 @@ private static function getPrivilegedConnectionParameters() : array /** * @return mixed[] */ - private static function getTestConnectionParameters() : array + private static function getTestConnectionParameters(): array { return self::mapConnectionParameters($GLOBALS, 'db_'); } @@ -161,20 +162,22 @@ private static function getTestConnectionParameters() : array * * @return array */ - private static function mapConnectionParameters(array $configuration, string $prefix) : array + private static function mapConnectionParameters(array $configuration, string $prefix): array { $parameters = []; - foreach ([ - 'driver', - 'user', - 'password', - 'host', - 'dbname', - 'port', - 'server', - 'unix_socket', - ] as $parameter) { + foreach ( + [ + 'driver', + 'user', + 'password', + 'host', + 'dbname', + 'port', + 'server', + 'unix_socket', + ] as $parameter + ) { if (! isset($configuration[$prefix . $parameter])) { continue; } @@ -185,7 +188,7 @@ private static function mapConnectionParameters(array $configuration, string $pr return $parameters; } - public static function getPrivilegedConnection() : Connection + public static function getPrivilegedConnection(): Connection { return DriverManager::getConnection(self::getPrivilegedConnectionParameters()); } diff --git a/tests/Doctrine/Tests/Types/CommentedType.php b/tests/Doctrine/Tests/Types/CommentedType.php index cbe98b2324b..a589c9fbe22 100644 --- a/tests/Doctrine/Tests/Types/CommentedType.php +++ b/tests/Doctrine/Tests/Types/CommentedType.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; + use function strtoupper; class CommentedType extends Type diff --git a/tests/Doctrine/Tests/Types/MySqlPointType.php b/tests/Doctrine/Tests/Types/MySqlPointType.php index f4740769b8b..951bd7f4916 100644 --- a/tests/Doctrine/Tests/Types/MySqlPointType.php +++ b/tests/Doctrine/Tests/Types/MySqlPointType.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; + use function strtoupper; class MySqlPointType extends Type diff --git a/tests/continuousphp/bootstrap.php b/tests/continuousphp/bootstrap.php index e24bea47112..899fd6d5e16 100644 --- a/tests/continuousphp/bootstrap.php +++ b/tests/continuousphp/bootstrap.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\DriverManager; -(static function () : void { +(static function (): void { // workaround for https://bugs.php.net/bug.php?id=77120 DriverManager::getConnection([ 'driver' => 'oci8', From 99c1b213fef5b23c5c0a1c2087a16d158a09b5e2 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 6 Jul 2020 23:05:53 -0700 Subject: [PATCH 19/19] Rename classes in Driver\PDO* namespaces --- UPGRADE.md | 12 ++++++ psalm.xml | 4 +- src/Driver/{PDOMySql => PDO/MySQL}/Driver.php | 5 +-- src/Driver/{PDOOracle => PDO/OCI}/Driver.php | 10 +---- src/Driver/{PDOPgSql => PDO/PgSQL}/Driver.php | 5 +-- .../{PDOSqlsrv => PDO/SQLSrv}/Connection.php | 2 +- .../{PDOSqlsrv => PDO/SQLSrv}/Driver.php | 5 +-- .../{PDOSqlsrv => PDO/SQLSrv}/Statement.php | 5 +-- .../{PDOSqlite => PDO/SQLite}/Driver.php | 5 +-- src/DriverManager.php | 32 ++++++-------- src/Id/TableGenerator.php | 2 +- tests/ConnectionTest.php | 2 +- .../{PDOMySql => PDO/MySQL}/DriverTest.php | 4 +- .../{PDOOracle => PDO/OCI}/DriverTest.php | 4 +- .../{PDOPgSql => PDO/PgSQL}/DriverTest.php | 23 +++++----- .../{PDOSqlsrv => PDO/SQLSrv}/DriverTest.php | 4 +- .../{PDOSqlite => PDO/SQLite}/DriverTest.php | 4 +- tests/DriverManagerTest.php | 43 +++++++++---------- tests/Functional/BlobTest.php | 4 +- .../Functional/Driver/PDO/ConnectionTest.php | 13 +++--- .../{PDOMySql => PDO/MySQL}/DriverTest.php | 4 +- .../{PDOOracle => PDO/OCI}/DriverTest.php | 4 +- .../PgSQL}/ConnectionTest.php | 8 ++-- .../{PDOPgSql => PDO/PgSQL}/DriverTest.php | 4 +- .../{PDOSqlsrv => PDO/SQLSrv}/DriverTest.php | 6 +-- .../{PDOSqlite => PDO/SQLite}/DriverTest.php | 4 +- tests/Functional/StatementTest.php | 10 ++--- tests/Functional/TypeConversionTest.php | 4 +- tests/Functional/Types/BinaryTest.php | 4 +- 29 files changed, 108 insertions(+), 128 deletions(-) rename src/Driver/{PDOMySql => PDO/MySQL}/Driver.php (95%) rename src/Driver/{PDOOracle => PDO/OCI}/Driver.php (75%) rename src/Driver/{PDOPgSql => PDO/PgSQL}/Driver.php (97%) rename src/Driver/{PDOSqlsrv => PDO/SQLSrv}/Connection.php (98%) rename src/Driver/{PDOSqlsrv => PDO/SQLSrv}/Driver.php (96%) rename src/Driver/{PDOSqlsrv => PDO/SQLSrv}/Statement.php (94%) rename src/Driver/{PDOSqlite => PDO/SQLite}/Driver.php (96%) rename tests/Driver/{PDOMySql => PDO/MySQL}/DriverTest.php (74%) rename tests/Driver/{PDOOracle => PDO/OCI}/DriverTest.php (74%) rename tests/Driver/{PDOPgSql => PDO/PgSQL}/DriverTest.php (68%) rename tests/Driver/{PDOSqlsrv => PDO/SQLSrv}/DriverTest.php (74%) rename tests/Driver/{PDOSqlite => PDO/SQLite}/DriverTest.php (73%) rename tests/Functional/Driver/{PDOMySql => PDO/MySQL}/DriverTest.php (86%) rename tests/Functional/Driver/{PDOOracle => PDO/OCI}/DriverTest.php (90%) rename tests/Functional/Driver/{PDOPgSql => PDO/PgSQL}/ConnectionTest.php (82%) rename tests/Functional/Driver/{PDOPgSql => PDO/PgSQL}/DriverTest.php (97%) rename tests/Functional/Driver/{PDOSqlsrv => PDO/SQLSrv}/DriverTest.php (92%) rename tests/Functional/Driver/{PDOSqlite => PDO/SQLite}/DriverTest.php (88%) diff --git a/UPGRADE.md b/UPGRADE.md index aae1a14a8f5..ea573effcc0 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,17 @@ # Upgrade to 3.0 +## BC BREAK: PDO-based driver classes are moved under the PDO namespace + +The following classes have been renamed: + +- `PDOMySql\Driver` → `PDO\MySQL\Driver` +- `PDOOracle\Driver` → `PDO\OCI\Driver` +- `PDOPgSql\Driver` → `PDO\PgSQL\Driver` +- `PDOSqlite\Driver` → `PDO\SQLite\Driver` +- `PDOSqlsrv\Driver` → `PDO\SQLSrv\Driver` +- `PDOSqlsrv\Connection` → `PDO\SQLSrv\Connection` +- `PDOSqlsrv\Statement` → `PDO\SQLSrv\Statement` + ## BC BREAK: Changes schema manager instantiation. 1. The `$platform` argument of all schema manager constructors is no longer optional. diff --git a/psalm.xml b/psalm.xml index b8f382f9586..a60412e4e5d 100644 --- a/psalm.xml +++ b/psalm.xml @@ -37,7 +37,7 @@ - + @@ -64,7 +64,7 @@ Requires a release of https://github.com/JetBrains/phpstorm-stubs/pull/732 --> - + diff --git a/src/Driver/PDOMySql/Driver.php b/src/Driver/PDO/MySQL/Driver.php similarity index 95% rename from src/Driver/PDOMySql/Driver.php rename to src/Driver/PDO/MySQL/Driver.php index a0d7dc9617e..1b52fb8a3dd 100644 --- a/src/Driver/PDOMySql/Driver.php +++ b/src/Driver/PDO/MySQL/Driver.php @@ -1,14 +1,11 @@ PDOMySQLDriver::class, - 'pdo_sqlite' => PDOSQLiteDriver::class, - 'pdo_pgsql' => PDOPgSQLDriver::class, - 'pdo_oci' => PDOOCIDriver::class, - 'oci8' => OCI8Driver::class, - 'ibm_db2' => IBMDB2Driver::class, - 'pdo_sqlsrv' => PDOSQLSrvDriver::class, - 'mysqli' => MySQLiDriver::class, - 'sqlsrv' => SQLSrvDriver::class, + 'pdo_mysql' => PDO\MySQL\Driver::class, + 'pdo_sqlite' => PDO\SQLite\Driver::class, + 'pdo_pgsql' => PDO\PgSQL\Driver::class, + 'pdo_oci' => PDO\OCI\Driver::class, + 'oci8' => OCI8\Driver::class, + 'ibm_db2' => IBMDB2\Driver::class, + 'pdo_sqlsrv' => PDO\SQLSrv\Driver::class, + 'mysqli' => Mysqli\Driver::class, + 'sqlsrv' => SQLSrv\Driver::class, ]; /** diff --git a/src/Id/TableGenerator.php b/src/Id/TableGenerator.php index 6b5a62353a4..cdb7adcbbbc 100644 --- a/src/Id/TableGenerator.php +++ b/src/Id/TableGenerator.php @@ -70,7 +70,7 @@ class TableGenerator */ public function __construct(Connection $conn, $generatorTableName = 'sequences') { - if ($conn->getDriver() instanceof Driver\PDOSqlite\Driver) { + if ($conn->getDriver() instanceof Driver\PDO\SQLite\Driver) { throw new DBALException('Cannot use TableGenerator with SQLite.'); } diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index a0146693381..7043382765f 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -110,7 +110,7 @@ public function testGetConfiguration(): void public function testGetDriver(): void { - self::assertInstanceOf(\Doctrine\DBAL\Driver\PDOMySql\Driver::class, $this->connection->getDriver()); + self::assertInstanceOf(Driver\PDO\MySQL\Driver::class, $this->connection->getDriver()); } public function testGetEventManager(): void diff --git a/tests/Driver/PDOMySql/DriverTest.php b/tests/Driver/PDO/MySQL/DriverTest.php similarity index 74% rename from tests/Driver/PDOMySql/DriverTest.php rename to tests/Driver/PDO/MySQL/DriverTest.php index d97f03a7c30..f059e1e6514 100644 --- a/tests/Driver/PDOMySql/DriverTest.php +++ b/tests/Driver/PDO/MySQL/DriverTest.php @@ -1,9 +1,9 @@ connect([]); - self::assertInstanceOf(PDOConnection::class, $connection); + self::assertInstanceOf(PDO\Connection::class, $connection); self::assertTrue( - $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES) + $connection->getWrappedConnection()->getAttribute(\PDO::PGSQL_ATTR_DISABLE_PREPARES) ); } @@ -44,12 +43,12 @@ public function testConnectionDisablesPrepares(): void public function testConnectionDoesNotDisablePreparesWhenAttributeDefined(): void { $connection = $this->connect( - [PDO::PGSQL_ATTR_DISABLE_PREPARES => false] + [\PDO::PGSQL_ATTR_DISABLE_PREPARES => false] ); - self::assertInstanceOf(PDOConnection::class, $connection); + self::assertInstanceOf(PDO\Connection::class, $connection); self::assertNotTrue( - $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES) + $connection->getWrappedConnection()->getAttribute(\PDO::PGSQL_ATTR_DISABLE_PREPARES) ); } @@ -59,12 +58,12 @@ public function testConnectionDoesNotDisablePreparesWhenAttributeDefined(): void public function testConnectionDisablePreparesWhenDisablePreparesIsExplicitlyDefined(): void { $connection = $this->connect( - [PDO::PGSQL_ATTR_DISABLE_PREPARES => true] + [\PDO::PGSQL_ATTR_DISABLE_PREPARES => true] ); - self::assertInstanceOf(PDOConnection::class, $connection); + self::assertInstanceOf(PDO\Connection::class, $connection); self::assertTrue( - $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES) + $connection->getWrappedConnection()->getAttribute(\PDO::PGSQL_ATTR_DISABLE_PREPARES) ); } diff --git a/tests/Driver/PDOSqlsrv/DriverTest.php b/tests/Driver/PDO/SQLSrv/DriverTest.php similarity index 74% rename from tests/Driver/PDOSqlsrv/DriverTest.php rename to tests/Driver/PDO/SQLSrv/DriverTest.php index dcffafafac3..306ea0d1e0a 100644 --- a/tests/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Driver/PDO/SQLSrv/DriverTest.php @@ -1,9 +1,9 @@ PDOMySQLDriver::class]; + $options = ['driverClass' => PDO\MySQL\Driver::class]; $conn = DriverManager::getConnection($options); - self::assertInstanceOf(PDOMySQLDriver::class, $conn->getDriver()); + self::assertInstanceOf(PDO\MySQL\Driver::class, $conn->getDriver()); } public function testDatabaseUrlPrimaryReplica(): void @@ -113,7 +112,7 @@ public function testDatabaseUrlPrimaryReplica(): void $conn = DriverManager::getConnection($options); $params = $conn->getParams(); - self::assertInstanceOf(PDOMySQLDriver::class, $conn->getDriver()); + self::assertInstanceOf(PDO\MySQL\Driver::class, $conn->getDriver()); $expected = [ 'user' => 'foo', @@ -173,7 +172,7 @@ public function databaseUrls(): iterable 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', - 'driver' => PDOMySQLDriver::class, + 'driver' => PDO\MySQL\Driver::class, ], ], 'simple URL with port' => [ @@ -184,49 +183,49 @@ public function databaseUrls(): iterable 'host' => 'localhost', 'port' => 11211, 'dbname' => 'baz', - 'driver' => PDOMySQLDriver::class, + 'driver' => PDO\MySQL\Driver::class, ], ], 'sqlite relative URL with host' => [ 'sqlite://localhost/foo/dbname.sqlite', [ 'path' => 'foo/dbname.sqlite', - 'driver' => PDOSqliteDriver::class, + 'driver' => PDO\SQLite\Driver::class, ], ], 'sqlite absolute URL with host' => [ 'sqlite://localhost//tmp/dbname.sqlite', [ 'path' => '/tmp/dbname.sqlite', - 'driver' => PDOSqliteDriver::class, + 'driver' => PDO\SQLite\Driver::class, ], ], 'sqlite relative URL without host' => [ 'sqlite:///foo/dbname.sqlite', [ 'path' => 'foo/dbname.sqlite', - 'driver' => PDOSqliteDriver::class, + 'driver' => PDO\SQLite\Driver::class, ], ], 'sqlite absolute URL without host' => [ 'sqlite:////tmp/dbname.sqlite', [ 'path' => '/tmp/dbname.sqlite', - 'driver' => PDOSqliteDriver::class, + 'driver' => PDO\SQLite\Driver::class, ], ], 'sqlite memory' => [ 'sqlite:///:memory:', [ 'memory' => true, - 'driver' => PDOSqliteDriver::class, + 'driver' => PDO\SQLite\Driver::class, ], ], 'sqlite memory with host' => [ 'sqlite://localhost/:memory:', [ 'memory' => true, - 'driver' => PDOSqliteDriver::class, + 'driver' => PDO\SQLite\Driver::class, ], ], 'params parsed from URL override individual params' => [ @@ -239,7 +238,7 @@ public function databaseUrls(): iterable 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', - 'driver' => PDOMySQLDriver::class, + 'driver' => PDO\MySQL\Driver::class, ], ], 'params not parsed from URL but individual params are preserved' => [ @@ -253,7 +252,7 @@ public function databaseUrls(): iterable 'host' => 'localhost', 'port' => 1234, 'dbname' => 'baz', - 'driver' => PDOMySQLDriver::class, + 'driver' => PDO\MySQL\Driver::class, ], ], 'query params from URL are used as extra params' => [ @@ -281,7 +280,7 @@ public function databaseUrls(): iterable 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', - 'driver' => PDOMySQLDriver::class, + 'driver' => PDO\MySQL\Driver::class, ], ], 'simple URL with percent encoding' => [ @@ -291,7 +290,7 @@ public function databaseUrls(): iterable 'password' => 'bar/', 'host' => 'localhost', 'dbname' => 'baz+baz@', - 'driver' => PDOMySQLDriver::class, + 'driver' => PDO\MySQL\Driver::class, ], ], 'simple URL with percent sign in password' => [ @@ -301,7 +300,7 @@ public function databaseUrls(): iterable 'password' => 'bar%bar', 'host' => 'localhost', 'dbname' => 'baz', - 'driver' => PDOMySQLDriver::class, + 'driver' => PDO\MySQL\Driver::class, ], ], @@ -320,7 +319,7 @@ public function databaseUrls(): iterable 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', - 'driver' => PDOMySQLDriver::class, + 'driver' => PDO\MySQL\Driver::class, ], ], 'URL without scheme but custom driver' => [ @@ -360,7 +359,7 @@ public function databaseUrls(): iterable 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', - 'driver' => PDOMySQLDriver::class, + 'driver' => PDO\MySQL\Driver::class, ], ], 'URL with default custom driver' => [ @@ -373,7 +372,7 @@ public function databaseUrls(): iterable 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', - 'driver' => PDOMySQLDriver::class, + 'driver' => PDO\MySQL\Driver::class, ], ], 'URL with default driver and default custom driver' => [ @@ -387,7 +386,7 @@ public function databaseUrls(): iterable 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', - 'driver' => PDOMySQLDriver::class, + 'driver' => PDO\MySQL\Driver::class, ], ], ]; diff --git a/tests/Functional/BlobTest.php b/tests/Functional/BlobTest.php index 749bdaeedce..0248b8d9912 100644 --- a/tests/Functional/BlobTest.php +++ b/tests/Functional/BlobTest.php @@ -3,7 +3,7 @@ namespace Doctrine\DBAL\Tests\Functional; use Doctrine\DBAL\Driver\OCI8\Driver as OCI8Driver; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Tests\FunctionalTestCase; @@ -22,7 +22,7 @@ protected function setUp(): void { parent::setUp(); - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDO\OCI\Driver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported // see http://php.net/manual/en/pdo.lobs.php#example-1035 self::markTestSkipped('DBAL doesn\'t support storing LOBs represented as streams using PDO_OCI'); diff --git a/tests/Functional/Driver/PDO/ConnectionTest.php b/tests/Functional/Driver/PDO/ConnectionTest.php index 46b1298439f..628fa882a1c 100644 --- a/tests/Functional/Driver/PDO/ConnectionTest.php +++ b/tests/Functional/Driver/PDO/ConnectionTest.php @@ -2,13 +2,10 @@ namespace Doctrine\DBAL\Tests\Functional\Driver\PDO; +use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\Driver\PDO\Connection; use Doctrine\DBAL\Driver\PDO\Exception; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; -use Doctrine\DBAL\Driver\PDOPgSql\Driver as PDOPgSQLDriver; -use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSRVDriver; use Doctrine\DBAL\Tests\FunctionalTestCase; -use PDO; use function get_class; use function sprintf; @@ -66,7 +63,7 @@ public function testThrowsWrappedExceptionOnPrepare(): void { $driver = $this->connection->getDriver(); - if ($driver instanceof PDOSQLSRVDriver) { + if ($driver instanceof PDO\SQLSrv\Driver) { self::markTestSkipped('pdo_sqlsrv does not allow setting PDO::ATTR_EMULATE_PREPARES at connection level.'); } @@ -74,8 +71,8 @@ public function testThrowsWrappedExceptionOnPrepare(): void // even though emulated prepared statements are disabled, // so an exception is thrown only eventually. if ( - $driver instanceof PDOOracleDriver - || $driver instanceof PDOPgSQLDriver + $driver instanceof PDO\OCI\Driver + || $driver instanceof PDO\PgSQL\Driver ) { self::markTestSkipped(sprintf( 'The underlying implementation of the %s driver does not check the query to be prepared server-side.', @@ -87,7 +84,7 @@ public function testThrowsWrappedExceptionOnPrepare(): void // so that PDO actually communicates with the database server to check the query. $this->driverConnection ->getWrappedConnection() - ->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); + ->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false); $this->expectException(Exception::class); diff --git a/tests/Functional/Driver/PDOMySql/DriverTest.php b/tests/Functional/Driver/PDO/MySQL/DriverTest.php similarity index 86% rename from tests/Functional/Driver/PDOMySql/DriverTest.php rename to tests/Functional/Driver/PDO/MySQL/DriverTest.php index ca79c242496..9839454ddb7 100644 --- a/tests/Functional/Driver/PDOMySql/DriverTest.php +++ b/tests/Functional/Driver/PDO/MySQL/DriverTest.php @@ -1,9 +1,9 @@ connection->getDatabasePlatform() instanceof PostgreSQL94Platform) { + if ($this->connection->getDriver() instanceof Driver) { return; } - self::markTestSkipped('PDOPgsql only test.'); + self::markTestSkipped('pdo_pgsql only test.'); } /** diff --git a/tests/Functional/Driver/PDOPgSql/DriverTest.php b/tests/Functional/Driver/PDO/PgSQL/DriverTest.php similarity index 97% rename from tests/Functional/Driver/PDOPgSql/DriverTest.php rename to tests/Functional/Driver/PDO/PgSQL/DriverTest.php index bfa33568934..84198893da0 100644 --- a/tests/Functional/Driver/PDOPgSql/DriverTest.php +++ b/tests/Functional/Driver/PDO/PgSQL/DriverTest.php @@ -1,10 +1,10 @@ connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDO\OCI\Driver) { self::markTestIncomplete('See https://bugs.php.net/bug.php?id=77181'); } @@ -50,7 +50,7 @@ public function testStatementIsReusableAfterFreeingResult(): void public function testReuseStatementWithLongerResults(): void { - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDO\OCI\Driver) { self::markTestIncomplete('PDO_OCI doesn\'t support fetching blobs via PDOStatement::fetchAll()'); } @@ -87,7 +87,7 @@ public function testReuseStatementWithLongerResults(): void public function testFetchLongBlob(): void { - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDO\OCI\Driver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported // see http://php.net/manual/en/pdo.lobs.php#example-1035 self::markTestSkipped('DBAL doesn\'t support storing LOBs represented as streams using PDO_OCI'); @@ -153,7 +153,7 @@ public function testIncompletelyFetchedStatementDoesNotBlockConnection(): void public function testReuseStatementAfterFreeingResult(): void { - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDO\OCI\Driver) { self::markTestIncomplete('See https://bugs.php.net/bug.php?id=77181'); } diff --git a/tests/Functional/TypeConversionTest.php b/tests/Functional/TypeConversionTest.php index ac2324d2eb8..99111a24915 100644 --- a/tests/Functional/TypeConversionTest.php +++ b/tests/Functional/TypeConversionTest.php @@ -3,7 +3,7 @@ namespace Doctrine\DBAL\Tests\Functional; use DateTime; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Types\Type; @@ -120,7 +120,7 @@ public static function floatProvider(): iterable */ public function testIdempotentConversionToString(string $type, $originalValue): void { - if ($type === 'text' && $this->connection->getDriver() instanceof PDOOracleDriver) { + if ($type === 'text' && $this->connection->getDriver() instanceof PDO\OCI\Driver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported // see http://php.net/manual/en/pdo.lobs.php#example-1035 self::markTestSkipped('DBAL doesn\'t support storing LOBs represented as streams using PDO_OCI'); diff --git a/tests/Functional/Types/BinaryTest.php b/tests/Functional/Types/BinaryTest.php index dac2c265430..332f318f6a2 100644 --- a/tests/Functional/Types/BinaryTest.php +++ b/tests/Functional/Types/BinaryTest.php @@ -5,7 +5,7 @@ namespace Doctrine\DBAL\Tests\Functional\Types; use Doctrine\DBAL\Driver\IBMDB2\Driver; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Tests\FunctionalTestCase; @@ -21,7 +21,7 @@ protected function setUp(): void { parent::setUp(); - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDO\OCI\Driver) { self::markTestSkipped('PDO_OCI doesn\'t support binding binary values'); }