diff --git a/composer.json b/composer.json index f17794bcec0..eb5f95c8eb0 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "doctrine/event-manager": "^1.0" }, "require-dev": { - "doctrine/coding-standard": "^6.0", + "doctrine/coding-standard": "^7.0", "jetbrains/phpstorm-stubs": "^2019.1", "nikic/php-parser": "^4.4", "phpstan/phpstan": "^0.12", diff --git a/composer.lock b/composer.lock index 215798b08a1..0073213a8c6 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": "b7f970513c9756e5eaaba3974429c23c", + "content-hash": "6bf4905b268231ccd58bdbe30d4ecf81", "packages": [ { "name": "doctrine/cache", @@ -478,28 +478,28 @@ }, { "name": "doctrine/coding-standard", - "version": "6.0.0", + "version": "7.0.2", "source": { "type": "git", "url": "https://github.com/doctrine/coding-standard.git", - "reference": "d33f69eb98b25aa51ffe3a909f0ec77000af4701" + "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/d33f69eb98b25aa51ffe3a909f0ec77000af4701", - "reference": "d33f69eb98b25aa51ffe3a909f0ec77000af4701", + "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/d8a60ec4da68025c42795b714f66e277dd3e11de", + "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", - "php": "^7.1", - "slevomat/coding-standard": "^5.0", - "squizlabs/php_codesniffer": "^3.4.0" + "php": "^7.2", + "slevomat/coding-standard": "^6.0", + "squizlabs/php_codesniffer": "^3.5.3" }, "type": "phpcodesniffer-standard", "extra": { "branch-alias": { - "dev-master": "6.0.x-dev" + "dev-master": "7.0.x-dev" } }, "autoload": { @@ -535,7 +535,7 @@ "standard", "style" ], - "time": "2019-03-15T12:45:47+00:00" + "time": "2019-12-11T07:59:21+00:00" }, { "name": "doctrine/instantiator", @@ -1282,16 +1282,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "0.3.5", + "version": "0.4.4", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "8c4ef2aefd9788238897b678a985e1d5c8df6db4" + "reference": "d8d9d4645379e677466d407034436bb155b11c65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/8c4ef2aefd9788238897b678a985e1d5c8df6db4", - "reference": "8c4ef2aefd9788238897b678a985e1d5c8df6db4", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/d8d9d4645379e677466d407034436bb155b11c65", + "reference": "d8d9d4645379e677466d407034436bb155b11c65", "shasum": "" }, "require": { @@ -1299,18 +1299,20 @@ }, "require-dev": { "consistence/coding-standard": "^3.5", + "ergebnis/composer-normalize": "^2.0.2", "jakub-onderka/php-parallel-lint": "^0.9.2", "phing/phing": "^2.16.0", - "phpstan/phpstan": "^0.10", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12.19", + "phpstan/phpstan-strict-rules": "^0.12", "phpunit/phpunit": "^6.3", "slevomat/coding-standard": "^4.7.2", - "squizlabs/php_codesniffer": "^3.3.2", - "symfony/process": "^3.4 || ^4.0" + "symfony/process": "^4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "0.3-dev" + "dev-master": "0.4-dev" } }, "autoload": { @@ -1325,7 +1327,7 @@ "MIT" ], "description": "PHPDoc parser with support for nullable, intersection and generic types", - "time": "2019-06-07T19:13:52+00:00" + "time": "2020-04-13T16:28:46+00:00" }, { "name": "phpstan/phpstan", @@ -2414,32 +2416,39 @@ }, { "name": "slevomat/coding-standard", - "version": "5.0.2", + "version": "6.3.3", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "223f02b6193fe47b7b483bfa5bf75693535482dd" + "reference": "b905a82255749de847fd4de607c7a4c8163f058d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/223f02b6193fe47b7b483bfa5bf75693535482dd", - "reference": "223f02b6193fe47b7b483bfa5bf75693535482dd", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/b905a82255749de847fd4de607c7a4c8163f058d", + "reference": "b905a82255749de847fd4de607c7a4c8163f058d", "shasum": "" }, "require": { "php": "^7.1", - "phpstan/phpdoc-parser": "^0.3.1", - "squizlabs/php_codesniffer": "^3.4.0" + "phpstan/phpdoc-parser": "0.4.0 - 0.4.4", + "squizlabs/php_codesniffer": "^3.5.5" }, "require-dev": { - "jakub-onderka/php-parallel-lint": "1.0.0", - "phing/phing": "2.16.1", - "phpstan/phpstan": "0.11.1", - "phpstan/phpstan-phpunit": "0.11", - "phpstan/phpstan-strict-rules": "0.11", - "phpunit/phpunit": "8.0.0" + "dealerdirect/phpcodesniffer-composer-installer": "0.6.2", + "phing/phing": "2.16.3", + "php-parallel-lint/php-parallel-lint": "1.2.0", + "phpstan/phpstan": "0.12.19", + "phpstan/phpstan-deprecation-rules": "0.12.2", + "phpstan/phpstan-phpunit": "0.12.8", + "phpstan/phpstan-strict-rules": "0.12.2", + "phpunit/phpunit": "7.5.20|8.5.2|9.1.2" }, "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "6.x-dev" + } + }, "autoload": { "psr-4": { "SlevomatCodingStandard\\": "SlevomatCodingStandard" @@ -2450,20 +2459,30 @@ "MIT" ], "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", - "time": "2019-03-12T20:26:36+00:00" + "funding": [ + { + "url": "https://github.com/kukulich", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard", + "type": "tidelift" + } + ], + "time": "2020-04-28T07:15:08+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.4.0", + "version": "3.5.5", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "379deb987e26c7cd103a7b387aea178baec96e48" + "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/379deb987e26c7cd103a7b387aea178baec96e48", - "reference": "379deb987e26c7cd103a7b387aea178baec96e48", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/73e2e7f57d958e7228fce50dc0c61f58f017f9f6", + "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6", "shasum": "" }, "require": { @@ -2496,12 +2515,12 @@ } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ "phpcs", "standards" ], - "time": "2018-12-19T23:57:18+00:00" + "time": "2020-04-17T01:09:41+00:00" }, { "name": "symfony/console", diff --git a/lib/Doctrine/DBAL/Cache/CacheException.php b/lib/Doctrine/DBAL/Cache/CacheException.php index 6bb5d1b5f6b..db5680812e2 100644 --- a/lib/Doctrine/DBAL/Cache/CacheException.php +++ b/lib/Doctrine/DBAL/Cache/CacheException.php @@ -10,7 +10,7 @@ class CacheException extends DBALException { /** - * @return \Doctrine\DBAL\Cache\CacheException + * @return CacheException */ public static function noCacheKey() { @@ -18,7 +18,7 @@ public static function noCacheKey() } /** - * @return \Doctrine\DBAL\Cache\CacheException + * @return CacheException */ public static function noResultDriverConfigured() { diff --git a/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php b/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php index 9433f982fc5..aef70b4624b 100644 --- a/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php +++ b/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php @@ -92,7 +92,7 @@ public function generateCacheKeys($query, $params, $types, array $connectionPara } /** - * @return \Doctrine\DBAL\Cache\QueryCacheProfile + * @return QueryCacheProfile */ public function setResultCacheDriver(Cache $cache) { @@ -102,7 +102,7 @@ public function setResultCacheDriver(Cache $cache) /** * @param string|null $cacheKey * - * @return \Doctrine\DBAL\Cache\QueryCacheProfile + * @return QueryCacheProfile */ public function setCacheKey($cacheKey) { @@ -112,7 +112,7 @@ public function setCacheKey($cacheKey) /** * @param int $lifetime * - * @return \Doctrine\DBAL\Cache\QueryCacheProfile + * @return QueryCacheProfile */ public function setLifetime($lifetime) { diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index f04c8524974..cbb44a94a1a 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -86,6 +86,7 @@ public function closeCursor() if (! $data) { $data = []; } + $data[$this->realKey] = $this->data; $this->resultCache->save($this->cacheKey, $data, $this->lifetime); diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 10da0f98f4d..4a9a8cd959c 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -1063,6 +1063,7 @@ public function executeUpdate($query, array $params = [], array $types = []) } else { $stmt->execute($params); } + $result = $stmt->rowCount(); } else { $result = $connection->exec($query); @@ -1179,9 +1180,11 @@ public function transactional(Closure $func) return $res; } catch (Exception $e) { $this->rollBack(); + throw $e; } catch (Throwable $e) { $this->rollBack(); + throw $e; } } @@ -1254,6 +1257,7 @@ public function beginTransaction() if ($logger) { $logger->startQuery('"SAVEPOINT"'); } + $this->createSavepoint($this->_getNestedTransactionSavePointName()); if ($logger) { $logger->stopQuery(); @@ -1274,6 +1278,7 @@ public function commit() if ($this->transactionNestingLevel === 0) { throw ConnectionException::noActiveTransaction(); } + if ($this->isRollbackOnly) { throw ConnectionException::commitFailedRollbackOnly(); } @@ -1298,6 +1303,7 @@ public function commit() if ($logger) { $logger->startQuery('"RELEASE SAVEPOINT"'); } + $this->releaseSavepoint($this->_getNestedTransactionSavePointName()); if ($logger) { $logger->stopQuery(); @@ -1354,6 +1360,7 @@ public function rollBack() if ($logger) { $logger->startQuery('"ROLLBACK"'); } + $this->transactionNestingLevel = 0; $connection->rollBack(); $this->isRollbackOnly = false; @@ -1368,6 +1375,7 @@ public function rollBack() if ($logger) { $logger->startQuery('"ROLLBACK TO SAVEPOINT"'); } + $this->rollbackSavepoint($this->_getNestedTransactionSavePointName()); --$this->transactionNestingLevel; if ($logger) { @@ -1479,6 +1487,7 @@ public function setRollbackOnly() if ($this->transactionNestingLevel === 0) { throw ConnectionException::noActiveTransaction(); } + $this->isRollbackOnly = true; } @@ -1555,6 +1564,7 @@ private function _bindTypedValues($stmt, array $params, array $types) } else { $stmt->bindValue($bindIndex, $value); } + ++$bindIndex; } } else { @@ -1584,6 +1594,7 @@ private function getBindingInfo($value, $type) if (is_string($type)) { $type = Type::getType($type); } + if ($type instanceof Type) { $value = $type->convertToDatabaseValue($value, $this->getDatabasePlatform()); $bindingType = $type->getBindingType(); @@ -1623,6 +1634,7 @@ public function resolveParams(array $params, array $types) } else { $resolvedParams[$bindIndex] = $value; } + ++$bindIndex; } } else { diff --git a/lib/Doctrine/DBAL/ConnectionException.php b/lib/Doctrine/DBAL/ConnectionException.php index 47c6ed9a0d4..f1914f5294e 100644 --- a/lib/Doctrine/DBAL/ConnectionException.php +++ b/lib/Doctrine/DBAL/ConnectionException.php @@ -8,7 +8,7 @@ class ConnectionException extends DBALException { /** - * @return \Doctrine\DBAL\ConnectionException + * @return ConnectionException */ public static function commitFailedRollbackOnly() { @@ -16,7 +16,7 @@ public static function commitFailedRollbackOnly() } /** - * @return \Doctrine\DBAL\ConnectionException + * @return ConnectionException */ public static function noActiveTransaction() { @@ -24,7 +24,7 @@ public static function noActiveTransaction() } /** - * @return \Doctrine\DBAL\ConnectionException + * @return ConnectionException */ public static function savepointsNotSupported() { @@ -32,7 +32,7 @@ public static function savepointsNotSupported() } /** - * @return \Doctrine\DBAL\ConnectionException + * @return ConnectionException */ public static function mayNotAlterNestedTransactionWithSavepointsInTransaction() { diff --git a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php index 1f8ae27ba51..0a21d31b035 100644 --- a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php +++ b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php @@ -95,6 +95,7 @@ public function __construct(array $params, Driver $driver, ?Configuration $confi if (! isset($params['slaves'], $params['master'])) { throw new InvalidArgumentException('master or slaves configuration missing'); } + if (count($params['slaves']) === 0) { throw new InvalidArgumentException('You have to configure at least one slaves.'); } diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php index b2852e55182..30ada6c5ecd 100644 --- a/lib/Doctrine/DBAL/DBALException.php +++ b/lib/Doctrine/DBAL/DBALException.php @@ -30,7 +30,7 @@ class DBALException extends Exception /** * @param string $method * - * @return \Doctrine\DBAL\DBALException + * @return DBALException */ public static function notSupported($method) { @@ -89,7 +89,7 @@ public static function invalidPlatformVersionSpecified($version, $expectedFormat } /** - * @return \Doctrine\DBAL\DBALException + * @return DBALException */ public static function invalidPdoInstance() { @@ -102,7 +102,7 @@ public static function invalidPdoInstance() /** * @param string|null $url The URL that was provided in the connection parameters (if any). * - * @return \Doctrine\DBAL\DBALException + * @return DBALException */ public static function driverRequired($url = null) { @@ -124,7 +124,7 @@ public static function driverRequired($url = null) * @param string $unknownDriverName * @param string[] $knownDrivers * - * @return \Doctrine\DBAL\DBALException + * @return DBALException */ public static function unknownDriver($unknownDriverName, array $knownDrivers) { @@ -144,6 +144,7 @@ public static function driverExceptionDuringQuery(Driver $driver, Throwable $dri if ($params) { $msg .= ' with params ' . self::formatParameters($params); } + $msg .= ":\n\n" . $driverEx->getMessage(); return static::wrapException($driver, $driverEx, $msg); @@ -165,6 +166,7 @@ private static function wrapException(Driver $driver, Throwable $driverEx, strin if ($driverEx instanceof DriverException) { return $driverEx; } + if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof DriverExceptionInterface) { return $driver->convertException($msg, $driverEx); } @@ -201,7 +203,7 @@ private static function formatParameters(array $params) /** * @param string $wrapperClass * - * @return \Doctrine\DBAL\DBALException + * @return DBALException */ public static function invalidWrapperClass($wrapperClass) { @@ -212,7 +214,7 @@ public static function invalidWrapperClass($wrapperClass) /** * @param string $driverClass * - * @return \Doctrine\DBAL\DBALException + * @return DBALException */ public static function invalidDriverClass($driverClass) { @@ -222,7 +224,7 @@ public static function invalidDriverClass($driverClass) /** * @param string $tableName * - * @return \Doctrine\DBAL\DBALException + * @return DBALException */ public static function invalidTableName($tableName) { @@ -232,7 +234,7 @@ public static function invalidTableName($tableName) /** * @param string $tableName * - * @return \Doctrine\DBAL\DBALException + * @return DBALException */ public static function noColumnsSpecifiedForTable($tableName) { @@ -240,7 +242,7 @@ public static function noColumnsSpecifiedForTable($tableName) } /** - * @return \Doctrine\DBAL\DBALException + * @return DBALException */ public static function limitOffsetInvalid() { @@ -250,7 +252,7 @@ public static function limitOffsetInvalid() /** * @param string $name * - * @return \Doctrine\DBAL\DBALException + * @return DBALException */ public static function typeExists($name) { @@ -260,7 +262,7 @@ public static function typeExists($name) /** * @param string $name * - * @return \Doctrine\DBAL\DBALException + * @return DBALException */ public static function unknownColumnType($name) { @@ -276,7 +278,7 @@ public static function unknownColumnType($name) /** * @param string $name * - * @return \Doctrine\DBAL\DBALException + * @return DBALException */ public static function typeNotFound($name) { diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index c46ddc63dd7..866e5d04617 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -32,8 +32,10 @@ public function convertException($message, DriverException $exception) switch ($exception->getErrorCode()) { case '1213': return new Exception\DeadlockException($message, $exception); + case '1205': return new Exception\LockWaitTimeoutException($message, $exception); + case '1050': return new Exception\TableExistsException($message, $exception); @@ -123,6 +125,7 @@ public function createDatabasePlatformForVersion($version) if (version_compare($oracleMysqlVersion, '8', '>=')) { return new MySQL80Platform(); } + if (version_compare($oracleMysqlVersion, '5.7.9', '>=')) { return new MySQL57Platform(); } @@ -151,6 +154,7 @@ private function getOracleMysqlVersionNumber(string $versionString) : string '..' ); } + $majorVersion = $versionParts['major']; $minorVersion = $versionParts['minor'] ?? 0; $patchVersion = $versionParts['patch'] ?? null; diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index 916d924980c..e5753fcf76b 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -33,6 +33,7 @@ public function convertException($message, DriverException $exception) case '40001': case '40P01': return new Exception\DeadlockException($message, $exception); + case '0A000': // Foreign key constraint violations during a TRUNCATE operation // are considered "feature not supported" in PostgreSQL. @@ -41,6 +42,7 @@ public function convertException($message, DriverException $exception) } break; + case '23502': return new Exception\NotNullConstraintViolationException($message, $exception); diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php index 88f26ce7def..60cfb046ee6 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php @@ -32,31 +32,41 @@ public function convertException($message, DriverException $exception) case '-307': case '-684': return new Exception\DeadlockException($message, $exception); + case '-210': case '-1175': case '-1281': return new Exception\LockWaitTimeoutException($message, $exception); + case '-100': case '-103': case '-832': return new Exception\ConnectionException($message, $exception); + case '-143': return new Exception\InvalidFieldNameException($message, $exception); + case '-193': case '-196': return new Exception\UniqueConstraintViolationException($message, $exception); + case '-194': case '-198': return new Exception\ForeignKeyConstraintViolationException($message, $exception); + case '-144': return new Exception\NonUniqueFieldNameException($message, $exception); + case '-184': case '-195': return new Exception\NotNullConstraintViolationException($message, $exception); + case '-131': return new Exception\SyntaxErrorException($message, $exception); + case '-110': return new Exception\TableExistsException($message, $exception); + case '-141': case '-1041': return new Exception\TableNotFoundException($message, $exception); @@ -90,10 +100,13 @@ public function createDatabasePlatformForVersion($version) switch (true) { case version_compare($version, '16', '>='): return new SQLAnywhere16Platform(); + case version_compare($version, '12', '>='): return new SQLAnywhere12Platform(); + case version_compare($version, '11', '>='): return new SQLAnywhere11Platform(); + default: return new SQLAnywherePlatform(); } diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php index f03fa6a20c3..841ea4c9c61 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php @@ -6,8 +6,6 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; use stdClass; -use const DB2_AUTOCOMMIT_OFF; -use const DB2_AUTOCOMMIT_ON; use function assert; use function db2_autocommit; use function db2_commit; @@ -25,6 +23,8 @@ use function db2_stmt_errormsg; use function func_get_args; use function is_bool; +use const DB2_AUTOCOMMIT_OFF; +use const DB2_AUTOCOMMIT_ON; class DB2Connection implements Connection, ServerInfoAwareConnection { @@ -61,8 +61,8 @@ public function __construct(array $params, $username, $password, $driverOptions */ public function getServerVersion() { - /** @var stdClass $serverInfo */ $serverInfo = db2_server_info($this->conn); + assert($serverInfo instanceof stdClass); return $serverInfo->DBMS_VER; } diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index af6e852bc43..6222facf1e4 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -12,12 +12,6 @@ use ReflectionObject; use ReflectionProperty; use stdClass; -use const CASE_LOWER; -use const DB2_BINARY; -use const DB2_CHAR; -use const DB2_LONG; -use const DB2_PARAM_FILE; -use const DB2_PARAM_IN; use function array_change_key_case; use function db2_bind_param; use function db2_execute; @@ -45,6 +39,12 @@ use function stream_get_meta_data; use function strtolower; use function tmpfile; +use const CASE_LOWER; +use const DB2_BINARY; +use const DB2_CHAR; +use const DB2_LONG; +use const DB2_PARAM_FILE; +use const DB2_PARAM_IN; class DB2Statement implements IteratorAggregate, Statement { @@ -309,12 +309,16 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n while (($row = $this->fetch(...func_get_args())) !== false) { $rows[] = $row; } + break; + case FetchMode::COLUMN: while (($row = $this->fetchColumn()) !== false) { $rows[] = $row; } + break; + default: while (($row = $this->fetch($fetchMode)) !== false) { $rows[] = $row; diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index 68096ba80e0..f1b687aaec6 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -7,12 +7,6 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; use mysqli; -use const MYSQLI_INIT_COMMAND; -use const MYSQLI_OPT_CONNECT_TIMEOUT; -use const MYSQLI_OPT_LOCAL_INFILE; -use const MYSQLI_READ_DEFAULT_FILE; -use const MYSQLI_READ_DEFAULT_GROUP; -use const MYSQLI_SERVER_PUBLIC_KEY; use function defined; use function floor; use function func_get_args; @@ -26,6 +20,12 @@ 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; +use const MYSQLI_READ_DEFAULT_FILE; +use const MYSQLI_READ_DEFAULT_GROUP; +use const MYSQLI_SERVER_PUBLIC_KEY; class MysqliConnection implements Connection, PingableConnection, ServerInfoAwareConnection { diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index b1edcf4eed3..86e846af702 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -224,6 +224,7 @@ private function bindTypedParameters() : void if (get_resource_type($value) !== 'stream') { throw new InvalidArgumentException('Resources passed with the LARGE_OBJECT parameter type must be stream resources.'); } + $streams[$parameter] = $value; $values[$parameter] = null; continue; diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index b67ef9210a5..ae1b3599642 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -6,8 +6,6 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; use UnexpectedValueException; -use const OCI_COMMIT_ON_SUCCESS; -use const OCI_NO_AUTO_COMMIT; use function addcslashes; use function func_get_args; use function is_float; @@ -21,6 +19,8 @@ use function preg_match; use function sprintf; use function str_replace; +use const OCI_COMMIT_ON_SUCCESS; +use const OCI_NO_AUTO_COMMIT; /** * OCI8 implementation of the Connection interface. @@ -129,6 +129,7 @@ public function quote($value, $type = ParameterType::STRING) if (is_int($value) || is_float($value)) { return $value; } + $value = str_replace("'", "''", $value); return "'" . addcslashes($value, "\000\n\r\\\032") . "'"; @@ -193,6 +194,7 @@ public function commit() if (! oci_commit($this->dbh)) { throw OCI8Exception::fromErrorInfo($this->errorInfo()); } + $this->executeMode = OCI_COMMIT_ON_SUCCESS; return true; @@ -206,6 +208,7 @@ public function rollBack() if (! oci_rollback($this->dbh)) { throw OCI8Exception::fromErrorInfo($this->errorInfo()); } + $this->executeMode = OCI_COMMIT_ON_SUCCESS; return true; diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php index 42283e08a57..83b078097a4 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php @@ -12,7 +12,7 @@ class OCI8Exception extends AbstractDriverException /** * @param mixed[]|false $error * - * @return \Doctrine\DBAL\Driver\OCI8\OCI8Exception + * @return OCI8Exception */ public static function fromErrorInfo($error) { diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index 2f8b9323817..74607ddec76 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -9,19 +9,6 @@ use InvalidArgumentException; use IteratorAggregate; use PDO; -use const OCI_ASSOC; -use const OCI_B_BIN; -use const OCI_B_BLOB; -use const OCI_BOTH; -use const OCI_D_LOB; -use const OCI_FETCHSTATEMENT_BY_COLUMN; -use const OCI_FETCHSTATEMENT_BY_ROW; -use const OCI_NUM; -use const OCI_RETURN_LOBS; -use const OCI_RETURN_NULLS; -use const OCI_TEMP_BLOB; -use const PREG_OFFSET_CAPTURE; -use const SQLT_CHR; use function array_key_exists; use function assert; use function count; @@ -43,6 +30,19 @@ use function preg_quote; use function sprintf; use function substr; +use const OCI_ASSOC; +use const OCI_B_BIN; +use const OCI_B_BLOB; +use const OCI_BOTH; +use const OCI_D_LOB; +use const OCI_FETCHSTATEMENT_BY_COLUMN; +use const OCI_FETCHSTATEMENT_BY_ROW; +use const OCI_NUM; +use const OCI_RETURN_LOBS; +use const OCI_RETURN_NULLS; +use const OCI_TEMP_BLOB; +use const PREG_OFFSET_CAPTURE; +use const SQLT_CHR; /** * The OCI8 implementation of the Statement interface. diff --git a/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php b/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php index 12fb14ef5cb..7ea26d4d4c1 100644 --- a/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php @@ -36,9 +36,11 @@ private function _constructPdoDsn(array $params) if (isset($params['host'])) { $dsn .= 'HOSTNAME=' . $params['host'] . ';'; } + if (isset($params['port'])) { $dsn .= 'PORT=' . $params['port'] . ';'; } + $dsn .= 'PROTOCOL=TCPIP;'; if (isset($params['dbname'])) { $dsn .= 'DATABASE=' . $params['dbname'] . ';'; diff --git a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php index dcd4ff51895..3058febd05a 100644 --- a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php @@ -44,15 +44,19 @@ protected function constructPdoDsn(array $params) if (isset($params['host']) && $params['host'] !== '') { $dsn .= 'host=' . $params['host'] . ';'; } + if (isset($params['port'])) { $dsn .= 'port=' . $params['port'] . ';'; } + if (isset($params['dbname'])) { $dsn .= 'dbname=' . $params['dbname'] . ';'; } + if (isset($params['unix_socket'])) { $dsn .= 'unix_socket=' . $params['unix_socket'] . ';'; } + if (isset($params['charset'])) { $dsn .= 'charset=' . $params['charset'] . ';'; } diff --git a/lib/Doctrine/DBAL/Driver/PDOStatement.php b/lib/Doctrine/DBAL/Driver/PDOStatement.php index 26f0f2e7819..c7db7d4eb87 100644 --- a/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -5,13 +5,13 @@ use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; use PDO; -use const E_USER_DEPRECATED; 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; /** * The PDO implementation of the Statement interface. diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php index ff1759aba26..bac9abf7850 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php @@ -11,7 +11,6 @@ use ReflectionClass; use ReflectionObject; use stdClass; -use const SASQL_BOTH; use function array_key_exists; use function func_get_args; use function func_num_args; @@ -35,6 +34,7 @@ use function sasql_stmt_reset; use function sasql_stmt_result_metadata; use function sprintf; +use const SASQL_BOTH; /** * SAP SQL Anywhere implementation of the Statement interface. @@ -258,12 +258,14 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n while (($row = $this->fetch(...func_get_args())) !== false) { $rows[] = $row; } + break; case FetchMode::COLUMN: while (($row = $this->fetchColumn()) !== false) { $rows[] = $row; } + break; default: diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php index 71b450d98e0..ca7ce0c9ad3 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php @@ -5,7 +5,6 @@ use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; -use const SQLSRV_ERR_ERRORS; use function func_get_args; use function is_float; use function is_int; @@ -20,6 +19,7 @@ use function sqlsrv_rows_affected; use function sqlsrv_server_info; use function str_replace; +use const SQLSRV_ERR_ERRORS; /** * SQL Server implementation for the Connection interface. diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php index 5618ed73560..4dfe548f87a 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php @@ -3,9 +3,9 @@ namespace Doctrine\DBAL\Driver\SQLSrv; use Doctrine\DBAL\Driver\AbstractDriverException; -use const SQLSRV_ERR_ERRORS; use function rtrim; use function sqlsrv_errors; +use const SQLSRV_ERR_ERRORS; /** * @psalm-immutable @@ -15,7 +15,7 @@ class SQLSrvException extends AbstractDriverException /** * Helper method to turn sql server errors into exception. * - * @return \Doctrine\DBAL\Driver\SQLSrv\SQLSrvException + * @return SQLSrvException */ public static function fromSqlSrvErrors() { diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index 1e1c0a2a7f2..e728575fa4f 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -8,12 +8,6 @@ use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; -use const SQLSRV_ENC_BINARY; -use const SQLSRV_ERR_ERRORS; -use const SQLSRV_FETCH_ASSOC; -use const SQLSRV_FETCH_BOTH; -use const SQLSRV_FETCH_NUMERIC; -use const SQLSRV_PARAM_IN; use function array_key_exists; use function count; use function func_get_args; @@ -34,6 +28,12 @@ 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; +use const SQLSRV_FETCH_BOTH; +use const SQLSRV_FETCH_NUMERIC; +use const SQLSRV_PARAM_IN; /** * SQL Server Statement. @@ -387,12 +387,14 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n while (($row = $this->fetch(...func_get_args())) !== false) { $rows[] = $row; } + break; case FetchMode::COLUMN: while (($row = $this->fetchColumn()) !== false) { $rows[] = $row; } + break; default: diff --git a/lib/Doctrine/DBAL/DriverManager.php b/lib/Doctrine/DBAL/DriverManager.php index 31fc8ea12f9..95cb27c29d7 100644 --- a/lib/Doctrine/DBAL/DriverManager.php +++ b/lib/Doctrine/DBAL/DriverManager.php @@ -130,6 +130,7 @@ public static function getConnection( if (! $config) { $config = new Configuration(); } + if (! $eventManager) { $eventManager = new EventManager(); } @@ -273,12 +274,15 @@ private static function parseDatabaseUrl(array $params) : array if (isset($url['host'])) { $params['host'] = $url['host']; } + if (isset($url['port'])) { $params['port'] = $url['port']; } + if (isset($url['user'])) { $params['user'] = $url['user']; } + if (isset($url['pass'])) { $params['password'] = $url['pass']; } diff --git a/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php b/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php index 9e374856078..abcf42a5ac9 100644 --- a/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php +++ b/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php @@ -5,11 +5,11 @@ use Doctrine\Common\EventSubscriber; use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Events; -use const CASE_UPPER; use function array_change_key_case; use function array_merge; use function count; use function implode; +use const CASE_UPPER; /** * Should be used when Oracle Server default environment does not match the Doctrine requirements. @@ -57,6 +57,7 @@ public function postConnect(ConnectionEventArgs $args) $vars[] = $option . " = '" . $value . "'"; } } + $sql = 'ALTER SESSION SET ' . implode(' ', $vars); $args->getConnection()->executeUpdate($sql); } diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php index ff86a93d632..1aee06f8e27 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php @@ -62,7 +62,7 @@ public function getPlatform() * * @param string|string[] $sql * - * @return \Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs + * @return SchemaAlterTableAddColumnEventArgs */ public function addSql($sql) { diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php index 354eb68bc6b..e806c9a6cb1 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php @@ -62,7 +62,7 @@ public function getPlatform() * * @param string|string[] $sql * - * @return \Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs + * @return SchemaAlterTableChangeColumnEventArgs */ public function addSql($sql) { diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php index b10bc7a60a2..505d2a3600a 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php @@ -49,7 +49,7 @@ public function getPlatform() * * @param string|string[] $sql * - * @return \Doctrine\DBAL\Event\SchemaAlterTableEventArgs + * @return SchemaAlterTableEventArgs */ public function addSql($sql) { diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php index 6e3d6a757c7..7a2fe596a46 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php @@ -62,7 +62,7 @@ public function getPlatform() * * @param string|string[] $sql * - * @return \Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs + * @return SchemaAlterTableRemoveColumnEventArgs */ public function addSql($sql) { diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php index 27e2825314c..3f65e62ecab 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php @@ -77,7 +77,7 @@ public function getPlatform() * * @param string|string[] $sql * - * @return \Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs + * @return SchemaAlterTableRenameColumnEventArgs */ public function addSql($sql) { diff --git a/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php index 80d9abe73a5..efde1169806 100644 --- a/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php @@ -47,7 +47,7 @@ public function __construct(array $tableColumn, $table, $database, Connection $c * Allows to clear the column which means the column will be excluded from * tables column list. * - * @return \Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs + * @return SchemaColumnDefinitionEventArgs */ public function setColumn(?Column $column = null) { diff --git a/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php index 6d78aae5c11..d24ff439595 100644 --- a/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php @@ -62,7 +62,7 @@ public function getPlatform() * * @param string|string[] $sql * - * @return \Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs + * @return SchemaCreateTableColumnEventArgs */ public function addSql($sql) { diff --git a/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php index 927a4e4efe1..ee4061b4543 100644 --- a/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php @@ -77,7 +77,7 @@ public function getPlatform() * * @param string|string[] $sql * - * @return \Doctrine\DBAL\Event\SchemaCreateTableEventArgs + * @return SchemaCreateTableEventArgs */ public function addSql($sql) { diff --git a/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php index 387049791d2..1e6f8662025 100644 --- a/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php @@ -50,7 +50,7 @@ public function getPlatform() /** * @param string $sql * - * @return \Doctrine\DBAL\Event\SchemaDropTableEventArgs + * @return SchemaDropTableEventArgs */ public function setSql($sql) { diff --git a/lib/Doctrine/DBAL/Event/SchemaEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaEventArgs.php index 0db0689c5ad..df2bdae09f4 100644 --- a/lib/Doctrine/DBAL/Event/SchemaEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaEventArgs.php @@ -13,7 +13,7 @@ class SchemaEventArgs extends EventArgs private $preventDefault = false; /** - * @return \Doctrine\DBAL\Event\SchemaEventArgs + * @return SchemaEventArgs */ public function preventDefault() { diff --git a/lib/Doctrine/DBAL/Id/TableGenerator.php b/lib/Doctrine/DBAL/Id/TableGenerator.php index 62ad0d35c48..97bc70282f3 100644 --- a/lib/Doctrine/DBAL/Id/TableGenerator.php +++ b/lib/Doctrine/DBAL/Id/TableGenerator.php @@ -8,10 +8,10 @@ use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\LockMode; use Throwable; -use const CASE_LOWER; use function array_change_key_case; use function assert; use function is_int; +use const CASE_LOWER; /** * Table ID Generator for those poor languages that are missing sequences. @@ -72,6 +72,7 @@ public function __construct(Connection $conn, $generatorTableName = 'sequences') if ($params['driver'] === 'pdo_sqlite') { throw new DBALException('Cannot use TableGenerator with SQLite.'); } + $this->conn = DriverManager::getConnection($params, $conn->getConfiguration(), $conn->getEventManager()); $this->generatorTableName = $generatorTableName; } @@ -141,6 +142,7 @@ public function nextValue($sequenceName) $this->conn->commit(); } catch (Throwable $e) { $this->conn->rollBack(); + throw new DBALException('Error occurred while generating ID with TableGenerator, aborted generation: ' . $e->getMessage(), 0, $e); } diff --git a/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php b/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php index 657abb4d378..c722797dd8b 100644 --- a/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php +++ b/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php @@ -2,8 +2,8 @@ namespace Doctrine\DBAL\Logging; -use const PHP_EOL; use function var_dump; +use const PHP_EOL; /** * A SQL logger that logs to the standard output using echo/var_dump. diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index e76bc003da7..53e097d36eb 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -28,7 +28,6 @@ use Doctrine\DBAL\Types\Type; use InvalidArgumentException; use UnexpectedValueException; -use const E_USER_DEPRECATED; use function addcslashes; use function array_map; use function array_merge; @@ -55,6 +54,7 @@ use function strtolower; use function strtoupper; use function trigger_error; +use const E_USER_DEPRECATED; /** * Base class for all DatabasePlatforms. The DatabasePlatforms are the central @@ -1552,7 +1552,6 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE if (($createFlags&self::CREATE_INDEXES) > 0) { foreach ($table->getIndexes() as $index) { - /** @var $index Index */ if ($index->isPrimary()) { $options['primary'] = $index->getQuotedColumns($this); $options['primary_index'] = $index; @@ -1614,6 +1613,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE if ($table->hasOption('comment')) { $sql[] = $this->getCommentOnTableSQL($tableName, $table->getOption('comment')); } + foreach ($table->getColumns() as $column) { $comment = $this->getColumnComment($column); @@ -1712,6 +1712,7 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options if (! empty($check)) { $query .= ', ' . $check; } + $query .= ')'; $sql[] = $query; @@ -1793,6 +1794,7 @@ public function getCreateConstraintSQL(Constraint $constraint, $table) $referencesClause = ' REFERENCES ' . $constraint->getQuotedForeignTableName($this) . ' (' . implode(', ', $constraint->getQuotedForeignColumns($this)) . ')'; } + $query .= ' ' . $columnList . $referencesClause; return $query; @@ -1812,6 +1814,7 @@ public function getCreateIndexSQL(Index $index, $table) if ($table instanceof Table) { $table = $table->getQuotedName($this); } + $name = $index->getQuotedName($this); $columns = $index->getColumns(); @@ -2080,6 +2083,7 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) foreach ($diff->removedForeignKeys as $foreignKey) { $sql[] = $this->getDropForeignKeySQL($foreignKey, $tableName); } + foreach ($diff->changedForeignKeys as $foreignKey) { $sql[] = $this->getDropForeignKeySQL($foreignKey, $tableName); } @@ -2088,6 +2092,7 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) foreach ($diff->removedIndexes as $index) { $sql[] = $this->getDropIndexSQL($index, $tableName); } + foreach ($diff->changedIndexes as $index) { $sql[] = $this->getDropIndexSQL($index, $tableName); } @@ -2515,6 +2520,7 @@ public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey if ($this->supportsForeignKeyOnUpdate() && $foreignKey->hasOption('onUpdate')) { $query .= ' ON UPDATE ' . $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onUpdate')); } + if ($foreignKey->hasOption('onDelete')) { $query .= ' ON DELETE ' . $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onDelete')); } @@ -2541,6 +2547,7 @@ public function getForeignKeyReferentialActionSQL($action) case 'RESTRICT': case 'SET DEFAULT': return $upper; + default: throw new InvalidArgumentException('Invalid foreign key action: ' . $upper); } @@ -2560,14 +2567,17 @@ public function getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey if (strlen($foreignKey->getName())) { $sql .= 'CONSTRAINT ' . $foreignKey->getQuotedName($this) . ' '; } + $sql .= 'FOREIGN KEY ('; if (count($foreignKey->getLocalColumns()) === 0) { throw new InvalidArgumentException("Incomplete definition. 'local' required."); } + if (count($foreignKey->getForeignColumns()) === 0) { throw new InvalidArgumentException("Incomplete definition. 'foreign' required."); } + if (strlen($foreignKey->getForeignTableName()) === 0) { throw new InvalidArgumentException("Incomplete definition. 'foreignTable' required."); } @@ -2744,12 +2754,16 @@ protected function _getTransactionIsolationLevelSQL($level) switch ($level) { case TransactionIsolationLevel::READ_UNCOMMITTED: return 'READ UNCOMMITTED'; + case TransactionIsolationLevel::READ_COMMITTED: return 'READ COMMITTED'; + case TransactionIsolationLevel::REPEATABLE_READ: return 'REPEATABLE READ'; + case TransactionIsolationLevel::SERIALIZABLE: return 'SERIALIZABLE'; + default: throw new InvalidArgumentException('Invalid isolation level:' . $level); } diff --git a/lib/Doctrine/DBAL/Platforms/DB2Platform.php b/lib/Doctrine/DBAL/Platforms/DB2Platform.php index 2dbf7f5df86..6f3931ec84c 100644 --- a/lib/Doctrine/DBAL/Platforms/DB2Platform.php +++ b/lib/Doctrine/DBAL/Platforms/DB2Platform.php @@ -22,9 +22,6 @@ class DB2Platform extends AbstractPlatform { - /** - * {@inheritdoc} - */ public function getCharMaxLength() : int { return 254; @@ -495,6 +492,7 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options if (isset($options['indexes'])) { $indexes = $options['indexes']; } + $options['indexes'] = []; $sqls = parent::_getCreateTableSQL($tableName, $columns, $options); @@ -708,21 +706,23 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) foreach ($diff->removedIndexes as $remKey => $remIndex) { foreach ($diff->addedIndexes as $addKey => $addIndex) { - if ($remIndex->getColumns() === $addIndex->getColumns()) { - if ($remIndex->isPrimary()) { - $sql[] = 'ALTER TABLE ' . $table . ' DROP PRIMARY KEY'; - } elseif ($remIndex->isUnique()) { - $sql[] = 'ALTER TABLE ' . $table . ' DROP UNIQUE ' . $remIndex->getQuotedName($this); - } else { - $sql[] = $this->getDropIndexSQL($remIndex, $table); - } + if ($remIndex->getColumns() !== $addIndex->getColumns()) { + continue; + } - $sql[] = $this->getCreateIndexSQL($addIndex, $table); + if ($remIndex->isPrimary()) { + $sql[] = 'ALTER TABLE ' . $table . ' DROP PRIMARY KEY'; + } elseif ($remIndex->isUnique()) { + $sql[] = 'ALTER TABLE ' . $table . ' DROP UNIQUE ' . $remIndex->getQuotedName($this); + } else { + $sql[] = $this->getDropIndexSQL($remIndex, $table); + } - unset($diff->removedIndexes[$remKey], $diff->addedIndexes[$addKey]); + $sql[] = $this->getCreateIndexSQL($addIndex, $table); - break; - } + unset($diff->removedIndexes[$remKey], $diff->addedIndexes[$addKey]); + + break; } } diff --git a/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php b/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php index 60aef82cebe..f796a48c786 100644 --- a/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php @@ -550,6 +550,7 @@ public function getAlterTableSQL(TableDiff $diff) if (count($queryParts) > 0) { $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . implode(', ', $queryParts); } + $sql = array_merge( $this->getPreAlterTableIndexForeignKeySQL($diff), $sql, diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php index 1b31c7682e7..0efd5f9a7fc 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php @@ -9,9 +9,6 @@ */ final class MariaDb102Keywords extends MySQLKeywords { - /** - * {@inheritdoc} - */ public function getName() : string { return 'MariaDb102'; diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php index 3402db1902c..07d87efba30 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php @@ -9,9 +9,6 @@ */ class PostgreSQL100Keywords extends PostgreSQL94Keywords { - /** - * {@inheritdoc} - */ public function getName() : string { return 'PostgreSQL100'; diff --git a/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php b/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php index 6c57082c586..2fff4e87ee7 100644 --- a/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php +++ b/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php @@ -21,17 +21,11 @@ public function getJsonTypeDeclarationSQL(array $field) : string return 'LONGTEXT'; } - /** - * {@inheritdoc} - */ protected function getReservedKeywordsClass() : string { return Keywords\MariaDb102Keywords::class; } - /** - * {@inheritdoc} - */ protected function initializeDoctrineTypeMappings() : void { parent::initializeDoctrineTypeMappings(); diff --git a/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php b/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php index 409f6eef86a..6c8defc7e07 100644 --- a/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php @@ -635,6 +635,7 @@ public function getAlterTableSQL(TableDiff $diff) if (count($queryParts) > 0) { $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . implode(', ', $queryParts); } + $sql = array_merge( $this->getPreAlterTableIndexForeignKeySQL($diff), $sql, @@ -661,25 +662,27 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) $sql = array_merge($sql, $this->getPreAlterTableAlterPrimaryKeySQL($diff, $remIndex)); foreach ($diff->addedIndexes as $addKey => $addIndex) { - if ($remIndex->getColumns() === $addIndex->getColumns()) { - $indexClause = 'INDEX ' . $addIndex->getName(); + if ($remIndex->getColumns() !== $addIndex->getColumns()) { + continue; + } - if ($addIndex->isPrimary()) { - $indexClause = 'PRIMARY KEY'; - } elseif ($addIndex->isUnique()) { - $indexClause = 'UNIQUE INDEX ' . $addIndex->getName(); - } + $indexClause = 'INDEX ' . $addIndex->getName(); - $query = 'ALTER TABLE ' . $table . ' DROP INDEX ' . $remIndex->getName() . ', '; - $query .= 'ADD ' . $indexClause; - $query .= ' (' . $this->getIndexFieldDeclarationListSQL($addIndex) . ')'; + if ($addIndex->isPrimary()) { + $indexClause = 'PRIMARY KEY'; + } elseif ($addIndex->isUnique()) { + $indexClause = 'UNIQUE INDEX ' . $addIndex->getName(); + } - $sql[] = $query; + $query = 'ALTER TABLE ' . $table . ' DROP INDEX ' . $remIndex->getName() . ', '; + $query .= 'ADD ' . $indexClause; + $query .= ' (' . $this->getIndexFieldDeclarationListSQL($addIndex) . ')'; - unset($diff->removedIndexes[$remKey], $diff->addedIndexes[$addKey]); + $sql[] = $query; - break; - } + unset($diff->removedIndexes[$remKey], $diff->addedIndexes[$addKey]); + + break; } } @@ -985,6 +988,7 @@ public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey if ($foreignKey->hasOption('match')) { $query .= ' MATCH ' . $foreignKey->getOption('match'); } + $query .= parent::getAdvancedForeignKeyOptionsSQL($foreignKey); return $query; @@ -1180,9 +1184,6 @@ public function getDefaultTransactionIsolationLevel() return TransactionIsolationLevel::REPEATABLE_READ; } - /** - * {@inheritdoc} - */ public function supportsColumnLengthIndexes() : bool { return true; diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index a4bf28c9670..1c21e219010 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -242,11 +242,14 @@ protected function _getTransactionIsolationLevelSQL($level) switch ($level) { case TransactionIsolationLevel::READ_UNCOMMITTED: return 'READ UNCOMMITTED'; + case TransactionIsolationLevel::READ_COMMITTED: return 'READ COMMITTED'; + case TransactionIsolationLevel::REPEATABLE_READ: case TransactionIsolationLevel::SERIALIZABLE: return 'SERIALIZABLE'; + default: return parent::_getTransactionIsolationLevelSQL($level); } diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php b/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php index cfb079f94dd..957f9f42458 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php @@ -11,14 +11,14 @@ */ class PostgreSQL100Platform extends PostgreSQL94Platform { - /** - * {@inheritdoc} - */ protected function getReservedKeywordsClass() : string { return PostgreSQL100Keywords::class; } + /** + * {@inheritDoc} + */ public function getListSequencesSQL($database) : string { return 'SELECT sequence_name AS relname, diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php index 6237898e2e8..7c62d5f8c66 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -531,7 +531,6 @@ public function getAlterTableSQL(TableDiff $diff) } foreach ($diff->changedColumns as $columnDiff) { - /** @var $columnDiff \Doctrine\DBAL\Schema\ColumnDiff */ if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) { continue; } diff --git a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php index 21850d2ba45..e9cb363c6b8 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php @@ -17,6 +17,7 @@ use function array_merge; use function array_unique; use function array_values; +use function assert; use function count; use function explode; use function func_get_args; @@ -636,6 +637,7 @@ public function getForeignKeyMatchClauseSQL($type) case self::FOREIGN_KEY_MATCH_FULL_UNIQUE: return 'UNIQUE FULL'; + default: throw new InvalidArgumentException('Invalid foreign key match type: ' . $type); } @@ -1127,8 +1129,10 @@ public function getTrimExpression($str, $pos = TrimMode::UNSPECIFIED, $char = fa switch ($pos) { case TrimMode::LEADING: return $this->getLtrimExpression($str); + case TrimMode::TRAILING: return $this->getRtrimExpression($str); + default: return 'TRIM(' . $str . ')'; } @@ -1139,8 +1143,10 @@ public function getTrimExpression($str, $pos = TrimMode::UNSPECIFIED, $char = fa switch ($pos) { case TrimMode::LEADING: return 'SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))'; + case TrimMode::TRAILING: return 'REVERSE(SUBSTR(REVERSE(' . $str . '), PATINDEX(' . $pattern . ', REVERSE(' . $str . '))))'; + default: return 'REVERSE(SUBSTR(REVERSE(SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))), ' . 'PATINDEX(' . $pattern . ', REVERSE(SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))))))'; @@ -1252,8 +1258,8 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options } if (! empty($options['indexes'])) { - /** @var Index $index */ foreach ((array) $options['indexes'] as $index) { + assert($index instanceof Index); $indexSql[] = $this->getCreateIndexSQL($index, $tableName); } } @@ -1294,12 +1300,16 @@ protected function _getTransactionIsolationLevelSQL($level) switch ($level) { case TransactionIsolationLevel::READ_UNCOMMITTED: return '0'; + case TransactionIsolationLevel::READ_COMMITTED: return '1'; + case TransactionIsolationLevel::REPEATABLE_READ: return '2'; + case TransactionIsolationLevel::SERIALIZABLE: return '3'; + default: throw new InvalidArgumentException('Invalid isolation level:' . $level); } diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php index 009a37d33b0..0e1250542b6 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php @@ -3,10 +3,10 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\DBAL\Schema\Sequence; -use const PREG_OFFSET_CAPTURE; use function preg_match; use function preg_match_all; use function substr_count; +use const PREG_OFFSET_CAPTURE; /** * Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2012 version. @@ -105,7 +105,7 @@ protected function doModifyLimitQuery($query, $limit, $offset = null) $matchesCount = preg_match_all('/[\\s]+order\\s+by\\s/im', $query, $matches, PREG_OFFSET_CAPTURE); $orderByPos = false; if ($matchesCount > 0) { - $orderByPos = $matches[0][($matchesCount - 1)][1]; + $orderByPos = $matches[0][$matchesCount - 1][1]; } if ($orderByPos === false diff --git a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php index 6a7130bd674..322fe1ec621 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -285,6 +285,7 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options if (isset($options['primary_index']) && $options['primary_index']->hasFlag('nonclustered')) { $flags = ' NONCLUSTERED'; } + $columnListSql .= ', PRIMARY KEY' . $flags . ' (' . implode(', ', array_unique(array_values($options['primary']))) . ')'; } @@ -294,6 +295,7 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options if (! empty($check)) { $query .= ', ' . $check; } + $query .= ')'; $sql = [$query]; @@ -1669,8 +1671,8 @@ protected function getCommentOnTableSQL(string $tableName, ?string $comment) : s { return sprintf( <<<'SQL' -EXEC sys.sp_addextendedproperty @name=N'MS_Description', - @value=N%s, @level0type=N'SCHEMA', @level0name=N'dbo', +EXEC sys.sp_addextendedproperty @name=N'MS_Description', + @value=N%s, @level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N%s SQL , diff --git a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php index e46965e3b32..3f8746cc14a 100644 --- a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php @@ -64,8 +64,10 @@ public function getNowExpression($type = 'timestamp') switch ($type) { case 'time': return 'time(\'now\')'; + case 'date': return 'date(\'now\')'; + case 'timestamp': default: return 'datetime(\'now\')'; @@ -77,7 +79,7 @@ public function getNowExpression($type = 'timestamp') */ public function getTrimExpression($str, $pos = TrimMode::UNSPECIFIED, $char = false) { - $trimChar = $char !== false ? (', ' . $char) : ''; + $trimChar = $char !== false ? ', ' . $char : ''; switch ($pos) { case TrimMode::LEADING: @@ -131,26 +133,25 @@ protected function getDateArithmeticIntervalExpression($date, $operator, $interv case DateIntervalUnit::MINUTE: case DateIntervalUnit::HOUR: return 'DATETIME(' . $date . ",'" . $operator . $interval . ' ' . $unit . "')"; + } - default: - switch ($unit) { - case DateIntervalUnit::WEEK: - $interval *= 7; - $unit = DateIntervalUnit::DAY; - break; - - case DateIntervalUnit::QUARTER: - $interval *= 3; - $unit = DateIntervalUnit::MONTH; - break; - } + switch ($unit) { + case DateIntervalUnit::WEEK: + $interval *= 7; + $unit = DateIntervalUnit::DAY; + break; - if (! is_numeric($interval)) { - $interval = "' || " . $interval . " || '"; - } + case DateIntervalUnit::QUARTER: + $interval *= 3; + $unit = DateIntervalUnit::MONTH; + break; + } - return 'DATE(' . $date . ",'" . $operator . $interval . ' ' . $unit . "')"; + if (! is_numeric($interval)) { + $interval = "' || " . $interval . " || '"; } + + return 'DATE(' . $date . ",'" . $operator . $interval . ' ' . $unit . "')"; } /** @@ -169,10 +170,12 @@ protected function _getTransactionIsolationLevelSQL($level) switch ($level) { case TransactionIsolationLevel::READ_UNCOMMITTED: return '0'; + case TransactionIsolationLevel::READ_COMMITTED: case TransactionIsolationLevel::REPEATABLE_READ: case TransactionIsolationLevel::SERIALIZABLE: return '1'; + default: return parent::_getTransactionIsolationLevelSQL($level); } @@ -773,9 +776,6 @@ public function supportsForeignKeyConstraints() return true; } - /** - * {@inheritDoc} - */ public function supportsCreateDropForeignKeyConstraints() : bool { return false; diff --git a/lib/Doctrine/DBAL/Portability/Connection.php b/lib/Doctrine/DBAL/Portability/Connection.php index 7b4af8a8799..cb1bd2f062b 100644 --- a/lib/Doctrine/DBAL/Portability/Connection.php +++ b/lib/Doctrine/DBAL/Portability/Connection.php @@ -6,9 +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; -use function func_get_args; /** * Portability wrapper for a Connection. @@ -62,6 +62,7 @@ public function connect() } else { $params['portability'] &= self::PORTABILITY_OTHERVENDORS; } + $this->portability = $params['portability']; } diff --git a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php index 443d71bc37e..96f94a36e66 100644 --- a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php +++ b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php @@ -51,7 +51,7 @@ public function __construct($type, array $parts = []) * * @param self[]|string[] $parts * - * @return \Doctrine\DBAL\Query\Expression\CompositeExpression + * @return CompositeExpression */ public function addMultiple(array $parts = []) { @@ -67,7 +67,7 @@ public function addMultiple(array $parts = []) * * @param mixed $part * - * @return \Doctrine\DBAL\Query\Expression\CompositeExpression + * @return CompositeExpression */ public function add($part) { diff --git a/lib/Doctrine/DBAL/Query/QueryBuilder.php b/lib/Doctrine/DBAL/Query/QueryBuilder.php index e76ca0e0758..6d1d1ff740b 100644 --- a/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -231,6 +231,7 @@ public function getSQL() case self::INSERT: $sql = $this->getSQLForInsert(); break; + case self::DELETE: $sql = $this->getSQLForDelete(); break; @@ -1274,6 +1275,7 @@ public function createNamedParameter($value, $type = ParameterType::STRING, $pla $this->boundCounter++; $placeHolder = ':dcValue' . $this->boundCounter; } + $this->setParameter(substr($placeHolder, 1), $value, $type); return $placeHolder; @@ -1326,11 +1328,13 @@ private function getSQLForJoins($fromAlias, array &$knownAliases) if (array_key_exists($join['joinAlias'], $knownAliases)) { throw QueryException::nonUniqueAlias($join['joinAlias'], array_keys($knownAliases)); } + $sql .= ' ' . strtoupper($join['joinType']) . ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias']; if ($join['joinCondition'] !== null) { $sql .= ' ON ' . $join['joinCondition']; } + $knownAliases[$join['joinAlias']] = true; } diff --git a/lib/Doctrine/DBAL/Query/QueryException.php b/lib/Doctrine/DBAL/Query/QueryException.php index 604bcb7565c..a9bb52d8102 100644 --- a/lib/Doctrine/DBAL/Query/QueryException.php +++ b/lib/Doctrine/DBAL/Query/QueryException.php @@ -14,7 +14,7 @@ class QueryException extends DBALException * @param string $alias * @param string[] $registeredAliases * - * @return \Doctrine\DBAL\Query\QueryException + * @return QueryException */ public static function unknownAlias($alias, $registeredAliases) { @@ -27,7 +27,7 @@ public static function unknownAlias($alias, $registeredAliases) * @param string $alias * @param string[] $registeredAliases * - * @return \Doctrine\DBAL\Query\QueryException + * @return QueryException */ public static function nonUniqueAlias($alias, $registeredAliases) { diff --git a/lib/Doctrine/DBAL/SQLParserUtils.php b/lib/Doctrine/DBAL/SQLParserUtils.php index 6329a84e20d..9e3fa0e658f 100644 --- a/lib/Doctrine/DBAL/SQLParserUtils.php +++ b/lib/Doctrine/DBAL/SQLParserUtils.php @@ -2,7 +2,6 @@ namespace Doctrine\DBAL; -use const PREG_OFFSET_CAPTURE; use function array_fill; use function array_fill_keys; use function array_key_exists; @@ -20,6 +19,7 @@ use function strlen; use function strpos; use function substr; +use const PREG_OFFSET_CAPTURE; /** * Utility class that parses sql statements with regard to types and parameters. @@ -195,8 +195,8 @@ public static function expandListParameters($query, $params, $types) $expandStr = $count ? implode(', ', array_fill(0, $count, '?')) : 'NULL'; $query = substr($query, 0, $needlePos) . $expandStr . substr($query, $needlePos + 1); - $paramOffset += ($count - 1); // Grows larger by number of parameters minus the replaced needle. - $queryOffset += (strlen($expandStr) - 1); + $paramOffset += $count - 1; // Grows larger by number of parameters minus the replaced needle. + $queryOffset += strlen($expandStr) - 1; } return [$query, $params, $types]; @@ -214,10 +214,10 @@ public static function expandListParameters($query, $params, $types) if (! isset($arrayPositions[$paramName]) && ! isset($arrayPositions[':' . $paramName])) { $pos += $queryOffset; - $queryOffset -= ($paramLen - 1); + $queryOffset -= $paramLen - 1; $paramsOrd[] = $value; $typesOrd[] = static::extractParam($paramName, $types, false, ParameterType::STRING); - $query = substr($query, 0, $pos) . '?' . substr($query, ($pos + $paramLen)); + $query = substr($query, 0, $pos) . '?' . substr($query, $pos + $paramLen); continue; } @@ -231,8 +231,8 @@ public static function expandListParameters($query, $params, $types) } $pos += $queryOffset; - $queryOffset += (strlen($expandStr) - $paramLen); - $query = substr($query, 0, $pos) . $expandStr . substr($query, ($pos + $paramLen)); + $queryOffset += strlen($expandStr) - $paramLen; + $query = substr($query, 0, $pos) . $expandStr . substr($query, $pos + $paramLen); } return [$query, $paramsOrd, $typesOrd]; diff --git a/lib/Doctrine/DBAL/SQLParserUtilsException.php b/lib/Doctrine/DBAL/SQLParserUtilsException.php index 0857fce8c36..ea8650fc36f 100644 --- a/lib/Doctrine/DBAL/SQLParserUtilsException.php +++ b/lib/Doctrine/DBAL/SQLParserUtilsException.php @@ -14,7 +14,7 @@ class SQLParserUtilsException extends DBALException /** * @param string $paramName * - * @return \Doctrine\DBAL\SQLParserUtilsException + * @return SQLParserUtilsException */ public static function missingParam($paramName) { @@ -24,7 +24,7 @@ public static function missingParam($paramName) /** * @param string $typeName * - * @return \Doctrine\DBAL\SQLParserUtilsException + * @return SQLParserUtilsException */ public static function missingType($typeName) { diff --git a/lib/Doctrine/DBAL/Schema/AbstractAsset.php b/lib/Doctrine/DBAL/Schema/AbstractAsset.php index 45af02f5cc9..b64cb42e208 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractAsset.php +++ b/lib/Doctrine/DBAL/Schema/AbstractAsset.php @@ -48,11 +48,13 @@ protected function _setName($name) $this->_quoted = true; $name = $this->trimQuotes($name); } + if (strpos($name, '.') !== false) { $parts = explode('.', $name); $this->_namespace = $parts[0]; $name = $parts[1]; } + $this->_name = $name; } diff --git a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php index 8e4ffa5f966..b90994e0e64 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -132,6 +132,7 @@ public function listSequences($database = null) if ($database === null) { $database = $this->_conn->getDatabase(); } + $sql = $this->_platform->getListSequencesSQL($database); $sequences = $this->_conn->fetchAll($sql); @@ -273,6 +274,7 @@ public function listTableDetails($tableName) if ($this->_platform->supportsForeignKeyConstraints()) { $foreignKeys = $this->listTableForeignKeys($tableName); } + $indexes = $this->listTableIndexes($tableName); return new Table($tableName, $columns, $indexes, $foreignKeys); @@ -305,6 +307,7 @@ public function listTableForeignKeys($table, $database = null) if ($database === null) { $database = $this->_conn->getDatabase(); } + $sql = $this->_platform->getListTableForeignKeysSQL($table, $database); $tableForeignKeys = $this->_conn->fetchAll($sql); @@ -846,6 +849,7 @@ protected function _getPortableTableIndexesList($tableIndexRows, $tableName = nu if ($tableIndex['primary']) { $keyName = 'primary'; } + $keyName = strtolower($keyName); if (! isset($result[$keyName])) { @@ -1075,9 +1079,11 @@ public function createSchemaConfig() if (! isset($params['defaultTableOptions'])) { $params['defaultTableOptions'] = []; } + if (! isset($params['defaultTableOptions']['charset']) && isset($params['charset'])) { $params['defaultTableOptions']['charset'] = $params['charset']; } + $schemaConfig->setDefaultTableOptions($params['defaultTableOptions']); return $schemaConfig; diff --git a/lib/Doctrine/DBAL/Schema/Column.php b/lib/Doctrine/DBAL/Schema/Column.php index 50724fda77e..81dbef70975 100644 --- a/lib/Doctrine/DBAL/Schema/Column.php +++ b/lib/Doctrine/DBAL/Schema/Column.php @@ -3,12 +3,12 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Types\Type; -use const E_USER_DEPRECATED; use function array_merge; use function is_numeric; use function method_exists; use function sprintf; use function trigger_error; +use const E_USER_DEPRECATED; /** * Object representation of a database column. @@ -86,6 +86,7 @@ public function setOptions(array $options) continue; } + $this->$method($value); } diff --git a/lib/Doctrine/DBAL/Schema/Comparator.php b/lib/Doctrine/DBAL/Schema/Comparator.php index 9ccaa9a1efa..e241cf658c5 100644 --- a/lib/Doctrine/DBAL/Schema/Comparator.php +++ b/lib/Doctrine/DBAL/Schema/Comparator.php @@ -89,6 +89,7 @@ public function compare(Schema $fromSchema, Schema $toSchema) if (! isset($foreignKeysToTable[$foreignTable])) { $foreignKeysToTable[$foreignTable] = []; } + $foreignKeysToTable[$foreignTable][] = $foreignKey; } } @@ -116,6 +117,7 @@ public function compare(Schema $fromSchema, Schema $toSchema) if ($tableName !== strtolower($removedForeignKey->getForeignTableName())) { continue; } + unset($diff->changedTables[$localTableName]->removedForeignKeys[$key]); } } @@ -205,6 +207,7 @@ public function diffTable(Table $table1, Table $table2) $tableDifferences->addedColumns[$columnName] = $column; $changes++; } + /* See if there are any removed fields in table 2 */ foreach ($table1Columns as $columnName => $column) { // See if column is removed in table 2. @@ -241,6 +244,7 @@ public function diffTable(Table $table1, Table $table2) $tableDifferences->addedIndexes[$indexName] = $index; $changes++; } + /* See if there are any removed indexes in table 2 */ foreach ($table1Indexes as $indexName => $index) { // See if index is removed in table 2. @@ -465,6 +469,7 @@ public function diffColumn(Column $column1, Column $column2) if (($properties1['precision'] ?: 10) !== ($properties2['precision'] ?: 10)) { $changedProperties[] = 'precision'; } + if ($properties1['scale'] !== $properties2['scale']) { $changedProperties[] = 'scale'; } diff --git a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php index ae2af864f97..d2d6cef0743 100644 --- a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php @@ -4,14 +4,15 @@ use Doctrine\DBAL\Platforms\DB2Platform; use Doctrine\DBAL\Types\Type; -use const CASE_LOWER; use function array_change_key_case; +use function assert; use function is_resource; use function preg_match; use function str_replace; use function strpos; use function strtolower; use function substr; +use const CASE_LOWER; /** * IBM Db2 Schema Manager. @@ -68,13 +69,16 @@ protected function _getPortableTableColumnDefinition($tableColumn) $length = $tableColumn['length']; $fixed = false; break; + case 'character': $length = $tableColumn['length']; $fixed = true; break; + case 'clob': $length = $tableColumn['length']; break; + case 'decimal': case 'double': case 'real': @@ -213,13 +217,16 @@ protected function _getPortableViewDefinition($view) return new View($view['name'], $sql); } + /** + * {@inheritdoc} + */ public function listTableDetails($tableName) : Table { $table = parent::listTableDetails($tableName); - /** @var DB2Platform $platform */ $platform = $this->_platform; - $sql = $platform->getListTableCommentsSQL($tableName); + assert($platform instanceof DB2Platform); + $sql = $platform->getListTableCommentsSQL($tableName); $tableOptions = $this->_conn->fetchAssoc($sql); diff --git a/lib/Doctrine/DBAL/Schema/Index.php b/lib/Doctrine/DBAL/Schema/Index.php index 7a31c7824bf..07b1c008c19 100644 --- a/lib/Doctrine/DBAL/Schema/Index.php +++ b/lib/Doctrine/DBAL/Schema/Index.php @@ -65,6 +65,7 @@ public function __construct($indexName, array $columns, $isUnique = false, $isPr foreach ($columns as $column) { $this->_addColumn($column); } + foreach ($flags as $flag) { $this->addFlag($flag); } diff --git a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php index 9522faf6a73..15866efae9e 100644 --- a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php @@ -5,7 +5,6 @@ use Doctrine\DBAL\Platforms\MariaDb1027Platform; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Types\Type; -use const CASE_LOWER; use function array_change_key_case; use function array_shift; use function array_values; @@ -17,6 +16,7 @@ use function strtok; use function strtolower; use function strtr; +use const CASE_LOWER; /** * Schema manager for the MySql RDBMS. @@ -82,11 +82,13 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null } else { $v['primary'] = false; } + if (strpos($v['index_type'], 'FULLTEXT') !== false) { $v['flags'] = ['FULLTEXT']; } elseif (strpos($v['index_type'], 'SPATIAL') !== false) { $v['flags'] = ['SPATIAL']; } + $v['length'] = isset($v['sub_part']) ? (int) $v['sub_part'] : null; $tableIndexes[$k] = $v; @@ -138,6 +140,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) case 'binary': $fixed = true; break; + case 'float': case 'double': case 'real': @@ -148,25 +151,33 @@ protected function _getPortableTableColumnDefinition($tableColumn) $scale = $match[2]; $length = null; } + break; + case 'tinytext': $length = MySqlPlatform::LENGTH_LIMIT_TINYTEXT; break; + case 'text': $length = MySqlPlatform::LENGTH_LIMIT_TEXT; break; + case 'mediumtext': $length = MySqlPlatform::LENGTH_LIMIT_MEDIUMTEXT; break; + case 'tinyblob': $length = MySqlPlatform::LENGTH_LIMIT_TINYBLOB; break; + case 'blob': $length = MySqlPlatform::LENGTH_LIMIT_BLOB; break; + case 'mediumblob': $length = MySqlPlatform::LENGTH_LIMIT_MEDIUMBLOB; break; + case 'tinyint': case 'smallint': case 'mediumint': @@ -208,6 +219,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) if (isset($tableColumn['characterset'])) { $column->setPlatformOption('charset', $tableColumn['characterset']); } + if (isset($tableColumn['collation'])) { $column->setPlatformOption('collation', $tableColumn['collation']); } @@ -244,8 +256,10 @@ private function getMariaDb1027ColumnDefault(MariaDb1027Platform $platform, ?str switch ($columnDefault) { case 'current_timestamp()': return $platform->getCurrentTimestampSQL(); + case 'curdate()': return $platform->getCurrentDateSQL(); + case 'curtime()': return $platform->getCurrentTimeSQL(); } @@ -265,6 +279,7 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) if (! isset($value['delete_rule']) || $value['delete_rule'] === 'RESTRICT') { $value['delete_rule'] = null; } + if (! isset($value['update_rule']) || $value['update_rule'] === 'RESTRICT') { $value['update_rule'] = null; } @@ -278,6 +293,7 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) 'onUpdate' => $value['update_rule'], ]; } + $list[$value['constraint_name']]['local'][] = $value['column_name']; $list[$value['constraint_name']]['foreign'][] = $value['referenced_column_name']; } @@ -299,13 +315,16 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) return $result; } + /** + * {@inheritdoc} + */ public function listTableDetails($tableName) { $table = parent::listTableDetails($tableName); - /** @var MySqlPlatform $platform */ $platform = $this->_platform; - $sql = $platform->getListTableMetadataSQL($tableName); + assert($platform instanceof MySqlPlatform); + $sql = $platform->getListTableMetadataSQL($tableName); $tableOptions = $this->_conn->fetchAssoc($sql); diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index dd10cd0f928..e2816caeb00 100644 --- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -7,7 +7,6 @@ use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Types\Type; use Throwable; -use const CASE_LOWER; use function array_change_key_case; use function array_values; use function assert; @@ -18,6 +17,7 @@ use function strtolower; use function strtoupper; use function trim; +use const CASE_LOWER; /** * Oracle Schema Manager. @@ -107,6 +107,7 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null $buffer['primary'] = false; $buffer['non_unique'] = ! $tableIndex['is_unique']; } + $buffer['key_name'] = $keyName; $buffer['column_name'] = $this->getQuotedIdentifierName($tableIndex['column_name']); $indexBuffer[] = $buffer; @@ -176,12 +177,14 @@ protected function _getPortableTableColumnDefinition($tableColumn) } break; + case 'varchar': case 'varchar2': case 'nvarchar2': $length = $tableColumn['char_length']; $fixed = false; break; + case 'char': case 'nchar': $length = $tableColumn['char_length']; @@ -392,13 +395,16 @@ private function killUserSessions($user) } } + /** + * {@inheritdoc} + */ public function listTableDetails($tableName) : Table { $table = parent::listTableDetails($tableName); - /** @var OraclePlatform $platform */ $platform = $this->_platform; - $sql = $platform->getListTableCommentsSQL($tableName); + assert($platform instanceof OraclePlatform); + $sql = $platform->getListTableCommentsSQL($tableName); $tableOptions = $this->_conn->fetchAssoc($sql); diff --git a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php index ffc7c87d453..287a7dac6ba 100644 --- a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php @@ -7,7 +7,6 @@ use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; -use const CASE_LOWER; use function array_change_key_case; use function array_filter; use function array_keys; @@ -25,6 +24,7 @@ use function strpos; use function strtolower; use function trim; +use const CASE_LOWER; /** * PostgreSQL Schema Manager. @@ -141,6 +141,7 @@ protected function _getPortableTableForeignKeyDefinition($tableForeignKey) if (preg_match('(ON UPDATE ([a-zA-Z0-9]+( (NULL|ACTION|DEFAULT))?))', $tableForeignKey['condef'], $match)) { $onUpdate = $match[1]; } + if (preg_match('(ON DELETE ([a-zA-Z0-9]+( (NULL|ACTION|DEFAULT))?))', $tableForeignKey['condef'], $match)) { $onDelete = $match[1]; } @@ -339,9 +340,11 @@ protected function _getPortableTableColumnDefinition($tableColumn) if ($length === '-1' && isset($tableColumn['atttypmod'])) { $length = $tableColumn['atttypmod'] - 4; } + if ((int) $length <= 0) { $length = null; } + $fixed = null; if (! isset($tableColumn['name'])) { @@ -368,17 +371,20 @@ protected function _getPortableTableColumnDefinition($tableColumn) $tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']); $length = null; break; + case 'int': case 'int4': case 'integer': $tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']); $length = null; break; + case 'bigint': case 'int8': $tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']); $length = null; break; + case 'bool': case 'boolean': if ($tableColumn['default'] === 'true') { @@ -391,6 +397,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) $length = null; break; + case 'text': case '_varchar': case 'varchar': @@ -400,10 +407,12 @@ protected function _getPortableTableColumnDefinition($tableColumn) case 'interval': $fixed = false; break; + case 'char': case 'bpchar': $fixed = true; break; + case 'float': case 'float4': case 'float8': @@ -420,7 +429,9 @@ protected function _getPortableTableColumnDefinition($tableColumn) $scale = $match[2]; $length = null; } + break; + case 'year': $length = null; break; @@ -490,13 +501,16 @@ private function parseDefaultExpression(?string $default) : ?string return str_replace("''", "'", $default); } + /** + * {@inheritdoc} + */ public function listTableDetails($tableName) : Table { $table = parent::listTableDetails($tableName); - /** @var PostgreSqlPlatform $platform */ $platform = $this->_platform; - $sql = $platform->getListTableMetadataSQL($tableName); + assert($platform instanceof PostgreSqlPlatform); + $sql = $platform->getListTableMetadataSQL($tableName); $tableOptions = $this->_conn->fetchAssoc($sql); diff --git a/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php b/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php index 13cdcb0952d..9825a759755 100644 --- a/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php @@ -112,6 +112,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) case 'char': case 'nchar': $fixed = true; + break; } switch ($type) { @@ -119,6 +120,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) case 'float': $precision = $tableColumn['length']; $scale = $tableColumn['scale']; + break; } return new Column( diff --git a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php index 35cdc45089a..54960657dd3 100644 --- a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php @@ -87,11 +87,13 @@ protected function _getPortableTableColumnDefinition($tableColumn) // Unicode data requires 2 bytes per character $length /= 2; break; + case 'varchar': // TEXT type is returned as VARCHAR(MAX) with a length of -1 if ($length === -1) { $dbType = 'text'; } + break; } @@ -334,9 +336,9 @@ public function listTableDetails($tableName) : Table { $table = parent::listTableDetails($tableName); - /** @var SQLServerPlatform $platform */ $platform = $this->_platform; - $sql = $platform->getListTableMetadataSQL($tableName); + assert($platform instanceof SQLServerPlatform); + $sql = $platform->getListTableMetadataSQL($tableName); $tableOptions = $this->_conn->fetchAssoc($sql); diff --git a/lib/Doctrine/DBAL/Schema/Schema.php b/lib/Doctrine/DBAL/Schema/Schema.php index 5d746654a40..ff09ef52cf1 100644 --- a/lib/Doctrine/DBAL/Schema/Schema.php +++ b/lib/Doctrine/DBAL/Schema/Schema.php @@ -67,6 +67,7 @@ public function __construct( if ($schemaConfig === null) { $schemaConfig = new SchemaConfig(); } + $this->_schemaConfig = $schemaConfig; $this->_setName($schemaConfig->getName() ?: 'public'); @@ -287,7 +288,7 @@ public function getSequences() * * @param string $namespaceName The name of the namespace to create. * - * @return \Doctrine\DBAL\Schema\Schema This schema instance. + * @return Schema This schema instance. * * @throws SchemaException */ @@ -329,7 +330,7 @@ public function createTable($tableName) * @param string $oldTableName * @param string $newTableName * - * @return \Doctrine\DBAL\Schema\Schema + * @return Schema */ public function renameTable($oldTableName, $newTableName) { @@ -347,7 +348,7 @@ public function renameTable($oldTableName, $newTableName) * * @param string $tableName * - * @return \Doctrine\DBAL\Schema\Schema + * @return Schema */ public function dropTable($tableName) { @@ -378,7 +379,7 @@ public function createSequence($sequenceName, $allocationSize = 1, $initialValue /** * @param string $sequenceName * - * @return \Doctrine\DBAL\Schema\Schema + * @return Schema */ public function dropSequence($sequenceName) { @@ -468,6 +469,7 @@ public function __clone() foreach ($this->_tables as $k => $table) { $this->_tables[$k] = clone $table; } + foreach ($this->_sequences as $k => $sequence) { $this->_sequences[$k] = clone $sequence; } diff --git a/lib/Doctrine/DBAL/Schema/SchemaDiff.php b/lib/Doctrine/DBAL/Schema/SchemaDiff.php index 29c699c0610..4e5dc91f621 100644 --- a/lib/Doctrine/DBAL/Schema/SchemaDiff.php +++ b/lib/Doctrine/DBAL/Schema/SchemaDiff.php @@ -155,6 +155,7 @@ protected function _toSql(AbstractPlatform $platform, $saveMode = false) $foreignKeySql[] = $platform->getCreateForeignKeySQL($foreignKey, $table); } } + $sql = array_merge($sql, $foreignKeySql); if ($saveMode === false) { diff --git a/lib/Doctrine/DBAL/Schema/SchemaException.php b/lib/Doctrine/DBAL/Schema/SchemaException.php index 68d778f53fd..c7465eee4ad 100644 --- a/lib/Doctrine/DBAL/Schema/SchemaException.php +++ b/lib/Doctrine/DBAL/Schema/SchemaException.php @@ -26,7 +26,7 @@ class SchemaException extends DBALException /** * @param string $tableName * - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function tableDoesNotExist($tableName) { @@ -36,7 +36,7 @@ public static function tableDoesNotExist($tableName) /** * @param string $indexName * - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function indexNameInvalid($indexName) { @@ -50,7 +50,7 @@ public static function indexNameInvalid($indexName) * @param string $indexName * @param string $table * - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function indexDoesNotExist($indexName, $table) { @@ -64,7 +64,7 @@ public static function indexDoesNotExist($indexName, $table) * @param string $indexName * @param string $table * - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function indexAlreadyExists($indexName, $table) { @@ -78,7 +78,7 @@ public static function indexAlreadyExists($indexName, $table) * @param string $columnName * @param string $table * - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function columnDoesNotExist($columnName, $table) { @@ -91,7 +91,7 @@ public static function columnDoesNotExist($columnName, $table) /** * @param string $namespaceName * - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function namespaceAlreadyExists($namespaceName) { @@ -104,7 +104,7 @@ public static function namespaceAlreadyExists($namespaceName) /** * @param string $tableName * - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function tableAlreadyExists($tableName) { @@ -115,7 +115,7 @@ public static function tableAlreadyExists($tableName) * @param string $tableName * @param string $columnName * - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function columnAlreadyExists($tableName, $columnName) { @@ -128,7 +128,7 @@ public static function columnAlreadyExists($tableName, $columnName) /** * @param string $sequenceName * - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function sequenceAlreadyExists($sequenceName) { @@ -138,7 +138,7 @@ public static function sequenceAlreadyExists($sequenceName) /** * @param string $sequenceName * - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function sequenceDoesNotExist($sequenceName) { @@ -149,7 +149,7 @@ public static function sequenceDoesNotExist($sequenceName) * @param string $fkName * @param string $table * - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function foreignKeyDoesNotExist($fkName, $table) { @@ -160,7 +160,7 @@ public static function foreignKeyDoesNotExist($fkName, $table) } /** - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function namedForeignKeyRequired(Table $localTable, ForeignKeyConstraint $foreignKey) { @@ -175,7 +175,7 @@ public static function namedForeignKeyRequired(Table $localTable, ForeignKeyCons /** * @param string $changeName * - * @return \Doctrine\DBAL\Schema\SchemaException + * @return SchemaException */ public static function alterTableChangeNotSupported($changeName) { diff --git a/lib/Doctrine/DBAL/Schema/Sequence.php b/lib/Doctrine/DBAL/Schema/Sequence.php index 88891019bfd..2301c8ae7e1 100644 --- a/lib/Doctrine/DBAL/Schema/Sequence.php +++ b/lib/Doctrine/DBAL/Schema/Sequence.php @@ -61,7 +61,7 @@ public function getCache() /** * @param int $allocationSize * - * @return \Doctrine\DBAL\Schema\Sequence + * @return Sequence */ public function setAllocationSize($allocationSize) { @@ -73,7 +73,7 @@ public function setAllocationSize($allocationSize) /** * @param int $initialValue * - * @return \Doctrine\DBAL\Schema\Sequence + * @return Sequence */ public function setInitialValue($initialValue) { @@ -85,7 +85,7 @@ public function setInitialValue($initialValue) /** * @param int $cache * - * @return \Doctrine\DBAL\Schema\Sequence + * @return Sequence */ public function setCache($cache) { diff --git a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php index 3de11178c9c..03076d96b6a 100644 --- a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php @@ -8,7 +8,6 @@ use Doctrine\DBAL\Types\StringType; use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\Type; -use const CASE_LOWER; use function array_change_key_case; use function array_map; use function array_reverse; @@ -27,6 +26,7 @@ use function trim; use function unlink; use function usort; +use const CASE_LOWER; /** * Sqlite SchemaManager. @@ -113,6 +113,7 @@ public function listTableForeignKeys($table, $database = null) if ($database === null) { $database = $this->_conn->getDatabase(); } + $sql = $this->_platform->getListTableForeignKeysSQL($table, $database); $tableForeignKeys = $this->_conn->fetchAll($sql); @@ -358,8 +359,10 @@ protected function _getPortableTableColumnDefinition($tableColumn) if (strpos($tableColumn['length'], ',') === false) { $tableColumn['length'] .= ',0'; } + [$precision, $scale] = array_map('trim', explode(',', $tableColumn['length'])); } + $length = null; break; } @@ -399,6 +402,7 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) if (! isset($value['on_delete']) || $value['on_delete'] === 'RESTRICT') { $value['on_delete'] = null; } + if (! isset($value['on_update']) || $value['on_update'] === 'RESTRICT') { $value['on_update'] = null; } @@ -414,6 +418,7 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) 'deferred'=> $value['deferred'], ]; } + $list[$name]['local'][] = $value['from']; $list[$name]['foreign'][] = $value['to']; } diff --git a/lib/Doctrine/DBAL/Schema/Table.php b/lib/Doctrine/DBAL/Schema/Table.php index 842d1fccf67..6fa660efd5e 100644 --- a/lib/Doctrine/DBAL/Schema/Table.php +++ b/lib/Doctrine/DBAL/Schema/Table.php @@ -5,13 +5,13 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\DBAL\Types\Type; -use const ARRAY_FILTER_USE_KEY; 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; /** * Object Representation of a table. @@ -161,6 +161,7 @@ public function dropIndex($indexName) if (! $this->hasIndex($indexName)) { throw SchemaException::indexDoesNotExist($indexName, $this->_name); } + unset($this->_indexes[$indexName]); } @@ -240,7 +241,6 @@ public function renameIndex($oldIndexName, $newIndexName = null) public function columnsAreIndexed(array $columnNames) { foreach ($this->getIndexes() as $index) { - /** @var $index Index */ if ($index->spansColumns($columnNames)) { return true; } @@ -510,6 +510,7 @@ protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint) $this->_getMaxIdentifierLength() ); } + $name = $this->normalizeIdentifier($name); $this->_fkConstraints[$name] = $constraint; @@ -816,9 +817,11 @@ public function __clone() foreach ($this->_columns as $k => $column) { $this->_columns[$k] = clone $column; } + foreach ($this->_indexes as $k => $index) { $this->_indexes[$k] = clone $index; } + foreach ($this->_fkConstraints as $k => $fk) { $this->_fkConstraints[$k] = clone $fk; $this->_fkConstraints[$k]->setLocalTable($this); diff --git a/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php b/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php index f846206329c..05b87fb16b0 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; /** @@ -82,19 +83,19 @@ public function getQueries() { $sql = []; - /** @var ForeignKeyConstraint $fkConstraint */ foreach ($this->constraints as $fkConstraint) { + assert($fkConstraint instanceof ForeignKeyConstraint); $localTable = $this->constraints[$fkConstraint]; $sql[] = $this->platform->getDropForeignKeySQL($fkConstraint, $localTable); } - /** @var Sequence $sequence */ foreach ($this->sequences as $sequence) { + assert($sequence instanceof Sequence); $sql[] = $this->platform->getDropSequenceSQL($sequence); } - /** @var Table $table */ foreach ($this->tables as $table) { + assert($table instanceof Table); $sql[] = $this->platform->getDropTableSQL($table); } diff --git a/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php b/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php index d5e94cf6ea3..84a009f8a1e 100644 --- a/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php +++ b/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php @@ -87,6 +87,7 @@ private function createTableLabel(Table $table) if ($primaryKey !== null && in_array($column->getName(), $primaryKey->getColumns())) { $label .= "\xe2\x9c\xb7"; } + $label .= ''; } @@ -108,6 +109,7 @@ private function createNode($name, $options) foreach ($options as $key => $value) { $node .= $key . '=' . $value . ' '; } + $node .= "]\n"; return $node; @@ -126,6 +128,7 @@ private function createNodeRelation($node1, $node2, $options) foreach ($options as $key => $value) { $relation .= $key . '=' . $value . ' '; } + $relation .= "]\n"; return $relation; diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php index a83b401c2cd..e85a3025f18 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php @@ -108,6 +108,7 @@ private function getClusteredIndex($table) return $index; } } + throw new RuntimeException('No clustered index found on table ' . $table->getName()); } diff --git a/lib/Doctrine/DBAL/Sharding/ShardingException.php b/lib/Doctrine/DBAL/Sharding/ShardingException.php index 4d9f41a30e3..f760dc7baa2 100644 --- a/lib/Doctrine/DBAL/Sharding/ShardingException.php +++ b/lib/Doctrine/DBAL/Sharding/ShardingException.php @@ -12,7 +12,7 @@ class ShardingException extends DBALException { /** - * @return \Doctrine\DBAL\Sharding\ShardingException + * @return ShardingException */ public static function notImplemented() { @@ -20,7 +20,7 @@ public static function notImplemented() } /** - * @return \Doctrine\DBAL\Sharding\ShardingException + * @return ShardingException */ public static function missingDefaultFederationName() { @@ -28,7 +28,7 @@ public static function missingDefaultFederationName() } /** - * @return \Doctrine\DBAL\Sharding\ShardingException + * @return ShardingException */ public static function missingDefaultDistributionKey() { @@ -36,7 +36,7 @@ public static function missingDefaultDistributionKey() } /** - * @return \Doctrine\DBAL\Sharding\ShardingException + * @return ShardingException */ public static function activeTransaction() { @@ -44,7 +44,7 @@ public static function activeTransaction() } /** - * @return \Doctrine\DBAL\Sharding\ShardingException + * @return ShardingException */ public static function noShardDistributionValue() { @@ -52,7 +52,7 @@ public static function noShardDistributionValue() } /** - * @return \Doctrine\DBAL\Sharding\ShardingException + * @return ShardingException */ public static function missingDistributionType() { diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index 13140a6a600..ee8dcfcfceb 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -95,6 +95,7 @@ public function bindValue($name, $value, $type = ParameterType::STRING) if (is_string($type)) { $type = Type::getType($type); } + if ($type instanceof Type) { $value = $type->convertToDatabaseValue($value, $this->platform); $bindingType = $type->getBindingType(); @@ -155,6 +156,7 @@ public function execute($params = null) if ($logger) { $logger->stopQuery(); } + throw DBALException::driverExceptionDuringQuery( $this->conn->getDriver(), $ex, @@ -166,6 +168,7 @@ public function execute($params = null) if ($logger) { $logger->stopQuery(); } + $this->params = []; $this->types = []; diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php index c142accfd77..eb15dd96a48 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php @@ -11,7 +11,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use const PHP_EOL; use function assert; use function error_get_last; use function file_exists; @@ -19,6 +18,7 @@ use function is_readable; use function realpath; use function sprintf; +use const PHP_EOL; /** * Task for executing arbitrary SQL that can come from a file or directly from diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php index 6de3345b128..cc3d1611ecf 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php @@ -27,6 +27,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use function array_keys; +use function assert; use function count; use function implode; @@ -120,8 +121,8 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - /** @var Connection $conn */ $conn = $this->getHelper('db')->getConnection(); + assert($conn instanceof Connection); $keywordLists = (array) $input->getOption('list'); if (! $keywordLists) { @@ -152,6 +153,7 @@ protected function execute(InputInterface $input, OutputInterface $output) 'Known lists: ' . implode(', ', array_keys($this->keywordListClasses)) ); } + $class = $this->keywordListClasses[$keywordList]; $keywords[] = new $class(); } diff --git a/lib/Doctrine/DBAL/Tools/Dumper.php b/lib/Doctrine/DBAL/Tools/Dumper.php index 8cb8f4b8689..25c165901f9 100644 --- a/lib/Doctrine/DBAL/Tools/Dumper.php +++ b/lib/Doctrine/DBAL/Tools/Dumper.php @@ -150,6 +150,7 @@ private static function fillReturnWithClassAttributes($var, stdClass $return, in if ($aux[0] === '') { $name .= ':' . ($aux[1] === '*' ? 'protected' : $aux[1] . ':private'); } + $return->$name = self::export($clone[$key], $maxDepth - 1); } diff --git a/lib/Doctrine/DBAL/Types/ConversionException.php b/lib/Doctrine/DBAL/Types/ConversionException.php index ba8c2a9192e..4733b572257 100644 --- a/lib/Doctrine/DBAL/Types/ConversionException.php +++ b/lib/Doctrine/DBAL/Types/ConversionException.php @@ -26,7 +26,7 @@ class ConversionException extends DBALException * @param string $value * @param string $toType * - * @return \Doctrine\DBAL\Types\ConversionException + * @return ConversionException */ public static function conversionFailed($value, $toType, ?Throwable $previous = null) { @@ -43,7 +43,7 @@ public static function conversionFailed($value, $toType, ?Throwable $previous = * @param string $toType * @param string $expectedFormat * - * @return \Doctrine\DBAL\Types\ConversionException + * @return ConversionException */ public static function conversionFailedFormat($value, $toType, $expectedFormat, ?Throwable $previous = null) { @@ -64,7 +64,7 @@ public static function conversionFailedFormat($value, $toType, $expectedFormat, * @param string $toType * @param string[] $possibleTypes * - * @return \Doctrine\DBAL\Types\ConversionException + * @return ConversionException */ public static function conversionFailedInvalidType( $value, diff --git a/lib/Doctrine/DBAL/Types/JsonType.php b/lib/Doctrine/DBAL/Types/JsonType.php index 127f3fa8ee1..5fc00937fef 100644 --- a/lib/Doctrine/DBAL/Types/JsonType.php +++ b/lib/Doctrine/DBAL/Types/JsonType.php @@ -3,13 +3,13 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; -use const JSON_ERROR_NONE; 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; /** * Type generating json objects values diff --git a/lib/Doctrine/DBAL/Types/Type.php b/lib/Doctrine/DBAL/Types/Type.php index d39ac2bd300..18c893dbcaf 100644 --- a/lib/Doctrine/DBAL/Types/Type.php +++ b/lib/Doctrine/DBAL/Types/Type.php @@ -222,7 +222,7 @@ private static function createTypeRegistry() : TypeRegistry * * @param string $name The name of the type (as returned by getName()). * - * @return \Doctrine\DBAL\Types\Type + * @return Type * * @throws DBALException */ diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 482519c1b72..73b009083e4 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,5 +1,8 @@ - + @@ -17,15 +20,32 @@ - + + + + + + + - + + + + + + + + */lib/* - + + */lib/* + + + */lib/* @@ -45,6 +65,11 @@ tests/Doctrine/Tests/DBAL/Tools/TestAsset/* + + + tests/continuousphp/bootstrap.php + + lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -52,6 +77,31 @@ tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php + + + lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php + + + + + tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php + + + + + + lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php + + lib/Doctrine/DBAL/SQLParserUtils.php + lib/Doctrine/DBAL/Tools/Dumper.php + tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php + tests/Doctrine/Tests/DBAL/Tools/DumperTest.php + + lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -62,21 +112,20 @@ lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php - - - tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php - tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php - - lib/Doctrine/DBAL/Schema/Comparator.php - - - lib/Doctrine/DBAL/Types/ArrayType.php - lib/Doctrine/DBAL/Types/ObjectType.php - tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php + + + lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php + + + + + lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php diff --git a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php index 6b478e82b5e..bde98cfa4b5 100644 --- a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php +++ b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php @@ -17,9 +17,6 @@ class ConfigurationTest extends DbalTestCase */ protected $config; - /** - * {@inheritdoc} - */ protected function setUp() : void { $this->config = new Configuration(); diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index fb0157314d6..8134ee03275 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -165,13 +165,11 @@ public function testEventManagerPassedToPlatform() : void { $eventManager = new EventManager(); - /** @var AbstractPlatform|MockObject $driver */ $platform = $this->createMock(AbstractPlatform::class); $platform->expects($this->once()) ->method('setEventManager') ->with($eventManager); - /** @var Driver|MockObject $driver */ $driver = $this->createMock(Driver::class); $driver->expects($this->any()) ->method('getDatabasePlatform') @@ -564,7 +562,6 @@ public function testFetchAssoc() : void ->with(FetchMode::ASSOCIATIVE) ->will($this->returnValue($result)); - /** @var Connection|MockObject $conn */ $conn = $this->getMockBuilder(Connection::class) ->onlyMethods(['executeQuery']) ->setConstructorArgs([[], $driverMock]) @@ -600,7 +597,6 @@ public function testFetchArray() : void ->with(FetchMode::NUMERIC) ->will($this->returnValue($result)); - /** @var Connection|MockObject $conn */ $conn = $this->getMockBuilder(Connection::class) ->onlyMethods(['executeQuery']) ->setConstructorArgs([[], $driverMock]) @@ -637,7 +633,6 @@ public function testFetchColumn() : void ->with($column) ->will($this->returnValue($result)); - /** @var Connection|MockObject $conn */ $conn = $this->getMockBuilder(Connection::class) ->onlyMethods(['executeQuery']) ->setConstructorArgs([[], $driverMock]) @@ -672,7 +667,6 @@ public function testFetchAll() : void ->method('fetchAll') ->will($this->returnValue($result)); - /** @var Connection|MockObject $conn */ $conn = $this->getMockBuilder(Connection::class) ->onlyMethods(['executeQuery']) ->setConstructorArgs([[], $driverMock]) @@ -710,7 +704,6 @@ public function testPassingExternalPDOMeansConnectionIsConnected() : void public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentException() : void { - /** @var Driver $driver */ $driver = $this->createMock(Driver::class); $pdoMock = $this->createMock(\Doctrine\DBAL\Driver\Connection::class); @@ -769,13 +762,10 @@ public function testCallConnectOnce(string $method, array $params) : void */ public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() : void { - /** @var Driver|VersionAwarePlatformDriver|MockObject $driverMock */ $driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]); - /** @var ServerInfoAwareConnection|MockObject $driverConnectionMock */ $driverConnectionMock = $this->createMock(ServerInfoAwareConnection::class); - /** @var AbstractPlatform|MockObject $platformMock */ $platformMock = $this->getMockForAbstractClass(AbstractPlatform::class); $connection = new Connection([], $driverMock); @@ -814,7 +804,6 @@ public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCach $params = [666]; $types = [ParameterType::INTEGER]; - /** @var QueryCacheProfile|MockObject $queryCacheProfileMock */ $queryCacheProfileMock = $this->createMock(QueryCacheProfile::class); $queryCacheProfileMock @@ -829,7 +818,6 @@ public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCach ->with($query, $params, $types, $this->params) ->will($this->returnValue(['cacheKey', 'realKey'])); - /** @var Driver $driver */ $driver = $this->createMock(Driver::class); self::assertInstanceOf( @@ -851,7 +839,6 @@ public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecute ->with('cacheKey') ->will($this->returnValue(['realKey' => []])); - /** @var QueryCacheProfile|MockObject $queryCacheProfileMock */ $queryCacheProfileMock = $this->createMock(QueryCacheProfile::class); $queryCacheProfileMock @@ -871,7 +858,6 @@ public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecute $connectionParams['platform'] = $this->createMock(AbstractPlatform::class); - /** @var Driver $driver */ $driver = $this->createMock(Driver::class); (new Connection($connectionParams, $driver))->executeCacheQuery($query, [], [], $queryCacheProfileMock); @@ -885,7 +871,6 @@ public function testThrowsExceptionWhenInValidPlatformSpecified() : void $connectionParams = $this->params; $connectionParams['platform'] = new stdClass(); - /** @var Driver $driver */ $driver = $this->createMock(Driver::class); $this->expectException(DBALException::class); @@ -898,7 +883,6 @@ public function testThrowsExceptionWhenInValidPlatformSpecified() : void */ public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase() : void { - /** @var Driver|VersionAwarePlatformDriver|MockObject $driverMock */ $driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]); $connection = new Connection(['dbname' => 'foo'], $driverMock); @@ -923,16 +907,12 @@ public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnecting */ public function testExecuteCacheQueryStripsPlatformFromConnectionParamsBeforeGeneratingCacheKeys() : void { - /** @var Driver|MockObject $driver */ $driver = $this->createMock(Driver::class); - /** @var AbstractPlatform|MockObject $platform */ $platform = $this->createMock(AbstractPlatform::class); - /** @var QueryCacheProfile|MockObject $queryCacheProfile */ $queryCacheProfile = $this->createMock(QueryCacheProfile::class); - /** @var Cache|MockObject $resultCacheDriver */ $resultCacheDriver = $this->createMock(Cache::class); $queryCacheProfile diff --git a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php index 7db5921ba79..de37397dd91 100644 --- a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php @@ -17,7 +17,6 @@ class DBALExceptionTest extends DbalTestCase { public function testDriverExceptionDuringQueryAcceptsBinaryData() : void { - /** @var Driver $driver */ $driver = $this->createMock(Driver::class); $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), '', ['ABC', chr(128)]); self::assertStringContainsString('with params ["ABC", "\x80"]', $e->getMessage()); @@ -25,7 +24,6 @@ public function testDriverExceptionDuringQueryAcceptsBinaryData() : void public function testDriverExceptionDuringQueryAcceptsResource() : void { - /** @var Driver $driver */ $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()); @@ -33,10 +31,8 @@ public function testDriverExceptionDuringQueryAcceptsResource() : void public function testAvoidOverWrappingOnDriverException() : void { - /** @var Driver $driver */ $driver = $this->createMock(Driver::class); - /** @var InnerDriverException $inner */ $inner = $this->createMock(InnerDriverException::class); $ex = new DriverException('', $inner); diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php index d2a5422a179..78f6ec5f5a6 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php @@ -28,7 +28,6 @@ use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; use Doctrine\Tests\DbalTestCase; -use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; use function array_merge; use function get_class; @@ -79,7 +78,6 @@ public function testConvertsException($errorCode, ?string $sqlState, ?string $me $this->markTestSkipped('This test is only intended for exception converter drivers.'); } - /** @var DriverExceptionInterface|MockObject $driverException */ $driverException = $this->getMockBuilder(DriverExceptionInterface::class) ->setConstructorArgs([$message]) ->getMock(); diff --git a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php index 37a5ab1a32f..5e4b43aff8c 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php @@ -44,10 +44,11 @@ public function testDoesNotRequireQueryForServerVersion() : void public function testRestoresErrorHandlerOnException() : void { - $handler = static function () : bool { + $handler = static function () : bool { self::fail('Never expected this to be called'); }; - $default_handler = set_error_handler($handler); + + $defaultHandler = set_error_handler($handler); try { new MysqliConnection(['host' => '255.255.255.255'], 'user', 'pass'); @@ -56,7 +57,7 @@ public function testRestoresErrorHandlerOnException() : void self::assertSame('Network is unreachable', $e->getMessage()); } - self::assertSame($handler, set_error_handler($default_handler), 'Restoring error handler failed.'); + self::assertSame($handler, set_error_handler($defaultHandler), 'Restoring error handler failed.'); restore_error_handler(); restore_error_handler(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php index 2b976233c27..b4f244a721d 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php @@ -97,9 +97,6 @@ public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplici } } - /** - * {@inheritDoc} - */ protected function createDriver() : DriverInterface { return new Driver(); diff --git a/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php b/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php index 90244cd2ac8..b3d8abc6b85 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php @@ -11,7 +11,6 @@ use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\Portability\Statement as PortabilityStatement; use Doctrine\Tests\DbalTestCase; -use IteratorAggregate; use PHPUnit\Framework\MockObject\MockObject; use Traversable; use function extension_loaded; @@ -23,7 +22,6 @@ class StatementIteratorTest extends DbalTestCase */ public function testGettingIteratorDoesNotCallFetch(string $class) : void { - /** @var IteratorAggregate|MockObject $stmt */ $stmt = $this->createPartialMock($class, ['fetch', 'fetchAll', 'fetchColumn']); $stmt->expects($this->never())->method('fetch'); $stmt->expects($this->never())->method('fetchAll'); @@ -71,6 +69,9 @@ private function configureStatement(MockObject $stmt, int &$calls) : void }); } + /** + * @param Traversable $iterator + */ private function assertIterationCallsFetchOncePerStep(Traversable $iterator, int &$calls) : void { foreach ($iterator as $i => $_) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php index 655b5897c72..5ea675c9e1a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php @@ -60,13 +60,16 @@ public function testTransactionNestingBehavior() : void try { $this->connection->beginTransaction(); self::assertEquals(2, $this->connection->getTransactionNestingLevel()); + throw new Exception(); + $this->connection->commit(); // never reached } catch (Throwable $e) { $this->connection->rollBack(); self::assertEquals(1, $this->connection->getTransactionNestingLevel()); //no rethrow } + self::assertTrue($this->connection->isRollbackOnly()); $this->connection->commit(); // should throw exception @@ -130,13 +133,16 @@ public function testTransactionNestingBehaviorWithSavepoints() : void self::assertEquals(3, $this->connection->getTransactionNestingLevel()); self::assertTrue($this->connection->commit()); self::assertEquals(2, $this->connection->getTransactionNestingLevel()); + throw new Exception(); + $this->connection->commit(); // never reached } catch (Throwable $e) { $this->connection->rollBack(); self::assertEquals(1, $this->connection->getTransactionNestingLevel()); //no rethrow } + self::assertFalse($this->connection->isRollbackOnly()); try { $this->connection->setNestTransactionsWithSavepoints(false); @@ -144,6 +150,7 @@ public function testTransactionNestingBehaviorWithSavepoints() : void } catch (ConnectionException $e) { self::assertTrue($this->connection->getNestTransactionsWithSavepoints()); } + $this->connection->commit(); // should not throw exception } catch (ConnectionException $e) { $this->fail('Transaction commit after failed nested transaction should not fail when using savepoints.'); @@ -246,6 +253,7 @@ public function testTransactionalWithException() : void $this->connection->transactional(static function ($conn) : void { /** @var Connection $conn */ $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); + throw new RuntimeException('Ooops!'); }); $this->fail('Expected exception'); @@ -260,6 +268,7 @@ public function testTransactionalWithThrowable() : void $this->connection->transactional(static function ($conn) : void { /** @var Connection $conn */ $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); + throw new Error('Ooops!'); }); $this->fail('Expected exception'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index b7d625c8600..29d82fdbe19 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -19,8 +19,6 @@ use Doctrine\DBAL\Types\Types; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; -use const CASE_LOWER; -use const PHP_EOL; use function array_change_key_case; use function array_filter; use function array_keys; @@ -32,6 +30,8 @@ use function property_exists; use function sprintf; use function strtotime; +use const CASE_LOWER; +use const PHP_EOL; class DataAccessTest extends DbalFunctionalTestCase { @@ -953,8 +953,8 @@ private function beforeFetchClassTest() : void return; } - /** @var PDOConnection $connection */ $connection = $this->connection->getWrappedConnection(); + self::assertInstanceOf(PDOConnection::class, $connection); $connection->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); } } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php index 4021bb2fff7..b029cabba31 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php @@ -24,25 +24,16 @@ protected function setUp() : void $this->markTestSkipped('ibm_db2 only test.'); } - /** - * {@inheritdoc} - */ public function testConnectsWithoutDatabaseNameParameter() : void { $this->markTestSkipped('IBM DB2 does not support connecting without database name.'); } - /** - * {@inheritdoc} - */ public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void { $this->markTestSkipped('IBM DB2 does not support connecting without database name.'); } - /** - * {@inheritdoc} - */ protected function createDriver() : Driver { return new DB2Driver(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php index 4a3a315f296..4a8745c06e8 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php @@ -6,8 +6,8 @@ use Doctrine\DBAL\Driver\Mysqli\MysqliConnection; use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\Tests\DbalFunctionalTestCase; -use const MYSQLI_OPT_CONNECT_TIMEOUT; use function extension_loaded; +use const MYSQLI_OPT_CONNECT_TIMEOUT; class ConnectionTest extends DbalFunctionalTestCase { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php index d4bbf9a1df7..549535be6ee 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php @@ -24,9 +24,6 @@ protected function setUp() : void $this->markTestSkipped('MySQLi only test.'); } - /** - * {@inheritdoc} - */ 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 861ce650e76..bf587cab186 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php @@ -24,25 +24,16 @@ protected function setUp() : void $this->markTestSkipped('oci8 only test.'); } - /** - * {@inheritdoc} - */ public function testConnectsWithoutDatabaseNameParameter() : void { $this->markTestSkipped('Oracle does not support connecting without database name.'); } - /** - * {@inheritdoc} - */ public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void { $this->markTestSkipped('Oracle does not support connecting without database name.'); } - /** - * {@inheritdoc} - */ protected function createDriver() : DriverInterface { return new Driver(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php index 7f77ea542f9..641f515c7ec 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php @@ -24,9 +24,6 @@ protected function setUp() : void $this->markTestSkipped('pdo_mysql only test.'); } - /** - * {@inheritdoc} - */ 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 b096fa47e94..f33c6669865 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php @@ -24,25 +24,16 @@ protected function setUp() : void $this->markTestSkipped('PDO_OCI only test.'); } - /** - * {@inheritdoc} - */ public function testConnectsWithoutDatabaseNameParameter() : void { $this->markTestSkipped('Oracle does not support connecting without database name.'); } - /** - * {@inheritdoc} - */ public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void { $this->markTestSkipped('Oracle does not support connecting without database name.'); } - /** - * {@inheritdoc} - */ 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 b5f9d3eda9d..638e855c970 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php @@ -101,17 +101,11 @@ public function testConnectsWithApplicationNameParameter() : void $this->fail(sprintf('Query result does not contain a record where column "query" equals "%s".', $sql)); } - /** - * {@inheritdoc} - */ protected function createDriver() : DriverInterface { return new Driver(); } - /** - * {@inheritdoc} - */ protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string { return 'postgres'; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php index efc0382d85f..295831b8bf4 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php @@ -24,9 +24,6 @@ protected function setUp() : void $this->markTestSkipped('pdo_sqlite only test.'); } - /** - * {@inheritdoc} - */ 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 d2dfd5925f5..236cb6b5875 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php @@ -26,17 +26,11 @@ protected function setUp() : void $this->markTestSkipped('pdo_sqlsrv only test.'); } - /** - * {@inheritdoc} - */ protected function createDriver() : DriverInterface { return new Driver(); } - /** - * {@inheritdoc} - */ protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string { return 'master'; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php index f2d54c62845..960acfc003c 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php @@ -42,9 +42,6 @@ public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void self::assertIsString($this->driver->getDatabase($connection)); } - /** - * {@inheritdoc} - */ protected function createDriver() : DriverInterface { return new Driver(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php index eb9931a43dc..de8b37cb683 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php @@ -24,17 +24,11 @@ protected function setUp() : void $this->markTestSkipped('sqlsrv only test.'); } - /** - * {@inheritdoc} - */ protected function createDriver() : DriverInterface { return new Driver(); } - /** - * {@inheritdoc} - */ protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string { return 'master'; diff --git a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php index 25824381048..46950e7db80 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php @@ -14,7 +14,6 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; -use const PHP_OS; use function array_merge; use function assert; use function chmod; @@ -27,6 +26,7 @@ use function touch; use function unlink; use function version_compare; +use const PHP_OS; class ExceptionTest extends DbalFunctionalTestCase { diff --git a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php index 2731ac995b8..8315c18c37a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php @@ -8,12 +8,12 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; -use const CASE_LOWER; use function array_change_key_case; use function sprintf; use function strlen; use function strtolower; use function substr; +use const CASE_LOWER; /** * @group DBAL-20 @@ -83,8 +83,8 @@ public function testInheritCharsetFromMaster() : void unset($params['slaves'][$index]['charset']); } - /** @var MasterSlaveConnection $conn */ $conn = DriverManager::getConnection($params); + self::assertInstanceOf(MasterSlaveConnection::class, $conn); $conn->connect('slave'); self::assertFalse($conn->isConnectedToMaster()); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php b/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php index a14f9b17582..73d258b31d9 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php @@ -4,9 +4,9 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; -use const CASE_LOWER; use function array_change_key_case; use function count; +use const CASE_LOWER; class ModifyLimitQueryTest extends DbalFunctionalTestCase { @@ -32,6 +32,7 @@ protected function setUp() : void $sm->createTable($table2); self::$tableCreated = true; } + $this->connection->exec($this->connection->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table')); $this->connection->exec($this->connection->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table2')); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php b/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php index 33e116ec368..8946db53308 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php @@ -8,8 +8,8 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; -use const CASE_LOWER; use function array_change_key_case; +use const CASE_LOWER; /** * @group DDC-1372 diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php index 42e08f3f6d7..faac5f4a6b2 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php @@ -9,9 +9,6 @@ final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends DbalFunctionalTestCase { - /** - * {@inheritDoc} - */ protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php index 8d0a17c9b43..6d03a736e13 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php @@ -9,12 +9,12 @@ use Doctrine\DBAL\Logging\DebugStack; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; -use const CASE_LOWER; 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; /** * @group DDC-217 @@ -43,7 +43,7 @@ protected function setUp() : void $this->connection->insert('caching', $row); } - $config = $this->connection->getConfiguration(); + $config = $this->connection->getConfiguration(); $config->setSQLLogger($this->sqlLogger = new DebugStack()); $cache = new ArrayCache(); @@ -101,6 +101,7 @@ public function testMixingFetch() : void foreach ($this->expectedResult as $v) { $numExpectedResult[] = array_values($v); } + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); $data = $this->hydrateStmt($stmt, FetchMode::ASSOCIATIVE); @@ -126,10 +127,10 @@ 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); - $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); - $data_iterator = $this->hydrateStmtIterator($stmt, $fetchMode); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $dataIterator = $this->hydrateStmtIterator($stmt, $fetchMode); - self::assertEquals($data, $data_iterator); + self::assertEquals($data, $dataIterator); } public function testDontCloseNoCache() : void @@ -245,6 +246,7 @@ private function hydrateStmt(ResultStatement $stmt, int $fetchMode = FetchMode:: while ($row = $stmt->fetch($fetchMode)) { $data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row; } + $stmt->closeCursor(); return $data; @@ -260,6 +262,7 @@ private function hydrateStmtIterator(ResultStatement $stmt, int $fetchMode = Fet foreach ($stmt as $row) { $data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row; } + $stmt->closeCursor(); return $data; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php index 422740476da..b1a47bc417c 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php @@ -30,7 +30,7 @@ public function testListTableWithBinary() : void public function testColumnCollation() : void { - $table = new Table('test_collation'); + $table = new Table('test_collation'); $table->addOption('collate', $collation = 'utf8_unicode_ci'); $table->addColumn('id', 'integer'); $table->addColumn('text', 'text'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php index cf636a797ff..1e3d620c02a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php @@ -269,7 +269,7 @@ public function testColumnCharsetChange() : void public function testColumnCollation() : void { - $table = new Table('test_collation'); + $table = new Table('test_collation'); $table->addOption('collate', $collation = 'latin1_swedish_ci'); $table->addOption('charset', 'latin1'); $table->addColumn('id', 'integer'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php index b8a26af3c65..0aec5dc14b5 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php @@ -240,12 +240,14 @@ public function testListForeignKeys() : void ['onDelete' => $fkOptions[$i]] ); } + $this->schemaManager->dropAndCreateTable($fkTable); $this->createTestTable('test_create_fk2'); foreach ($foreignKeys as $foreignKey) { $this->schemaManager->createForeignKey($foreignKey, 'test_create_fk1'); } + $fkeys = $this->schemaManager->listTableForeignKeys('test_create_fk1'); self::assertEquals(count($foreignKeys), count($fkeys), "Table 'test_create_fk1' has to have " . count($foreignKeys) . ' foreign keys.'); for ($i = 0; $i < count($fkeys); $i++) { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php index 669d78445fc..665ea42b87e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -1020,6 +1020,7 @@ protected function assertHasTable(array $tables) : void $foundTable = true; } + self::assertTrue($foundTable, 'Could not find new table'); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php index 166b0d08d5b..c534833129f 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php @@ -169,6 +169,7 @@ public function testNonDefaultPKOrder() : void 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(<<generator = new TableGenerator($this->connection); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php index 687e6e834a0..fc3657687a7 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php @@ -31,6 +31,7 @@ protected function setUp() : void $this->connection->exec('CREATE TABLE dbal630_allow_nulls (id SERIAL, bool_col BOOLEAN);'); } catch (DBALException $e) { } + $this->running = true; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php index b08751d5ec3..da2e23dc32d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php @@ -29,6 +29,7 @@ protected function setUp() : void $this->connection->getSchemaManager()->createTable($table); } catch (Throwable $e) { } + $this->connection->executeUpdate('DELETE FROM write_table'); } diff --git a/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php b/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php index 6a76e90f897..fefc973a699 100644 --- a/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php +++ b/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php @@ -26,6 +26,7 @@ public function testDateTimeTypeConversionPerformance(int $count) : void for ($i = 0; $i < $count; $i++) { $type->convertToDatabaseValue($value, $platform); } + $this->stopTiming(); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php index 9bd0ae62f85..109961f0368 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php @@ -800,25 +800,16 @@ protected function getCommentOnColumnSQL() : array ]; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string { return 'CONSTRAINT `select` UNIQUE (foo)'; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string { return 'INDEX `select` (foo)'; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInTruncateTableSQL() : string { return 'TRUNCATE `select`'; diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php index 44c28018849..4da784c3805 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php @@ -325,9 +325,6 @@ public function testSupportsSequences() : void self::assertTrue($this->platform->supportsSequences()); } - /** - * {@inheritdoc} - */ protected function supportsCommentOnStatement() : bool { return true; @@ -907,25 +904,16 @@ public function testAltersTableColumnCommentIfRequiredByType() : void ); } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string { return 'INDEX "select" (foo)'; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInTruncateTableSQL() : string { return 'TRUNCATE "select"'; diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php index 46627bd8cf2..40426da5c2b 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php @@ -1411,25 +1411,16 @@ public static function getReturnsForeignKeyReferentialActionSQL() : iterable ]; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string { return 'CONSTRAINT [select] UNIQUE (foo) WHERE foo IS NOT NULL'; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string { return 'INDEX [select] (foo)'; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInTruncateTableSQL() : string { return 'TRUNCATE TABLE [select]'; diff --git a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php index a0c1f1f4b4b..e3bca1e9c47 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php @@ -661,41 +661,26 @@ public static function getGeneratesAlterColumnSQL() : iterable ]; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string { return ''; // not supported by this platform } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInTruncateTableSQL() : string { return 'TRUNCATE "select" IMMEDIATE'; } - /** - * {@inheritdoc} - */ protected function supportsInlineIndexDeclaration() : bool { return false; } - /** - * {@inheritdoc} - */ protected function supportsCommentOnStatement() : bool { return true; diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php index 00b86088ad5..f8bbbf70ac5 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php @@ -8,9 +8,6 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase { - /** - * {@inheritdoc} - */ public function createPlatform() : AbstractPlatform { return new MariaDb1027Platform(); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php index 2557562ab95..0587f4cde6a 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php @@ -8,9 +8,6 @@ class MySQL57PlatformTest extends AbstractMySQLPlatformTestCase { - /** - * {@inheritdoc} - */ public function createPlatform() : AbstractPlatform { return new MySQL57Platform(); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php index 0dd4b304739..4552acb9122 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php @@ -213,9 +213,6 @@ public function testSupportsSavePoints() : void self::assertTrue($this->platform->supportsSavepoints()); } - /** - * {@inheritdoc} - */ protected function supportsCommentOnStatement() : bool { return true; @@ -844,7 +841,7 @@ public static function getReturnsGetListTableColumnsSQL() : iterable WHERE c.table_name = 'test' ORDER BY c.column_id SQL - , +, ], [ '/', @@ -860,7 +857,7 @@ public static function getReturnsGetListTableColumnsSQL() : iterable WHERE c.table_name = 'test' ORDER BY c.column_id SQL - , +, ], [ 'scott', @@ -876,30 +873,21 @@ public static function getReturnsGetListTableColumnsSQL() : iterable WHERE c.table_name = 'test' AND c.owner = 'SCOTT' ORDER BY c.column_id SQL - , +, ], ]; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string { return 'INDEX "select" (foo)'; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInTruncateTableSQL() : string { return 'TRUNCATE TABLE "select"'; diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php index 8eb58c98e72..0734c603017 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php @@ -9,9 +9,6 @@ class PostgreSQL100PlatformTest extends PostgreSQL94PlatformTest { - /** - * {@inheritdoc} - */ public function createPlatform() : AbstractPlatform { return new PostgreSQL100Platform(); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php index 7fbedd494be..276c32935b3 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php @@ -8,9 +8,6 @@ class PostgreSQL92PlatformTest extends AbstractPostgreSqlPlatformTestCase { - /** - * {@inheritdoc} - */ public function createPlatform() : AbstractPlatform { return new PostgreSQL92Platform(); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php index 179e005b2f9..36e53491848 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php @@ -8,9 +8,6 @@ class PostgreSQL94PlatformTest extends PostgreSQL92PlatformTest { - /** - * {@inheritdoc} - */ public function createPlatform() : AbstractPlatform { return new PostgreSQL94Platform(); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php index 0efa23b19c6..e304e797fdf 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php @@ -982,33 +982,21 @@ public static function getReturnsForeignKeyReferentialActionSQL() : iterable ]; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string { return ''; // not supported by this platform } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInTruncateTableSQL() : string { return 'TRUNCATE TABLE "select"'; } - /** - * {@inheritdoc} - */ protected function supportsInlineIndexDeclaration() : bool { return false; diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php index 18a8a0ef1d2..e6d4975daed 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php @@ -170,7 +170,6 @@ public function testModifyLimitQueryWithSubSelectInSelectList() : void ); self::assertEquals( - 'SELECT ' . 'u.id, ' . '(u.foo/2) foodiv, ' . diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php index d645b218cb8..e3f6d9b5d0c 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php @@ -689,25 +689,16 @@ protected static function getInlineColumnEmptyCommentSQL() : string return "--\n"; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string { return 'INDEX "select" (foo)'; } - /** - * {@inheritdoc} - */ protected function getQuotesReservedKeywordInTruncateTableSQL() : string { return 'DELETE FROM "select"'; diff --git a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php index c8e40214eb0..00dbe37b0d0 100644 --- a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php @@ -23,9 +23,6 @@ class StatementTest extends DbalTestCase /** @var DriverStatement|MockObject */ protected $wrappedStmt; - /** - * {@inheritdoc} - */ protected function setUp() : void { $this->wrappedStmt = $this->createMock(DriverStatement::class); diff --git a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php index a16a516579b..e19adad8940 100644 --- a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php @@ -792,14 +792,14 @@ public function testClone() : void $qb->setParameter(':test', (object) 1); - $qb_clone = clone $qb; + $qbClone = clone $qb; - self::assertEquals((string) $qb, (string) $qb_clone); + self::assertEquals((string) $qb, (string) $qbClone); $qb->andWhere('u.id = 1'); - self::assertNotSame($qb->getQueryParts(), $qb_clone->getQueryParts()); - self::assertNotSame($qb->getParameters(), $qb_clone->getParameters()); + self::assertNotSame($qb->getQueryParts(), $qbClone->getQueryParts()); + self::assertNotSame($qb->getParameters(), $qbClone->getParameters()); } public function testSimpleSelectWithoutTableAlias() : void diff --git a/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php b/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php index a582a272dd1..621520029b1 100644 --- a/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php +++ b/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php @@ -76,7 +76,7 @@ public static function dataGetPlaceholderPositions() : iterable OR bar='' OR bar=:a_param3 SQLDATA - , +, false, [ 74 => 'a_param1', diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php index 5a975662e7e..92bc0c83dd6 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php @@ -42,7 +42,6 @@ public function testSchemaDiffToSaveSql() : void */ private function createPlatform(bool $unsafe) { - /** @var AbstractPlatform|MockObject $platform */ $platform = $this->createMock(AbstractPlatform::class); $platform->expects($this->exactly(1)) ->method('getCreateSchemaSQL') @@ -58,6 +57,7 @@ private function createPlatform(bool $unsafe) ->with($this->isInstanceOf(Sequence::class)) ->will($this->returnValue('drop_seq')); } + $platform->expects($this->exactly(1)) ->method('getAlterSequenceSql') ->with($this->isInstanceOf(Sequence::class)) @@ -72,6 +72,7 @@ private function createPlatform(bool $unsafe) ->with($this->isInstanceOf(Table::class)) ->will($this->returnValue('drop_table')); } + $platform->expects($this->exactly(1)) ->method('getCreateTableSql') ->with($this->isInstanceOf(Table::class)) @@ -93,6 +94,7 @@ private function createPlatform(bool $unsafe) ) ->will($this->returnValue('drop_orphan_fk')); } + $platform->expects($this->exactly(1)) ->method('supportsSchemas') ->will($this->returnValue(true)); diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php index 88df92341ce..1591cdcbad0 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php @@ -18,9 +18,6 @@ class CreateSchemaSqlCollectorTest extends TestCase /** @var CreateSchemaSqlCollector */ private $visitor; - /** - * {@inheritdoc} - */ protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php index 5f5b412e249..062c77781f1 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php @@ -24,9 +24,6 @@ abstract class BaseDateTypeTestCase extends TestCase /** @var string */ private $currentTimezone; - /** - * {@inheritDoc} - */ protected function setUp() : void { $this->platform = $this->getMockForAbstractClass(AbstractPlatform::class); @@ -35,9 +32,6 @@ protected function setUp() : void self::assertInstanceOf(Type::class, $this->type); } - /** - * {@inheritDoc} - */ protected function tearDown() : void { date_default_timezone_set($this->currentTimezone); diff --git a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php index fceeee557b8..d71512f3c01 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php @@ -22,9 +22,6 @@ class BinaryTest extends DbalTestCase /** @var BinaryType */ protected $type; - /** - * {@inheritdoc} - */ protected function setUp() : void { $this->platform = $this->createMock(AbstractPlatform::class); diff --git a/tests/Doctrine/Tests/DBAL/Types/BlobTest.php b/tests/Doctrine/Tests/DBAL/Types/BlobTest.php index 194d26af0b8..d1a10a60bfa 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BlobTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BlobTest.php @@ -20,9 +20,6 @@ class BlobTest extends DbalTestCase /** @var BlobType */ protected $type; - /** - * {@inheritdoc} - */ protected function setUp() : void { $this->platform = $this->createMock(AbstractPlatform::class); diff --git a/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php b/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php index 7b2c09aca9f..15ee937e7d2 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php @@ -20,9 +20,6 @@ final class DateIntervalTest extends DbalTestCase /** @var DateIntervalType */ private $type; - /** - * {@inheritDoc} - */ protected function setUp() : void { $this->platform = $this->createMock(AbstractPlatform::class); diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTest.php index 73e426ea41c..4bc2cda4556 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTest.php @@ -9,9 +9,6 @@ class DateTest extends BaseDateTypeTestCase { - /** - * {@inheritDoc} - */ protected function setUp() : void { $this->type = Type::getType('date'); diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php index ba7a661c8d9..9d43cd9d7b3 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php @@ -8,9 +8,6 @@ class DateTimeTest extends BaseDateTypeTestCase { - /** - * {@inheritDoc} - */ protected function setUp() : void { $this->type = Type::getType('datetime'); diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php index 72ccaf87d05..adb75744d6e 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php @@ -8,9 +8,6 @@ class DateTimeTzTest extends BaseDateTypeTestCase { - /** - * {@inheritDoc} - */ protected function setUp() : void { $this->type = Type::getType('datetimetz'); diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php index 2ee5e9fc45e..92cb6b6e17f 100644 --- a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php @@ -21,9 +21,6 @@ class JsonArrayTest extends DbalTestCase /** @var JsonArrayType */ protected $type; - /** - * {@inheritdoc} - */ protected function setUp() : void { $this->platform = $this->createMock(AbstractPlatform::class); diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php index 4a5ff3c28c0..034cc0361bb 100644 --- a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php @@ -22,9 +22,6 @@ class JsonTest extends DbalTestCase /** @var JsonType */ protected $type; - /** - * {@inheritdoc} - */ protected function setUp() : void { $this->platform = $this->createMock(AbstractPlatform::class); diff --git a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php index a75544b650e..c9b340c6325 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php @@ -7,9 +7,6 @@ class TimeTest extends BaseDateTypeTestCase { - /** - * {@inheritDoc} - */ protected function setUp() : void { $this->type = Type::getType('time'); diff --git a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php index 7fe10cb2ba3..4e24f53373d 100644 --- a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php @@ -24,6 +24,7 @@ protected function setUp() : void if (! Type::hasType('vardatetime')) { Type::addType('vardatetime', VarDateTimeType::class); } + $this->type = Type::getType('vardatetime'); } diff --git a/tests/Doctrine/Tests/DbalFunctionalTestCase.php b/tests/Doctrine/Tests/DbalFunctionalTestCase.php index 16aa747c20e..4546f60090e 100644 --- a/tests/Doctrine/Tests/DbalFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DbalFunctionalTestCase.php @@ -7,7 +7,6 @@ use Exception; use PHPUnit\Framework\AssertionFailedError; use Throwable; -use const PHP_EOL; use function array_map; use function array_reverse; use function count; @@ -17,6 +16,7 @@ use function is_scalar; use function strpos; use function var_export; +use const PHP_EOL; abstract class DbalFunctionalTestCase extends DbalTestCase { @@ -48,6 +48,7 @@ protected function setUp() : void if (! isset(self::$sharedConnection)) { self::$sharedConnection = TestUtil::getConnection(); } + $this->connection = self::$sharedConnection; $this->sqlLoggerStack = new DebugStack(); @@ -105,6 +106,7 @@ protected function onNotSuccessfulTest(Throwable $t) : void throw new Exception($message, (int) $t->getCode(), $t); } + throw $t; } } diff --git a/tests/Doctrine/Tests/DbalPerformanceTestCase.php b/tests/Doctrine/Tests/DbalPerformanceTestCase.php index ac0beb3c5de..9ab40f058b1 100644 --- a/tests/Doctrine/Tests/DbalPerformanceTestCase.php +++ b/tests/Doctrine/Tests/DbalPerformanceTestCase.php @@ -27,9 +27,6 @@ abstract class DbalPerformanceTestCase extends DbalFunctionalTestCase */ private $runTime; - /** - * {@inheritdoc} - */ protected function assertPostConditions() : void { // If a perf test doesn't start or stop, it fails. diff --git a/tests/Doctrine/Tests/DbalPerformanceTestListener.php b/tests/Doctrine/Tests/DbalPerformanceTestListener.php index e9265c0f35f..ba46ca04a68 100644 --- a/tests/Doctrine/Tests/DbalPerformanceTestListener.php +++ b/tests/Doctrine/Tests/DbalPerformanceTestListener.php @@ -19,9 +19,6 @@ class DbalPerformanceTestListener implements TestListener /** @var string[][] */ private $timings = []; - /** - * {@inheritdoc} - */ public function endTest(Test $test, float $time) : void { // This listener only applies to performance tests.