Unverified Commit 4c03ed81 authored by Grégoire Paris's avatar Grégoire Paris Committed by GitHub

Merge pull request #3983 from greg0ire/bump-cs-libs

Bump cs libs
parents fa8b6afe d5b45211
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "b7f970513c9756e5eaaba3974429c23c", "content-hash": "6bf4905b268231ccd58bdbe30d4ecf81",
"packages": [ "packages": [
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
...@@ -478,28 +478,28 @@ ...@@ -478,28 +478,28 @@
}, },
{ {
"name": "doctrine/coding-standard", "name": "doctrine/coding-standard",
"version": "6.0.0", "version": "7.0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/coding-standard.git", "url": "https://github.com/doctrine/coding-standard.git",
"reference": "d33f69eb98b25aa51ffe3a909f0ec77000af4701" "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/coding-standard/zipball/d33f69eb98b25aa51ffe3a909f0ec77000af4701", "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/d8a60ec4da68025c42795b714f66e277dd3e11de",
"reference": "d33f69eb98b25aa51ffe3a909f0ec77000af4701", "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"php": "^7.1", "php": "^7.2",
"slevomat/coding-standard": "^5.0", "slevomat/coding-standard": "^6.0",
"squizlabs/php_codesniffer": "^3.4.0" "squizlabs/php_codesniffer": "^3.5.3"
}, },
"type": "phpcodesniffer-standard", "type": "phpcodesniffer-standard",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "6.0.x-dev" "dev-master": "7.0.x-dev"
} }
}, },
"autoload": { "autoload": {
...@@ -535,7 +535,7 @@ ...@@ -535,7 +535,7 @@
"standard", "standard",
"style" "style"
], ],
"time": "2019-03-15T12:45:47+00:00" "time": "2019-12-11T07:59:21+00:00"
}, },
{ {
"name": "doctrine/instantiator", "name": "doctrine/instantiator",
...@@ -1282,16 +1282,16 @@ ...@@ -1282,16 +1282,16 @@
}, },
{ {
"name": "phpstan/phpdoc-parser", "name": "phpstan/phpdoc-parser",
"version": "0.3.5", "version": "0.4.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git", "url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "8c4ef2aefd9788238897b678a985e1d5c8df6db4" "reference": "d8d9d4645379e677466d407034436bb155b11c65"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/8c4ef2aefd9788238897b678a985e1d5c8df6db4", "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/d8d9d4645379e677466d407034436bb155b11c65",
"reference": "8c4ef2aefd9788238897b678a985e1d5c8df6db4", "reference": "d8d9d4645379e677466d407034436bb155b11c65",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -1299,18 +1299,20 @@ ...@@ -1299,18 +1299,20 @@
}, },
"require-dev": { "require-dev": {
"consistence/coding-standard": "^3.5", "consistence/coding-standard": "^3.5",
"ergebnis/composer-normalize": "^2.0.2",
"jakub-onderka/php-parallel-lint": "^0.9.2", "jakub-onderka/php-parallel-lint": "^0.9.2",
"phing/phing": "^2.16.0", "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", "phpunit/phpunit": "^6.3",
"slevomat/coding-standard": "^4.7.2", "slevomat/coding-standard": "^4.7.2",
"squizlabs/php_codesniffer": "^3.3.2", "symfony/process": "^4.0"
"symfony/process": "^3.4 || ^4.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "0.3-dev" "dev-master": "0.4-dev"
} }
}, },
"autoload": { "autoload": {
...@@ -1325,7 +1327,7 @@ ...@@ -1325,7 +1327,7 @@
"MIT" "MIT"
], ],
"description": "PHPDoc parser with support for nullable, intersection and generic types", "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", "name": "phpstan/phpstan",
...@@ -2414,32 +2416,39 @@ ...@@ -2414,32 +2416,39 @@
}, },
{ {
"name": "slevomat/coding-standard", "name": "slevomat/coding-standard",
"version": "5.0.2", "version": "6.3.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/slevomat/coding-standard.git", "url": "https://github.com/slevomat/coding-standard.git",
"reference": "223f02b6193fe47b7b483bfa5bf75693535482dd" "reference": "b905a82255749de847fd4de607c7a4c8163f058d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/223f02b6193fe47b7b483bfa5bf75693535482dd", "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/b905a82255749de847fd4de607c7a4c8163f058d",
"reference": "223f02b6193fe47b7b483bfa5bf75693535482dd", "reference": "b905a82255749de847fd4de607c7a4c8163f058d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1", "php": "^7.1",
"phpstan/phpdoc-parser": "^0.3.1", "phpstan/phpdoc-parser": "0.4.0 - 0.4.4",
"squizlabs/php_codesniffer": "^3.4.0" "squizlabs/php_codesniffer": "^3.5.5"
}, },
"require-dev": { "require-dev": {
"jakub-onderka/php-parallel-lint": "1.0.0", "dealerdirect/phpcodesniffer-composer-installer": "0.6.2",
"phing/phing": "2.16.1", "phing/phing": "2.16.3",
"phpstan/phpstan": "0.11.1", "php-parallel-lint/php-parallel-lint": "1.2.0",
"phpstan/phpstan-phpunit": "0.11", "phpstan/phpstan": "0.12.19",
"phpstan/phpstan-strict-rules": "0.11", "phpstan/phpstan-deprecation-rules": "0.12.2",
"phpunit/phpunit": "8.0.0" "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", "type": "phpcodesniffer-standard",
"extra": {
"branch-alias": {
"dev-master": "6.x-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"SlevomatCodingStandard\\": "SlevomatCodingStandard" "SlevomatCodingStandard\\": "SlevomatCodingStandard"
...@@ -2450,20 +2459,30 @@ ...@@ -2450,20 +2459,30 @@
"MIT" "MIT"
], ],
"description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", "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", "name": "squizlabs/php_codesniffer",
"version": "3.4.0", "version": "3.5.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "379deb987e26c7cd103a7b387aea178baec96e48" "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/379deb987e26c7cd103a7b387aea178baec96e48", "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/73e2e7f57d958e7228fce50dc0c61f58f017f9f6",
"reference": "379deb987e26c7cd103a7b387aea178baec96e48", "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -2496,12 +2515,12 @@ ...@@ -2496,12 +2515,12 @@
} }
], ],
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", "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": [ "keywords": [
"phpcs", "phpcs",
"standards" "standards"
], ],
"time": "2018-12-19T23:57:18+00:00" "time": "2020-04-17T01:09:41+00:00"
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
......
...@@ -10,7 +10,7 @@ use Doctrine\DBAL\DBALException; ...@@ -10,7 +10,7 @@ use Doctrine\DBAL\DBALException;
class CacheException extends DBALException class CacheException extends DBALException
{ {
/** /**
* @return \Doctrine\DBAL\Cache\CacheException * @return CacheException
*/ */
public static function noCacheKey() public static function noCacheKey()
{ {
...@@ -18,7 +18,7 @@ class CacheException extends DBALException ...@@ -18,7 +18,7 @@ class CacheException extends DBALException
} }
/** /**
* @return \Doctrine\DBAL\Cache\CacheException * @return CacheException
*/ */
public static function noResultDriverConfigured() public static function noResultDriverConfigured()
{ {
......
...@@ -92,7 +92,7 @@ class QueryCacheProfile ...@@ -92,7 +92,7 @@ class QueryCacheProfile
} }
/** /**
* @return \Doctrine\DBAL\Cache\QueryCacheProfile * @return QueryCacheProfile
*/ */
public function setResultCacheDriver(Cache $cache) public function setResultCacheDriver(Cache $cache)
{ {
...@@ -102,7 +102,7 @@ class QueryCacheProfile ...@@ -102,7 +102,7 @@ class QueryCacheProfile
/** /**
* @param string|null $cacheKey * @param string|null $cacheKey
* *
* @return \Doctrine\DBAL\Cache\QueryCacheProfile * @return QueryCacheProfile
*/ */
public function setCacheKey($cacheKey) public function setCacheKey($cacheKey)
{ {
...@@ -112,7 +112,7 @@ class QueryCacheProfile ...@@ -112,7 +112,7 @@ class QueryCacheProfile
/** /**
* @param int $lifetime * @param int $lifetime
* *
* @return \Doctrine\DBAL\Cache\QueryCacheProfile * @return QueryCacheProfile
*/ */
public function setLifetime($lifetime) public function setLifetime($lifetime)
{ {
......
...@@ -86,6 +86,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement ...@@ -86,6 +86,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
if (! $data) { if (! $data) {
$data = []; $data = [];
} }
$data[$this->realKey] = $this->data; $data[$this->realKey] = $this->data;
$this->resultCache->save($this->cacheKey, $data, $this->lifetime); $this->resultCache->save($this->cacheKey, $data, $this->lifetime);
......
...@@ -1063,6 +1063,7 @@ class Connection implements DriverConnection ...@@ -1063,6 +1063,7 @@ class Connection implements DriverConnection
} else { } else {
$stmt->execute($params); $stmt->execute($params);
} }
$result = $stmt->rowCount(); $result = $stmt->rowCount();
} else { } else {
$result = $connection->exec($query); $result = $connection->exec($query);
...@@ -1179,9 +1180,11 @@ class Connection implements DriverConnection ...@@ -1179,9 +1180,11 @@ class Connection implements DriverConnection
return $res; return $res;
} catch (Exception $e) { } catch (Exception $e) {
$this->rollBack(); $this->rollBack();
throw $e; throw $e;
} catch (Throwable $e) { } catch (Throwable $e) {
$this->rollBack(); $this->rollBack();
throw $e; throw $e;
} }
} }
...@@ -1254,6 +1257,7 @@ class Connection implements DriverConnection ...@@ -1254,6 +1257,7 @@ class Connection implements DriverConnection
if ($logger) { if ($logger) {
$logger->startQuery('"SAVEPOINT"'); $logger->startQuery('"SAVEPOINT"');
} }
$this->createSavepoint($this->_getNestedTransactionSavePointName()); $this->createSavepoint($this->_getNestedTransactionSavePointName());
if ($logger) { if ($logger) {
$logger->stopQuery(); $logger->stopQuery();
...@@ -1274,6 +1278,7 @@ class Connection implements DriverConnection ...@@ -1274,6 +1278,7 @@ class Connection implements DriverConnection
if ($this->transactionNestingLevel === 0) { if ($this->transactionNestingLevel === 0) {
throw ConnectionException::noActiveTransaction(); throw ConnectionException::noActiveTransaction();
} }
if ($this->isRollbackOnly) { if ($this->isRollbackOnly) {
throw ConnectionException::commitFailedRollbackOnly(); throw ConnectionException::commitFailedRollbackOnly();
} }
...@@ -1298,6 +1303,7 @@ class Connection implements DriverConnection ...@@ -1298,6 +1303,7 @@ class Connection implements DriverConnection
if ($logger) { if ($logger) {
$logger->startQuery('"RELEASE SAVEPOINT"'); $logger->startQuery('"RELEASE SAVEPOINT"');
} }
$this->releaseSavepoint($this->_getNestedTransactionSavePointName()); $this->releaseSavepoint($this->_getNestedTransactionSavePointName());
if ($logger) { if ($logger) {
$logger->stopQuery(); $logger->stopQuery();
...@@ -1354,6 +1360,7 @@ class Connection implements DriverConnection ...@@ -1354,6 +1360,7 @@ class Connection implements DriverConnection
if ($logger) { if ($logger) {
$logger->startQuery('"ROLLBACK"'); $logger->startQuery('"ROLLBACK"');
} }
$this->transactionNestingLevel = 0; $this->transactionNestingLevel = 0;
$connection->rollBack(); $connection->rollBack();
$this->isRollbackOnly = false; $this->isRollbackOnly = false;
...@@ -1368,6 +1375,7 @@ class Connection implements DriverConnection ...@@ -1368,6 +1375,7 @@ class Connection implements DriverConnection
if ($logger) { if ($logger) {
$logger->startQuery('"ROLLBACK TO SAVEPOINT"'); $logger->startQuery('"ROLLBACK TO SAVEPOINT"');
} }
$this->rollbackSavepoint($this->_getNestedTransactionSavePointName()); $this->rollbackSavepoint($this->_getNestedTransactionSavePointName());
--$this->transactionNestingLevel; --$this->transactionNestingLevel;
if ($logger) { if ($logger) {
...@@ -1479,6 +1487,7 @@ class Connection implements DriverConnection ...@@ -1479,6 +1487,7 @@ class Connection implements DriverConnection
if ($this->transactionNestingLevel === 0) { if ($this->transactionNestingLevel === 0) {
throw ConnectionException::noActiveTransaction(); throw ConnectionException::noActiveTransaction();
} }
$this->isRollbackOnly = true; $this->isRollbackOnly = true;
} }
...@@ -1555,6 +1564,7 @@ class Connection implements DriverConnection ...@@ -1555,6 +1564,7 @@ class Connection implements DriverConnection
} else { } else {
$stmt->bindValue($bindIndex, $value); $stmt->bindValue($bindIndex, $value);
} }
++$bindIndex; ++$bindIndex;
} }
} else { } else {
...@@ -1584,6 +1594,7 @@ class Connection implements DriverConnection ...@@ -1584,6 +1594,7 @@ class Connection implements DriverConnection
if (is_string($type)) { if (is_string($type)) {
$type = Type::getType($type); $type = Type::getType($type);
} }
if ($type instanceof Type) { if ($type instanceof Type) {
$value = $type->convertToDatabaseValue($value, $this->getDatabasePlatform()); $value = $type->convertToDatabaseValue($value, $this->getDatabasePlatform());
$bindingType = $type->getBindingType(); $bindingType = $type->getBindingType();
...@@ -1623,6 +1634,7 @@ class Connection implements DriverConnection ...@@ -1623,6 +1634,7 @@ class Connection implements DriverConnection
} else { } else {
$resolvedParams[$bindIndex] = $value; $resolvedParams[$bindIndex] = $value;
} }
++$bindIndex; ++$bindIndex;
} }
} else { } else {
......
...@@ -8,7 +8,7 @@ namespace Doctrine\DBAL; ...@@ -8,7 +8,7 @@ namespace Doctrine\DBAL;
class ConnectionException extends DBALException class ConnectionException extends DBALException
{ {
/** /**
* @return \Doctrine\DBAL\ConnectionException * @return ConnectionException
*/ */
public static function commitFailedRollbackOnly() public static function commitFailedRollbackOnly()
{ {
...@@ -16,7 +16,7 @@ class ConnectionException extends DBALException ...@@ -16,7 +16,7 @@ class ConnectionException extends DBALException
} }
/** /**
* @return \Doctrine\DBAL\ConnectionException * @return ConnectionException
*/ */
public static function noActiveTransaction() public static function noActiveTransaction()
{ {
...@@ -24,7 +24,7 @@ class ConnectionException extends DBALException ...@@ -24,7 +24,7 @@ class ConnectionException extends DBALException
} }
/** /**
* @return \Doctrine\DBAL\ConnectionException * @return ConnectionException
*/ */
public static function savepointsNotSupported() public static function savepointsNotSupported()
{ {
...@@ -32,7 +32,7 @@ class ConnectionException extends DBALException ...@@ -32,7 +32,7 @@ class ConnectionException extends DBALException
} }
/** /**
* @return \Doctrine\DBAL\ConnectionException * @return ConnectionException
*/ */
public static function mayNotAlterNestedTransactionWithSavepointsInTransaction() public static function mayNotAlterNestedTransactionWithSavepointsInTransaction()
{ {
......
...@@ -95,6 +95,7 @@ class MasterSlaveConnection extends Connection ...@@ -95,6 +95,7 @@ class MasterSlaveConnection extends Connection
if (! isset($params['slaves'], $params['master'])) { if (! isset($params['slaves'], $params['master'])) {
throw new InvalidArgumentException('master or slaves configuration missing'); throw new InvalidArgumentException('master or slaves configuration missing');
} }
if (count($params['slaves']) === 0) { if (count($params['slaves']) === 0) {
throw new InvalidArgumentException('You have to configure at least one slaves.'); throw new InvalidArgumentException('You have to configure at least one slaves.');
} }
......
...@@ -30,7 +30,7 @@ class DBALException extends Exception ...@@ -30,7 +30,7 @@ class DBALException extends Exception
/** /**
* @param string $method * @param string $method
* *
* @return \Doctrine\DBAL\DBALException * @return DBALException
*/ */
public static function notSupported($method) public static function notSupported($method)
{ {
...@@ -89,7 +89,7 @@ class DBALException extends Exception ...@@ -89,7 +89,7 @@ class DBALException extends Exception
} }
/** /**
* @return \Doctrine\DBAL\DBALException * @return DBALException
*/ */
public static function invalidPdoInstance() public static function invalidPdoInstance()
{ {
...@@ -102,7 +102,7 @@ class DBALException extends Exception ...@@ -102,7 +102,7 @@ class DBALException extends Exception
/** /**
* @param string|null $url The URL that was provided in the connection parameters (if any). * @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) public static function driverRequired($url = null)
{ {
...@@ -124,7 +124,7 @@ class DBALException extends Exception ...@@ -124,7 +124,7 @@ class DBALException extends Exception
* @param string $unknownDriverName * @param string $unknownDriverName
* @param string[] $knownDrivers * @param string[] $knownDrivers
* *
* @return \Doctrine\DBAL\DBALException * @return DBALException
*/ */
public static function unknownDriver($unknownDriverName, array $knownDrivers) public static function unknownDriver($unknownDriverName, array $knownDrivers)
{ {
...@@ -144,6 +144,7 @@ class DBALException extends Exception ...@@ -144,6 +144,7 @@ class DBALException extends Exception
if ($params) { if ($params) {
$msg .= ' with params ' . self::formatParameters($params); $msg .= ' with params ' . self::formatParameters($params);
} }
$msg .= ":\n\n" . $driverEx->getMessage(); $msg .= ":\n\n" . $driverEx->getMessage();
return static::wrapException($driver, $driverEx, $msg); return static::wrapException($driver, $driverEx, $msg);
...@@ -165,6 +166,7 @@ class DBALException extends Exception ...@@ -165,6 +166,7 @@ class DBALException extends Exception
if ($driverEx instanceof DriverException) { if ($driverEx instanceof DriverException) {
return $driverEx; return $driverEx;
} }
if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof DriverExceptionInterface) { if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof DriverExceptionInterface) {
return $driver->convertException($msg, $driverEx); return $driver->convertException($msg, $driverEx);
} }
...@@ -201,7 +203,7 @@ class DBALException extends Exception ...@@ -201,7 +203,7 @@ class DBALException extends Exception
/** /**
* @param string $wrapperClass * @param string $wrapperClass
* *
* @return \Doctrine\DBAL\DBALException * @return DBALException
*/ */
public static function invalidWrapperClass($wrapperClass) public static function invalidWrapperClass($wrapperClass)
{ {
...@@ -212,7 +214,7 @@ class DBALException extends Exception ...@@ -212,7 +214,7 @@ class DBALException extends Exception
/** /**
* @param string $driverClass * @param string $driverClass
* *
* @return \Doctrine\DBAL\DBALException * @return DBALException
*/ */
public static function invalidDriverClass($driverClass) public static function invalidDriverClass($driverClass)
{ {
...@@ -222,7 +224,7 @@ class DBALException extends Exception ...@@ -222,7 +224,7 @@ class DBALException extends Exception
/** /**
* @param string $tableName * @param string $tableName
* *
* @return \Doctrine\DBAL\DBALException * @return DBALException
*/ */
public static function invalidTableName($tableName) public static function invalidTableName($tableName)
{ {
...@@ -232,7 +234,7 @@ class DBALException extends Exception ...@@ -232,7 +234,7 @@ class DBALException extends Exception
/** /**
* @param string $tableName * @param string $tableName
* *
* @return \Doctrine\DBAL\DBALException * @return DBALException
*/ */
public static function noColumnsSpecifiedForTable($tableName) public static function noColumnsSpecifiedForTable($tableName)
{ {
...@@ -240,7 +242,7 @@ class DBALException extends Exception ...@@ -240,7 +242,7 @@ class DBALException extends Exception
} }
/** /**
* @return \Doctrine\DBAL\DBALException * @return DBALException
*/ */
public static function limitOffsetInvalid() public static function limitOffsetInvalid()
{ {
...@@ -250,7 +252,7 @@ class DBALException extends Exception ...@@ -250,7 +252,7 @@ class DBALException extends Exception
/** /**
* @param string $name * @param string $name
* *
* @return \Doctrine\DBAL\DBALException * @return DBALException
*/ */
public static function typeExists($name) public static function typeExists($name)
{ {
...@@ -260,7 +262,7 @@ class DBALException extends Exception ...@@ -260,7 +262,7 @@ class DBALException extends Exception
/** /**
* @param string $name * @param string $name
* *
* @return \Doctrine\DBAL\DBALException * @return DBALException
*/ */
public static function unknownColumnType($name) public static function unknownColumnType($name)
{ {
...@@ -276,7 +278,7 @@ class DBALException extends Exception ...@@ -276,7 +278,7 @@ class DBALException extends Exception
/** /**
* @param string $name * @param string $name
* *
* @return \Doctrine\DBAL\DBALException * @return DBALException
*/ */
public static function typeNotFound($name) public static function typeNotFound($name)
{ {
......
...@@ -32,8 +32,10 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -32,8 +32,10 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
switch ($exception->getErrorCode()) { switch ($exception->getErrorCode()) {
case '1213': case '1213':
return new Exception\DeadlockException($message, $exception); return new Exception\DeadlockException($message, $exception);
case '1205': case '1205':
return new Exception\LockWaitTimeoutException($message, $exception); return new Exception\LockWaitTimeoutException($message, $exception);
case '1050': case '1050':
return new Exception\TableExistsException($message, $exception); return new Exception\TableExistsException($message, $exception);
...@@ -123,6 +125,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -123,6 +125,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
if (version_compare($oracleMysqlVersion, '8', '>=')) { if (version_compare($oracleMysqlVersion, '8', '>=')) {
return new MySQL80Platform(); return new MySQL80Platform();
} }
if (version_compare($oracleMysqlVersion, '5.7.9', '>=')) { if (version_compare($oracleMysqlVersion, '5.7.9', '>=')) {
return new MySQL57Platform(); return new MySQL57Platform();
} }
...@@ -151,6 +154,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -151,6 +154,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
'<major_version>.<minor_version>.<patch_version>' '<major_version>.<minor_version>.<patch_version>'
); );
} }
$majorVersion = $versionParts['major']; $majorVersion = $versionParts['major'];
$minorVersion = $versionParts['minor'] ?? 0; $minorVersion = $versionParts['minor'] ?? 0;
$patchVersion = $versionParts['patch'] ?? null; $patchVersion = $versionParts['patch'] ?? null;
......
...@@ -33,6 +33,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri ...@@ -33,6 +33,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri
case '40001': case '40001':
case '40P01': case '40P01':
return new Exception\DeadlockException($message, $exception); return new Exception\DeadlockException($message, $exception);
case '0A000': case '0A000':
// Foreign key constraint violations during a TRUNCATE operation // Foreign key constraint violations during a TRUNCATE operation
// are considered "feature not supported" in PostgreSQL. // are considered "feature not supported" in PostgreSQL.
...@@ -41,6 +42,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri ...@@ -41,6 +42,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri
} }
break; break;
case '23502': case '23502':
return new Exception\NotNullConstraintViolationException($message, $exception); return new Exception\NotNullConstraintViolationException($message, $exception);
......
...@@ -32,31 +32,41 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr ...@@ -32,31 +32,41 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
case '-307': case '-307':
case '-684': case '-684':
return new Exception\DeadlockException($message, $exception); return new Exception\DeadlockException($message, $exception);
case '-210': case '-210':
case '-1175': case '-1175':
case '-1281': case '-1281':
return new Exception\LockWaitTimeoutException($message, $exception); return new Exception\LockWaitTimeoutException($message, $exception);
case '-100': case '-100':
case '-103': case '-103':
case '-832': case '-832':
return new Exception\ConnectionException($message, $exception); return new Exception\ConnectionException($message, $exception);
case '-143': case '-143':
return new Exception\InvalidFieldNameException($message, $exception); return new Exception\InvalidFieldNameException($message, $exception);
case '-193': case '-193':
case '-196': case '-196':
return new Exception\UniqueConstraintViolationException($message, $exception); return new Exception\UniqueConstraintViolationException($message, $exception);
case '-194': case '-194':
case '-198': case '-198':
return new Exception\ForeignKeyConstraintViolationException($message, $exception); return new Exception\ForeignKeyConstraintViolationException($message, $exception);
case '-144': case '-144':
return new Exception\NonUniqueFieldNameException($message, $exception); return new Exception\NonUniqueFieldNameException($message, $exception);
case '-184': case '-184':
case '-195': case '-195':
return new Exception\NotNullConstraintViolationException($message, $exception); return new Exception\NotNullConstraintViolationException($message, $exception);
case '-131': case '-131':
return new Exception\SyntaxErrorException($message, $exception); return new Exception\SyntaxErrorException($message, $exception);
case '-110': case '-110':
return new Exception\TableExistsException($message, $exception); return new Exception\TableExistsException($message, $exception);
case '-141': case '-141':
case '-1041': case '-1041':
return new Exception\TableNotFoundException($message, $exception); return new Exception\TableNotFoundException($message, $exception);
...@@ -90,10 +100,13 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr ...@@ -90,10 +100,13 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
switch (true) { switch (true) {
case version_compare($version, '16', '>='): case version_compare($version, '16', '>='):
return new SQLAnywhere16Platform(); return new SQLAnywhere16Platform();
case version_compare($version, '12', '>='): case version_compare($version, '12', '>='):
return new SQLAnywhere12Platform(); return new SQLAnywhere12Platform();
case version_compare($version, '11', '>='): case version_compare($version, '11', '>='):
return new SQLAnywhere11Platform(); return new SQLAnywhere11Platform();
default: default:
return new SQLAnywherePlatform(); return new SQLAnywherePlatform();
} }
......
...@@ -6,8 +6,6 @@ use Doctrine\DBAL\Driver\Connection; ...@@ -6,8 +6,6 @@ use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use stdClass; use stdClass;
use const DB2_AUTOCOMMIT_OFF;
use const DB2_AUTOCOMMIT_ON;
use function assert; use function assert;
use function db2_autocommit; use function db2_autocommit;
use function db2_commit; use function db2_commit;
...@@ -25,6 +23,8 @@ use function db2_server_info; ...@@ -25,6 +23,8 @@ use function db2_server_info;
use function db2_stmt_errormsg; use function db2_stmt_errormsg;
use function func_get_args; use function func_get_args;
use function is_bool; use function is_bool;
use const DB2_AUTOCOMMIT_OFF;
use const DB2_AUTOCOMMIT_ON;
class DB2Connection implements Connection, ServerInfoAwareConnection class DB2Connection implements Connection, ServerInfoAwareConnection
{ {
...@@ -61,8 +61,8 @@ class DB2Connection implements Connection, ServerInfoAwareConnection ...@@ -61,8 +61,8 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
*/ */
public function getServerVersion() public function getServerVersion()
{ {
/** @var stdClass $serverInfo */
$serverInfo = db2_server_info($this->conn); $serverInfo = db2_server_info($this->conn);
assert($serverInfo instanceof stdClass);
return $serverInfo->DBMS_VER; return $serverInfo->DBMS_VER;
} }
......
...@@ -12,12 +12,6 @@ use ReflectionClass; ...@@ -12,12 +12,6 @@ use ReflectionClass;
use ReflectionObject; use ReflectionObject;
use ReflectionProperty; use ReflectionProperty;
use stdClass; 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 array_change_key_case;
use function db2_bind_param; use function db2_bind_param;
use function db2_execute; use function db2_execute;
...@@ -45,6 +39,12 @@ use function stream_copy_to_stream; ...@@ -45,6 +39,12 @@ use function stream_copy_to_stream;
use function stream_get_meta_data; use function stream_get_meta_data;
use function strtolower; use function strtolower;
use function tmpfile; 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 class DB2Statement implements IteratorAggregate, Statement
{ {
...@@ -309,12 +309,16 @@ class DB2Statement implements IteratorAggregate, Statement ...@@ -309,12 +309,16 @@ class DB2Statement implements IteratorAggregate, Statement
while (($row = $this->fetch(...func_get_args())) !== false) { while (($row = $this->fetch(...func_get_args())) !== false) {
$rows[] = $row; $rows[] = $row;
} }
break; break;
case FetchMode::COLUMN: case FetchMode::COLUMN:
while (($row = $this->fetchColumn()) !== false) { while (($row = $this->fetchColumn()) !== false) {
$rows[] = $row; $rows[] = $row;
} }
break; break;
default: default:
while (($row = $this->fetch($fetchMode)) !== false) { while (($row = $this->fetch($fetchMode)) !== false) {
$rows[] = $row; $rows[] = $row;
......
...@@ -7,12 +7,6 @@ use Doctrine\DBAL\Driver\PingableConnection; ...@@ -7,12 +7,6 @@ use Doctrine\DBAL\Driver\PingableConnection;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use mysqli; 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 defined;
use function floor; use function floor;
use function func_get_args; use function func_get_args;
...@@ -26,6 +20,12 @@ use function restore_error_handler; ...@@ -26,6 +20,12 @@ use function restore_error_handler;
use function set_error_handler; use function set_error_handler;
use function sprintf; use function sprintf;
use function stripos; 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 class MysqliConnection implements Connection, PingableConnection, ServerInfoAwareConnection
{ {
......
...@@ -224,6 +224,7 @@ class MysqliStatement implements IteratorAggregate, Statement ...@@ -224,6 +224,7 @@ class MysqliStatement implements IteratorAggregate, Statement
if (get_resource_type($value) !== 'stream') { if (get_resource_type($value) !== 'stream') {
throw new InvalidArgumentException('Resources passed with the LARGE_OBJECT parameter type must be stream resources.'); throw new InvalidArgumentException('Resources passed with the LARGE_OBJECT parameter type must be stream resources.');
} }
$streams[$parameter] = $value; $streams[$parameter] = $value;
$values[$parameter] = null; $values[$parameter] = null;
continue; continue;
......
...@@ -6,8 +6,6 @@ use Doctrine\DBAL\Driver\Connection; ...@@ -6,8 +6,6 @@ use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use UnexpectedValueException; use UnexpectedValueException;
use const OCI_COMMIT_ON_SUCCESS;
use const OCI_NO_AUTO_COMMIT;
use function addcslashes; use function addcslashes;
use function func_get_args; use function func_get_args;
use function is_float; use function is_float;
...@@ -21,6 +19,8 @@ use function oci_server_version; ...@@ -21,6 +19,8 @@ use function oci_server_version;
use function preg_match; use function preg_match;
use function sprintf; use function sprintf;
use function str_replace; use function str_replace;
use const OCI_COMMIT_ON_SUCCESS;
use const OCI_NO_AUTO_COMMIT;
/** /**
* OCI8 implementation of the Connection interface. * OCI8 implementation of the Connection interface.
...@@ -129,6 +129,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection ...@@ -129,6 +129,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
if (is_int($value) || is_float($value)) { if (is_int($value) || is_float($value)) {
return $value; return $value;
} }
$value = str_replace("'", "''", $value); $value = str_replace("'", "''", $value);
return "'" . addcslashes($value, "\000\n\r\\\032") . "'"; return "'" . addcslashes($value, "\000\n\r\\\032") . "'";
...@@ -193,6 +194,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection ...@@ -193,6 +194,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
if (! oci_commit($this->dbh)) { if (! oci_commit($this->dbh)) {
throw OCI8Exception::fromErrorInfo($this->errorInfo()); throw OCI8Exception::fromErrorInfo($this->errorInfo());
} }
$this->executeMode = OCI_COMMIT_ON_SUCCESS; $this->executeMode = OCI_COMMIT_ON_SUCCESS;
return true; return true;
...@@ -206,6 +208,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection ...@@ -206,6 +208,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
if (! oci_rollback($this->dbh)) { if (! oci_rollback($this->dbh)) {
throw OCI8Exception::fromErrorInfo($this->errorInfo()); throw OCI8Exception::fromErrorInfo($this->errorInfo());
} }
$this->executeMode = OCI_COMMIT_ON_SUCCESS; $this->executeMode = OCI_COMMIT_ON_SUCCESS;
return true; return true;
......
...@@ -12,7 +12,7 @@ class OCI8Exception extends AbstractDriverException ...@@ -12,7 +12,7 @@ class OCI8Exception extends AbstractDriverException
/** /**
* @param mixed[]|false $error * @param mixed[]|false $error
* *
* @return \Doctrine\DBAL\Driver\OCI8\OCI8Exception * @return OCI8Exception
*/ */
public static function fromErrorInfo($error) public static function fromErrorInfo($error)
{ {
......
...@@ -9,19 +9,6 @@ use Doctrine\DBAL\ParameterType; ...@@ -9,19 +9,6 @@ use Doctrine\DBAL\ParameterType;
use InvalidArgumentException; use InvalidArgumentException;
use IteratorAggregate; use IteratorAggregate;
use PDO; 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 array_key_exists;
use function assert; use function assert;
use function count; use function count;
...@@ -43,6 +30,19 @@ use function preg_match; ...@@ -43,6 +30,19 @@ use function preg_match;
use function preg_quote; use function preg_quote;
use function sprintf; use function sprintf;
use function substr; 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. * The OCI8 implementation of the Statement interface.
......
...@@ -36,9 +36,11 @@ class Driver extends AbstractDB2Driver ...@@ -36,9 +36,11 @@ class Driver extends AbstractDB2Driver
if (isset($params['host'])) { if (isset($params['host'])) {
$dsn .= 'HOSTNAME=' . $params['host'] . ';'; $dsn .= 'HOSTNAME=' . $params['host'] . ';';
} }
if (isset($params['port'])) { if (isset($params['port'])) {
$dsn .= 'PORT=' . $params['port'] . ';'; $dsn .= 'PORT=' . $params['port'] . ';';
} }
$dsn .= 'PROTOCOL=TCPIP;'; $dsn .= 'PROTOCOL=TCPIP;';
if (isset($params['dbname'])) { if (isset($params['dbname'])) {
$dsn .= 'DATABASE=' . $params['dbname'] . ';'; $dsn .= 'DATABASE=' . $params['dbname'] . ';';
......
...@@ -44,15 +44,19 @@ class Driver extends AbstractMySQLDriver ...@@ -44,15 +44,19 @@ class Driver extends AbstractMySQLDriver
if (isset($params['host']) && $params['host'] !== '') { if (isset($params['host']) && $params['host'] !== '') {
$dsn .= 'host=' . $params['host'] . ';'; $dsn .= 'host=' . $params['host'] . ';';
} }
if (isset($params['port'])) { if (isset($params['port'])) {
$dsn .= 'port=' . $params['port'] . ';'; $dsn .= 'port=' . $params['port'] . ';';
} }
if (isset($params['dbname'])) { if (isset($params['dbname'])) {
$dsn .= 'dbname=' . $params['dbname'] . ';'; $dsn .= 'dbname=' . $params['dbname'] . ';';
} }
if (isset($params['unix_socket'])) { if (isset($params['unix_socket'])) {
$dsn .= 'unix_socket=' . $params['unix_socket'] . ';'; $dsn .= 'unix_socket=' . $params['unix_socket'] . ';';
} }
if (isset($params['charset'])) { if (isset($params['charset'])) {
$dsn .= 'charset=' . $params['charset'] . ';'; $dsn .= 'charset=' . $params['charset'] . ';';
} }
......
...@@ -5,13 +5,13 @@ namespace Doctrine\DBAL\Driver; ...@@ -5,13 +5,13 @@ namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use PDO; use PDO;
use const E_USER_DEPRECATED;
use function array_slice; use function array_slice;
use function assert; use function assert;
use function func_get_args; use function func_get_args;
use function is_array; use function is_array;
use function sprintf; use function sprintf;
use function trigger_error; use function trigger_error;
use const E_USER_DEPRECATED;
/** /**
* The PDO implementation of the Statement interface. * The PDO implementation of the Statement interface.
......
...@@ -11,7 +11,6 @@ use PDO; ...@@ -11,7 +11,6 @@ use PDO;
use ReflectionClass; use ReflectionClass;
use ReflectionObject; use ReflectionObject;
use stdClass; use stdClass;
use const SASQL_BOTH;
use function array_key_exists; use function array_key_exists;
use function func_get_args; use function func_get_args;
use function func_num_args; use function func_num_args;
...@@ -35,6 +34,7 @@ use function sasql_stmt_field_count; ...@@ -35,6 +34,7 @@ use function sasql_stmt_field_count;
use function sasql_stmt_reset; use function sasql_stmt_reset;
use function sasql_stmt_result_metadata; use function sasql_stmt_result_metadata;
use function sprintf; use function sprintf;
use const SASQL_BOTH;
/** /**
* SAP SQL Anywhere implementation of the Statement interface. * SAP SQL Anywhere implementation of the Statement interface.
...@@ -258,12 +258,14 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement ...@@ -258,12 +258,14 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
while (($row = $this->fetch(...func_get_args())) !== false) { while (($row = $this->fetch(...func_get_args())) !== false) {
$rows[] = $row; $rows[] = $row;
} }
break; break;
case FetchMode::COLUMN: case FetchMode::COLUMN:
while (($row = $this->fetchColumn()) !== false) { while (($row = $this->fetchColumn()) !== false) {
$rows[] = $row; $rows[] = $row;
} }
break; break;
default: default:
......
...@@ -5,7 +5,6 @@ namespace Doctrine\DBAL\Driver\SQLSrv; ...@@ -5,7 +5,6 @@ namespace Doctrine\DBAL\Driver\SQLSrv;
use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use const SQLSRV_ERR_ERRORS;
use function func_get_args; use function func_get_args;
use function is_float; use function is_float;
use function is_int; use function is_int;
...@@ -20,6 +19,7 @@ use function sqlsrv_rollback; ...@@ -20,6 +19,7 @@ use function sqlsrv_rollback;
use function sqlsrv_rows_affected; use function sqlsrv_rows_affected;
use function sqlsrv_server_info; use function sqlsrv_server_info;
use function str_replace; use function str_replace;
use const SQLSRV_ERR_ERRORS;
/** /**
* SQL Server implementation for the Connection interface. * SQL Server implementation for the Connection interface.
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
namespace Doctrine\DBAL\Driver\SQLSrv; namespace Doctrine\DBAL\Driver\SQLSrv;
use Doctrine\DBAL\Driver\AbstractDriverException; use Doctrine\DBAL\Driver\AbstractDriverException;
use const SQLSRV_ERR_ERRORS;
use function rtrim; use function rtrim;
use function sqlsrv_errors; use function sqlsrv_errors;
use const SQLSRV_ERR_ERRORS;
/** /**
* @psalm-immutable * @psalm-immutable
...@@ -15,7 +15,7 @@ class SQLSrvException extends AbstractDriverException ...@@ -15,7 +15,7 @@ class SQLSrvException extends AbstractDriverException
/** /**
* Helper method to turn sql server errors into exception. * Helper method to turn sql server errors into exception.
* *
* @return \Doctrine\DBAL\Driver\SQLSrv\SQLSrvException * @return SQLSrvException
*/ */
public static function fromSqlSrvErrors() public static function fromSqlSrvErrors()
{ {
......
...@@ -8,12 +8,6 @@ use Doctrine\DBAL\FetchMode; ...@@ -8,12 +8,6 @@ use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use IteratorAggregate; use IteratorAggregate;
use PDO; 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 array_key_exists;
use function count; use function count;
use function func_get_args; use function func_get_args;
...@@ -34,6 +28,12 @@ use function sqlsrv_prepare; ...@@ -34,6 +28,12 @@ use function sqlsrv_prepare;
use function sqlsrv_rows_affected; use function sqlsrv_rows_affected;
use function SQLSRV_SQLTYPE_VARBINARY; use function SQLSRV_SQLTYPE_VARBINARY;
use function stripos; 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. * SQL Server Statement.
...@@ -387,12 +387,14 @@ class SQLSrvStatement implements IteratorAggregate, Statement ...@@ -387,12 +387,14 @@ class SQLSrvStatement implements IteratorAggregate, Statement
while (($row = $this->fetch(...func_get_args())) !== false) { while (($row = $this->fetch(...func_get_args())) !== false) {
$rows[] = $row; $rows[] = $row;
} }
break; break;
case FetchMode::COLUMN: case FetchMode::COLUMN:
while (($row = $this->fetchColumn()) !== false) { while (($row = $this->fetchColumn()) !== false) {
$rows[] = $row; $rows[] = $row;
} }
break; break;
default: default:
......
...@@ -130,6 +130,7 @@ final class DriverManager ...@@ -130,6 +130,7 @@ final class DriverManager
if (! $config) { if (! $config) {
$config = new Configuration(); $config = new Configuration();
} }
if (! $eventManager) { if (! $eventManager) {
$eventManager = new EventManager(); $eventManager = new EventManager();
} }
...@@ -273,12 +274,15 @@ final class DriverManager ...@@ -273,12 +274,15 @@ final class DriverManager
if (isset($url['host'])) { if (isset($url['host'])) {
$params['host'] = $url['host']; $params['host'] = $url['host'];
} }
if (isset($url['port'])) { if (isset($url['port'])) {
$params['port'] = $url['port']; $params['port'] = $url['port'];
} }
if (isset($url['user'])) { if (isset($url['user'])) {
$params['user'] = $url['user']; $params['user'] = $url['user'];
} }
if (isset($url['pass'])) { if (isset($url['pass'])) {
$params['password'] = $url['pass']; $params['password'] = $url['pass'];
} }
......
...@@ -5,11 +5,11 @@ namespace Doctrine\DBAL\Event\Listeners; ...@@ -5,11 +5,11 @@ namespace Doctrine\DBAL\Event\Listeners;
use Doctrine\Common\EventSubscriber; use Doctrine\Common\EventSubscriber;
use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events; use Doctrine\DBAL\Events;
use const CASE_UPPER;
use function array_change_key_case; use function array_change_key_case;
use function array_merge; use function array_merge;
use function count; use function count;
use function implode; use function implode;
use const CASE_UPPER;
/** /**
* Should be used when Oracle Server default environment does not match the Doctrine requirements. * Should be used when Oracle Server default environment does not match the Doctrine requirements.
...@@ -57,6 +57,7 @@ class OracleSessionInit implements EventSubscriber ...@@ -57,6 +57,7 @@ class OracleSessionInit implements EventSubscriber
$vars[] = $option . " = '" . $value . "'"; $vars[] = $option . " = '" . $value . "'";
} }
} }
$sql = 'ALTER SESSION SET ' . implode(' ', $vars); $sql = 'ALTER SESSION SET ' . implode(' ', $vars);
$args->getConnection()->executeUpdate($sql); $args->getConnection()->executeUpdate($sql);
} }
......
...@@ -62,7 +62,7 @@ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs ...@@ -62,7 +62,7 @@ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs
* *
* @param string|string[] $sql * @param string|string[] $sql
* *
* @return \Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs * @return SchemaAlterTableAddColumnEventArgs
*/ */
public function addSql($sql) public function addSql($sql)
{ {
......
...@@ -62,7 +62,7 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs ...@@ -62,7 +62,7 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
* *
* @param string|string[] $sql * @param string|string[] $sql
* *
* @return \Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs * @return SchemaAlterTableChangeColumnEventArgs
*/ */
public function addSql($sql) public function addSql($sql)
{ {
......
...@@ -49,7 +49,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs ...@@ -49,7 +49,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs
* *
* @param string|string[] $sql * @param string|string[] $sql
* *
* @return \Doctrine\DBAL\Event\SchemaAlterTableEventArgs * @return SchemaAlterTableEventArgs
*/ */
public function addSql($sql) public function addSql($sql)
{ {
......
...@@ -62,7 +62,7 @@ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs ...@@ -62,7 +62,7 @@ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs
* *
* @param string|string[] $sql * @param string|string[] $sql
* *
* @return \Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs * @return SchemaAlterTableRemoveColumnEventArgs
*/ */
public function addSql($sql) public function addSql($sql)
{ {
......
...@@ -77,7 +77,7 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs ...@@ -77,7 +77,7 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
* *
* @param string|string[] $sql * @param string|string[] $sql
* *
* @return \Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs * @return SchemaAlterTableRenameColumnEventArgs
*/ */
public function addSql($sql) public function addSql($sql)
{ {
......
...@@ -47,7 +47,7 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs ...@@ -47,7 +47,7 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
* Allows to clear the column which means the column will be excluded from * Allows to clear the column which means the column will be excluded from
* tables column list. * tables column list.
* *
* @return \Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs * @return SchemaColumnDefinitionEventArgs
*/ */
public function setColumn(?Column $column = null) public function setColumn(?Column $column = null)
{ {
......
...@@ -62,7 +62,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs ...@@ -62,7 +62,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
* *
* @param string|string[] $sql * @param string|string[] $sql
* *
* @return \Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs * @return SchemaCreateTableColumnEventArgs
*/ */
public function addSql($sql) public function addSql($sql)
{ {
......
...@@ -77,7 +77,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs ...@@ -77,7 +77,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
* *
* @param string|string[] $sql * @param string|string[] $sql
* *
* @return \Doctrine\DBAL\Event\SchemaCreateTableEventArgs * @return SchemaCreateTableEventArgs
*/ */
public function addSql($sql) public function addSql($sql)
{ {
......
...@@ -50,7 +50,7 @@ class SchemaDropTableEventArgs extends SchemaEventArgs ...@@ -50,7 +50,7 @@ class SchemaDropTableEventArgs extends SchemaEventArgs
/** /**
* @param string $sql * @param string $sql
* *
* @return \Doctrine\DBAL\Event\SchemaDropTableEventArgs * @return SchemaDropTableEventArgs
*/ */
public function setSql($sql) public function setSql($sql)
{ {
......
...@@ -13,7 +13,7 @@ class SchemaEventArgs extends EventArgs ...@@ -13,7 +13,7 @@ class SchemaEventArgs extends EventArgs
private $preventDefault = false; private $preventDefault = false;
/** /**
* @return \Doctrine\DBAL\Event\SchemaEventArgs * @return SchemaEventArgs
*/ */
public function preventDefault() public function preventDefault()
{ {
......
...@@ -8,10 +8,10 @@ use Doctrine\DBAL\DriverManager; ...@@ -8,10 +8,10 @@ use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\LockMode; use Doctrine\DBAL\LockMode;
use Throwable; use Throwable;
use const CASE_LOWER;
use function array_change_key_case; use function array_change_key_case;
use function assert; use function assert;
use function is_int; use function is_int;
use const CASE_LOWER;
/** /**
* Table ID Generator for those poor languages that are missing sequences. * Table ID Generator for those poor languages that are missing sequences.
...@@ -72,6 +72,7 @@ class TableGenerator ...@@ -72,6 +72,7 @@ class TableGenerator
if ($params['driver'] === 'pdo_sqlite') { if ($params['driver'] === 'pdo_sqlite') {
throw new DBALException('Cannot use TableGenerator with SQLite.'); throw new DBALException('Cannot use TableGenerator with SQLite.');
} }
$this->conn = DriverManager::getConnection($params, $conn->getConfiguration(), $conn->getEventManager()); $this->conn = DriverManager::getConnection($params, $conn->getConfiguration(), $conn->getEventManager());
$this->generatorTableName = $generatorTableName; $this->generatorTableName = $generatorTableName;
} }
...@@ -141,6 +142,7 @@ class TableGenerator ...@@ -141,6 +142,7 @@ class TableGenerator
$this->conn->commit(); $this->conn->commit();
} catch (Throwable $e) { } catch (Throwable $e) {
$this->conn->rollBack(); $this->conn->rollBack();
throw new DBALException('Error occurred while generating ID with TableGenerator, aborted generation: ' . $e->getMessage(), 0, $e); throw new DBALException('Error occurred while generating ID with TableGenerator, aborted generation: ' . $e->getMessage(), 0, $e);
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
namespace Doctrine\DBAL\Logging; namespace Doctrine\DBAL\Logging;
use const PHP_EOL;
use function var_dump; use function var_dump;
use const PHP_EOL;
/** /**
* A SQL logger that logs to the standard output using echo/var_dump. * A SQL logger that logs to the standard output using echo/var_dump.
......
...@@ -28,7 +28,6 @@ use Doctrine\DBAL\Types; ...@@ -28,7 +28,6 @@ use Doctrine\DBAL\Types;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use InvalidArgumentException; use InvalidArgumentException;
use UnexpectedValueException; use UnexpectedValueException;
use const E_USER_DEPRECATED;
use function addcslashes; use function addcslashes;
use function array_map; use function array_map;
use function array_merge; use function array_merge;
...@@ -55,6 +54,7 @@ use function strpos; ...@@ -55,6 +54,7 @@ use function strpos;
use function strtolower; use function strtolower;
use function strtoupper; use function strtoupper;
use function trigger_error; use function trigger_error;
use const E_USER_DEPRECATED;
/** /**
* Base class for all DatabasePlatforms. The DatabasePlatforms are the central * Base class for all DatabasePlatforms. The DatabasePlatforms are the central
...@@ -1552,7 +1552,6 @@ abstract class AbstractPlatform ...@@ -1552,7 +1552,6 @@ abstract class AbstractPlatform
if (($createFlags&self::CREATE_INDEXES) > 0) { if (($createFlags&self::CREATE_INDEXES) > 0) {
foreach ($table->getIndexes() as $index) { foreach ($table->getIndexes() as $index) {
/** @var $index Index */
if ($index->isPrimary()) { if ($index->isPrimary()) {
$options['primary'] = $index->getQuotedColumns($this); $options['primary'] = $index->getQuotedColumns($this);
$options['primary_index'] = $index; $options['primary_index'] = $index;
...@@ -1614,6 +1613,7 @@ abstract class AbstractPlatform ...@@ -1614,6 +1613,7 @@ abstract class AbstractPlatform
if ($table->hasOption('comment')) { if ($table->hasOption('comment')) {
$sql[] = $this->getCommentOnTableSQL($tableName, $table->getOption('comment')); $sql[] = $this->getCommentOnTableSQL($tableName, $table->getOption('comment'));
} }
foreach ($table->getColumns() as $column) { foreach ($table->getColumns() as $column) {
$comment = $this->getColumnComment($column); $comment = $this->getColumnComment($column);
...@@ -1712,6 +1712,7 @@ abstract class AbstractPlatform ...@@ -1712,6 +1712,7 @@ abstract class AbstractPlatform
if (! empty($check)) { if (! empty($check)) {
$query .= ', ' . $check; $query .= ', ' . $check;
} }
$query .= ')'; $query .= ')';
$sql[] = $query; $sql[] = $query;
...@@ -1793,6 +1794,7 @@ abstract class AbstractPlatform ...@@ -1793,6 +1794,7 @@ abstract class AbstractPlatform
$referencesClause = ' REFERENCES ' . $constraint->getQuotedForeignTableName($this) . $referencesClause = ' REFERENCES ' . $constraint->getQuotedForeignTableName($this) .
' (' . implode(', ', $constraint->getQuotedForeignColumns($this)) . ')'; ' (' . implode(', ', $constraint->getQuotedForeignColumns($this)) . ')';
} }
$query .= ' ' . $columnList . $referencesClause; $query .= ' ' . $columnList . $referencesClause;
return $query; return $query;
...@@ -1812,6 +1814,7 @@ abstract class AbstractPlatform ...@@ -1812,6 +1814,7 @@ abstract class AbstractPlatform
if ($table instanceof Table) { if ($table instanceof Table) {
$table = $table->getQuotedName($this); $table = $table->getQuotedName($this);
} }
$name = $index->getQuotedName($this); $name = $index->getQuotedName($this);
$columns = $index->getColumns(); $columns = $index->getColumns();
...@@ -2080,6 +2083,7 @@ abstract class AbstractPlatform ...@@ -2080,6 +2083,7 @@ abstract class AbstractPlatform
foreach ($diff->removedForeignKeys as $foreignKey) { foreach ($diff->removedForeignKeys as $foreignKey) {
$sql[] = $this->getDropForeignKeySQL($foreignKey, $tableName); $sql[] = $this->getDropForeignKeySQL($foreignKey, $tableName);
} }
foreach ($diff->changedForeignKeys as $foreignKey) { foreach ($diff->changedForeignKeys as $foreignKey) {
$sql[] = $this->getDropForeignKeySQL($foreignKey, $tableName); $sql[] = $this->getDropForeignKeySQL($foreignKey, $tableName);
} }
...@@ -2088,6 +2092,7 @@ abstract class AbstractPlatform ...@@ -2088,6 +2092,7 @@ abstract class AbstractPlatform
foreach ($diff->removedIndexes as $index) { foreach ($diff->removedIndexes as $index) {
$sql[] = $this->getDropIndexSQL($index, $tableName); $sql[] = $this->getDropIndexSQL($index, $tableName);
} }
foreach ($diff->changedIndexes as $index) { foreach ($diff->changedIndexes as $index) {
$sql[] = $this->getDropIndexSQL($index, $tableName); $sql[] = $this->getDropIndexSQL($index, $tableName);
} }
...@@ -2515,6 +2520,7 @@ abstract class AbstractPlatform ...@@ -2515,6 +2520,7 @@ abstract class AbstractPlatform
if ($this->supportsForeignKeyOnUpdate() && $foreignKey->hasOption('onUpdate')) { if ($this->supportsForeignKeyOnUpdate() && $foreignKey->hasOption('onUpdate')) {
$query .= ' ON UPDATE ' . $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onUpdate')); $query .= ' ON UPDATE ' . $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onUpdate'));
} }
if ($foreignKey->hasOption('onDelete')) { if ($foreignKey->hasOption('onDelete')) {
$query .= ' ON DELETE ' . $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onDelete')); $query .= ' ON DELETE ' . $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onDelete'));
} }
...@@ -2541,6 +2547,7 @@ abstract class AbstractPlatform ...@@ -2541,6 +2547,7 @@ abstract class AbstractPlatform
case 'RESTRICT': case 'RESTRICT':
case 'SET DEFAULT': case 'SET DEFAULT':
return $upper; return $upper;
default: default:
throw new InvalidArgumentException('Invalid foreign key action: ' . $upper); throw new InvalidArgumentException('Invalid foreign key action: ' . $upper);
} }
...@@ -2560,14 +2567,17 @@ abstract class AbstractPlatform ...@@ -2560,14 +2567,17 @@ abstract class AbstractPlatform
if (strlen($foreignKey->getName())) { if (strlen($foreignKey->getName())) {
$sql .= 'CONSTRAINT ' . $foreignKey->getQuotedName($this) . ' '; $sql .= 'CONSTRAINT ' . $foreignKey->getQuotedName($this) . ' ';
} }
$sql .= 'FOREIGN KEY ('; $sql .= 'FOREIGN KEY (';
if (count($foreignKey->getLocalColumns()) === 0) { if (count($foreignKey->getLocalColumns()) === 0) {
throw new InvalidArgumentException("Incomplete definition. 'local' required."); throw new InvalidArgumentException("Incomplete definition. 'local' required.");
} }
if (count($foreignKey->getForeignColumns()) === 0) { if (count($foreignKey->getForeignColumns()) === 0) {
throw new InvalidArgumentException("Incomplete definition. 'foreign' required."); throw new InvalidArgumentException("Incomplete definition. 'foreign' required.");
} }
if (strlen($foreignKey->getForeignTableName()) === 0) { if (strlen($foreignKey->getForeignTableName()) === 0) {
throw new InvalidArgumentException("Incomplete definition. 'foreignTable' required."); throw new InvalidArgumentException("Incomplete definition. 'foreignTable' required.");
} }
...@@ -2744,12 +2754,16 @@ abstract class AbstractPlatform ...@@ -2744,12 +2754,16 @@ abstract class AbstractPlatform
switch ($level) { switch ($level) {
case TransactionIsolationLevel::READ_UNCOMMITTED: case TransactionIsolationLevel::READ_UNCOMMITTED:
return 'READ UNCOMMITTED'; return 'READ UNCOMMITTED';
case TransactionIsolationLevel::READ_COMMITTED: case TransactionIsolationLevel::READ_COMMITTED:
return 'READ COMMITTED'; return 'READ COMMITTED';
case TransactionIsolationLevel::REPEATABLE_READ: case TransactionIsolationLevel::REPEATABLE_READ:
return 'REPEATABLE READ'; return 'REPEATABLE READ';
case TransactionIsolationLevel::SERIALIZABLE: case TransactionIsolationLevel::SERIALIZABLE:
return 'SERIALIZABLE'; return 'SERIALIZABLE';
default: default:
throw new InvalidArgumentException('Invalid isolation level:' . $level); throw new InvalidArgumentException('Invalid isolation level:' . $level);
} }
......
...@@ -22,9 +22,6 @@ use function strtoupper; ...@@ -22,9 +22,6 @@ use function strtoupper;
class DB2Platform extends AbstractPlatform class DB2Platform extends AbstractPlatform
{ {
/**
* {@inheritdoc}
*/
public function getCharMaxLength() : int public function getCharMaxLength() : int
{ {
return 254; return 254;
...@@ -495,6 +492,7 @@ class DB2Platform extends AbstractPlatform ...@@ -495,6 +492,7 @@ class DB2Platform extends AbstractPlatform
if (isset($options['indexes'])) { if (isset($options['indexes'])) {
$indexes = $options['indexes']; $indexes = $options['indexes'];
} }
$options['indexes'] = []; $options['indexes'] = [];
$sqls = parent::_getCreateTableSQL($tableName, $columns, $options); $sqls = parent::_getCreateTableSQL($tableName, $columns, $options);
...@@ -708,21 +706,23 @@ class DB2Platform extends AbstractPlatform ...@@ -708,21 +706,23 @@ class DB2Platform extends AbstractPlatform
foreach ($diff->removedIndexes as $remKey => $remIndex) { foreach ($diff->removedIndexes as $remKey => $remIndex) {
foreach ($diff->addedIndexes as $addKey => $addIndex) { foreach ($diff->addedIndexes as $addKey => $addIndex) {
if ($remIndex->getColumns() === $addIndex->getColumns()) { if ($remIndex->getColumns() !== $addIndex->getColumns()) {
if ($remIndex->isPrimary()) { continue;
$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);
}
$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;
} }
} }
......
...@@ -550,6 +550,7 @@ class DrizzlePlatform extends AbstractPlatform ...@@ -550,6 +550,7 @@ class DrizzlePlatform extends AbstractPlatform
if (count($queryParts) > 0) { if (count($queryParts) > 0) {
$sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . implode(', ', $queryParts); $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . implode(', ', $queryParts);
} }
$sql = array_merge( $sql = array_merge(
$this->getPreAlterTableIndexForeignKeySQL($diff), $this->getPreAlterTableIndexForeignKeySQL($diff),
$sql, $sql,
......
...@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms\Keywords; ...@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/ */
final class MariaDb102Keywords extends MySQLKeywords final class MariaDb102Keywords extends MySQLKeywords
{ {
/**
* {@inheritdoc}
*/
public function getName() : string public function getName() : string
{ {
return 'MariaDb102'; return 'MariaDb102';
......
...@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms\Keywords; ...@@ -9,9 +9,6 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/ */
class PostgreSQL100Keywords extends PostgreSQL94Keywords class PostgreSQL100Keywords extends PostgreSQL94Keywords
{ {
/**
* {@inheritdoc}
*/
public function getName() : string public function getName() : string
{ {
return 'PostgreSQL100'; return 'PostgreSQL100';
......
...@@ -21,17 +21,11 @@ final class MariaDb1027Platform extends MySqlPlatform ...@@ -21,17 +21,11 @@ final class MariaDb1027Platform extends MySqlPlatform
return 'LONGTEXT'; return 'LONGTEXT';
} }
/**
* {@inheritdoc}
*/
protected function getReservedKeywordsClass() : string protected function getReservedKeywordsClass() : string
{ {
return Keywords\MariaDb102Keywords::class; return Keywords\MariaDb102Keywords::class;
} }
/**
* {@inheritdoc}
*/
protected function initializeDoctrineTypeMappings() : void protected function initializeDoctrineTypeMappings() : void
{ {
parent::initializeDoctrineTypeMappings(); parent::initializeDoctrineTypeMappings();
......
...@@ -635,6 +635,7 @@ SQL ...@@ -635,6 +635,7 @@ SQL
if (count($queryParts) > 0) { if (count($queryParts) > 0) {
$sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . implode(', ', $queryParts); $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . implode(', ', $queryParts);
} }
$sql = array_merge( $sql = array_merge(
$this->getPreAlterTableIndexForeignKeySQL($diff), $this->getPreAlterTableIndexForeignKeySQL($diff),
$sql, $sql,
...@@ -661,25 +662,27 @@ SQL ...@@ -661,25 +662,27 @@ SQL
$sql = array_merge($sql, $this->getPreAlterTableAlterPrimaryKeySQL($diff, $remIndex)); $sql = array_merge($sql, $this->getPreAlterTableAlterPrimaryKeySQL($diff, $remIndex));
foreach ($diff->addedIndexes as $addKey => $addIndex) { foreach ($diff->addedIndexes as $addKey => $addIndex) {
if ($remIndex->getColumns() === $addIndex->getColumns()) { if ($remIndex->getColumns() !== $addIndex->getColumns()) {
$indexClause = 'INDEX ' . $addIndex->getName(); continue;
}
if ($addIndex->isPrimary()) { $indexClause = 'INDEX ' . $addIndex->getName();
$indexClause = 'PRIMARY KEY';
} elseif ($addIndex->isUnique()) {
$indexClause = 'UNIQUE INDEX ' . $addIndex->getName();
}
$query = 'ALTER TABLE ' . $table . ' DROP INDEX ' . $remIndex->getName() . ', '; if ($addIndex->isPrimary()) {
$query .= 'ADD ' . $indexClause; $indexClause = 'PRIMARY KEY';
$query .= ' (' . $this->getIndexFieldDeclarationListSQL($addIndex) . ')'; } 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 @@ SQL ...@@ -985,6 +988,7 @@ SQL
if ($foreignKey->hasOption('match')) { if ($foreignKey->hasOption('match')) {
$query .= ' MATCH ' . $foreignKey->getOption('match'); $query .= ' MATCH ' . $foreignKey->getOption('match');
} }
$query .= parent::getAdvancedForeignKeyOptionsSQL($foreignKey); $query .= parent::getAdvancedForeignKeyOptionsSQL($foreignKey);
return $query; return $query;
...@@ -1180,9 +1184,6 @@ SQL ...@@ -1180,9 +1184,6 @@ SQL
return TransactionIsolationLevel::REPEATABLE_READ; return TransactionIsolationLevel::REPEATABLE_READ;
} }
/**
* {@inheritdoc}
*/
public function supportsColumnLengthIndexes() : bool public function supportsColumnLengthIndexes() : bool
{ {
return true; return true;
......
...@@ -242,11 +242,14 @@ class OraclePlatform extends AbstractPlatform ...@@ -242,11 +242,14 @@ class OraclePlatform extends AbstractPlatform
switch ($level) { switch ($level) {
case TransactionIsolationLevel::READ_UNCOMMITTED: case TransactionIsolationLevel::READ_UNCOMMITTED:
return 'READ UNCOMMITTED'; return 'READ UNCOMMITTED';
case TransactionIsolationLevel::READ_COMMITTED: case TransactionIsolationLevel::READ_COMMITTED:
return 'READ COMMITTED'; return 'READ COMMITTED';
case TransactionIsolationLevel::REPEATABLE_READ: case TransactionIsolationLevel::REPEATABLE_READ:
case TransactionIsolationLevel::SERIALIZABLE: case TransactionIsolationLevel::SERIALIZABLE:
return 'SERIALIZABLE'; return 'SERIALIZABLE';
default: default:
return parent::_getTransactionIsolationLevelSQL($level); return parent::_getTransactionIsolationLevelSQL($level);
} }
......
...@@ -11,14 +11,14 @@ use Doctrine\DBAL\Platforms\Keywords\PostgreSQL100Keywords; ...@@ -11,14 +11,14 @@ use Doctrine\DBAL\Platforms\Keywords\PostgreSQL100Keywords;
*/ */
class PostgreSQL100Platform extends PostgreSQL94Platform class PostgreSQL100Platform extends PostgreSQL94Platform
{ {
/**
* {@inheritdoc}
*/
protected function getReservedKeywordsClass() : string protected function getReservedKeywordsClass() : string
{ {
return PostgreSQL100Keywords::class; return PostgreSQL100Keywords::class;
} }
/**
* {@inheritDoc}
*/
public function getListSequencesSQL($database) : string public function getListSequencesSQL($database) : string
{ {
return 'SELECT sequence_name AS relname, return 'SELECT sequence_name AS relname,
......
...@@ -531,7 +531,6 @@ SQL ...@@ -531,7 +531,6 @@ SQL
} }
foreach ($diff->changedColumns as $columnDiff) { foreach ($diff->changedColumns as $columnDiff) {
/** @var $columnDiff \Doctrine\DBAL\Schema\ColumnDiff */
if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) { if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) {
continue; continue;
} }
......
...@@ -17,6 +17,7 @@ use InvalidArgumentException; ...@@ -17,6 +17,7 @@ use InvalidArgumentException;
use function array_merge; use function array_merge;
use function array_unique; use function array_unique;
use function array_values; use function array_values;
use function assert;
use function count; use function count;
use function explode; use function explode;
use function func_get_args; use function func_get_args;
...@@ -636,6 +637,7 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -636,6 +637,7 @@ class SQLAnywherePlatform extends AbstractPlatform
case self::FOREIGN_KEY_MATCH_FULL_UNIQUE: case self::FOREIGN_KEY_MATCH_FULL_UNIQUE:
return 'UNIQUE FULL'; return 'UNIQUE FULL';
default: default:
throw new InvalidArgumentException('Invalid foreign key match type: ' . $type); throw new InvalidArgumentException('Invalid foreign key match type: ' . $type);
} }
...@@ -1127,8 +1129,10 @@ SQL ...@@ -1127,8 +1129,10 @@ SQL
switch ($pos) { switch ($pos) {
case TrimMode::LEADING: case TrimMode::LEADING:
return $this->getLtrimExpression($str); return $this->getLtrimExpression($str);
case TrimMode::TRAILING: case TrimMode::TRAILING:
return $this->getRtrimExpression($str); return $this->getRtrimExpression($str);
default: default:
return 'TRIM(' . $str . ')'; return 'TRIM(' . $str . ')';
} }
...@@ -1139,8 +1143,10 @@ SQL ...@@ -1139,8 +1143,10 @@ SQL
switch ($pos) { switch ($pos) {
case TrimMode::LEADING: case TrimMode::LEADING:
return 'SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))'; return 'SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))';
case TrimMode::TRAILING: case TrimMode::TRAILING:
return 'REVERSE(SUBSTR(REVERSE(' . $str . '), PATINDEX(' . $pattern . ', REVERSE(' . $str . '))))'; return 'REVERSE(SUBSTR(REVERSE(' . $str . '), PATINDEX(' . $pattern . ', REVERSE(' . $str . '))))';
default: default:
return 'REVERSE(SUBSTR(REVERSE(SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))), ' . return 'REVERSE(SUBSTR(REVERSE(SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))), ' .
'PATINDEX(' . $pattern . ', REVERSE(SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))))))'; 'PATINDEX(' . $pattern . ', REVERSE(SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))))))';
...@@ -1252,8 +1258,8 @@ SQL ...@@ -1252,8 +1258,8 @@ SQL
} }
if (! empty($options['indexes'])) { if (! empty($options['indexes'])) {
/** @var Index $index */
foreach ((array) $options['indexes'] as $index) { foreach ((array) $options['indexes'] as $index) {
assert($index instanceof Index);
$indexSql[] = $this->getCreateIndexSQL($index, $tableName); $indexSql[] = $this->getCreateIndexSQL($index, $tableName);
} }
} }
...@@ -1294,12 +1300,16 @@ SQL ...@@ -1294,12 +1300,16 @@ SQL
switch ($level) { switch ($level) {
case TransactionIsolationLevel::READ_UNCOMMITTED: case TransactionIsolationLevel::READ_UNCOMMITTED:
return '0'; return '0';
case TransactionIsolationLevel::READ_COMMITTED: case TransactionIsolationLevel::READ_COMMITTED:
return '1'; return '1';
case TransactionIsolationLevel::REPEATABLE_READ: case TransactionIsolationLevel::REPEATABLE_READ:
return '2'; return '2';
case TransactionIsolationLevel::SERIALIZABLE: case TransactionIsolationLevel::SERIALIZABLE:
return '3'; return '3';
default: default:
throw new InvalidArgumentException('Invalid isolation level:' . $level); throw new InvalidArgumentException('Invalid isolation level:' . $level);
} }
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
namespace Doctrine\DBAL\Platforms; namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Sequence;
use const PREG_OFFSET_CAPTURE;
use function preg_match; use function preg_match;
use function preg_match_all; use function preg_match_all;
use function substr_count; use function substr_count;
use const PREG_OFFSET_CAPTURE;
/** /**
* Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2012 version. * Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2012 version.
...@@ -105,7 +105,7 @@ class SQLServer2012Platform extends SQLServer2008Platform ...@@ -105,7 +105,7 @@ class SQLServer2012Platform extends SQLServer2008Platform
$matchesCount = preg_match_all('/[\\s]+order\\s+by\\s/im', $query, $matches, PREG_OFFSET_CAPTURE); $matchesCount = preg_match_all('/[\\s]+order\\s+by\\s/im', $query, $matches, PREG_OFFSET_CAPTURE);
$orderByPos = false; $orderByPos = false;
if ($matchesCount > 0) { if ($matchesCount > 0) {
$orderByPos = $matches[0][($matchesCount - 1)][1]; $orderByPos = $matches[0][$matchesCount - 1][1];
} }
if ($orderByPos === false if ($orderByPos === false
......
...@@ -285,6 +285,7 @@ SQL ...@@ -285,6 +285,7 @@ SQL
if (isset($options['primary_index']) && $options['primary_index']->hasFlag('nonclustered')) { if (isset($options['primary_index']) && $options['primary_index']->hasFlag('nonclustered')) {
$flags = ' NONCLUSTERED'; $flags = ' NONCLUSTERED';
} }
$columnListSql .= ', PRIMARY KEY' . $flags . ' (' . implode(', ', array_unique(array_values($options['primary']))) . ')'; $columnListSql .= ', PRIMARY KEY' . $flags . ' (' . implode(', ', array_unique(array_values($options['primary']))) . ')';
} }
...@@ -294,6 +295,7 @@ SQL ...@@ -294,6 +295,7 @@ SQL
if (! empty($check)) { if (! empty($check)) {
$query .= ', ' . $check; $query .= ', ' . $check;
} }
$query .= ')'; $query .= ')';
$sql = [$query]; $sql = [$query];
...@@ -1669,8 +1671,8 @@ SQL ...@@ -1669,8 +1671,8 @@ SQL
{ {
return sprintf( return sprintf(
<<<'SQL' <<<'SQL'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', EXEC sys.sp_addextendedproperty @name=N'MS_Description',
@value=N%s, @level0type=N'SCHEMA', @level0name=N'dbo', @value=N%s, @level0type=N'SCHEMA', @level0name=N'dbo',
@level1type=N'TABLE', @level1name=N%s @level1type=N'TABLE', @level1name=N%s
SQL SQL
, ,
......
...@@ -64,8 +64,10 @@ class SqlitePlatform extends AbstractPlatform ...@@ -64,8 +64,10 @@ class SqlitePlatform extends AbstractPlatform
switch ($type) { switch ($type) {
case 'time': case 'time':
return 'time(\'now\')'; return 'time(\'now\')';
case 'date': case 'date':
return 'date(\'now\')'; return 'date(\'now\')';
case 'timestamp': case 'timestamp':
default: default:
return 'datetime(\'now\')'; return 'datetime(\'now\')';
...@@ -77,7 +79,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -77,7 +79,7 @@ class SqlitePlatform extends AbstractPlatform
*/ */
public function getTrimExpression($str, $pos = TrimMode::UNSPECIFIED, $char = false) public function getTrimExpression($str, $pos = TrimMode::UNSPECIFIED, $char = false)
{ {
$trimChar = $char !== false ? (', ' . $char) : ''; $trimChar = $char !== false ? ', ' . $char : '';
switch ($pos) { switch ($pos) {
case TrimMode::LEADING: case TrimMode::LEADING:
...@@ -131,26 +133,25 @@ class SqlitePlatform extends AbstractPlatform ...@@ -131,26 +133,25 @@ class SqlitePlatform extends AbstractPlatform
case DateIntervalUnit::MINUTE: case DateIntervalUnit::MINUTE:
case DateIntervalUnit::HOUR: case DateIntervalUnit::HOUR:
return 'DATETIME(' . $date . ",'" . $operator . $interval . ' ' . $unit . "')"; return 'DATETIME(' . $date . ",'" . $operator . $interval . ' ' . $unit . "')";
}
default: switch ($unit) {
switch ($unit) { case DateIntervalUnit::WEEK:
case DateIntervalUnit::WEEK: $interval *= 7;
$interval *= 7; $unit = DateIntervalUnit::DAY;
$unit = DateIntervalUnit::DAY; break;
break;
case DateIntervalUnit::QUARTER:
$interval *= 3;
$unit = DateIntervalUnit::MONTH;
break;
}
if (! is_numeric($interval)) { case DateIntervalUnit::QUARTER:
$interval = "' || " . $interval . " || '"; $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 @@ class SqlitePlatform extends AbstractPlatform ...@@ -169,10 +170,12 @@ class SqlitePlatform extends AbstractPlatform
switch ($level) { switch ($level) {
case TransactionIsolationLevel::READ_UNCOMMITTED: case TransactionIsolationLevel::READ_UNCOMMITTED:
return '0'; return '0';
case TransactionIsolationLevel::READ_COMMITTED: case TransactionIsolationLevel::READ_COMMITTED:
case TransactionIsolationLevel::REPEATABLE_READ: case TransactionIsolationLevel::REPEATABLE_READ:
case TransactionIsolationLevel::SERIALIZABLE: case TransactionIsolationLevel::SERIALIZABLE:
return '1'; return '1';
default: default:
return parent::_getTransactionIsolationLevelSQL($level); return parent::_getTransactionIsolationLevelSQL($level);
} }
...@@ -773,9 +776,6 @@ class SqlitePlatform extends AbstractPlatform ...@@ -773,9 +776,6 @@ class SqlitePlatform extends AbstractPlatform
return true; return true;
} }
/**
* {@inheritDoc}
*/
public function supportsCreateDropForeignKeyConstraints() : bool public function supportsCreateDropForeignKeyConstraints() : bool
{ {
return false; return false;
......
...@@ -6,9 +6,9 @@ use Doctrine\DBAL\Cache\QueryCacheProfile; ...@@ -6,9 +6,9 @@ use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\ColumnCase; use Doctrine\DBAL\ColumnCase;
use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\Driver\PDOConnection;
use PDO; use PDO;
use function func_get_args;
use const CASE_LOWER; use const CASE_LOWER;
use const CASE_UPPER; use const CASE_UPPER;
use function func_get_args;
/** /**
* Portability wrapper for a Connection. * Portability wrapper for a Connection.
...@@ -62,6 +62,7 @@ class Connection extends \Doctrine\DBAL\Connection ...@@ -62,6 +62,7 @@ class Connection extends \Doctrine\DBAL\Connection
} else { } else {
$params['portability'] &= self::PORTABILITY_OTHERVENDORS; $params['portability'] &= self::PORTABILITY_OTHERVENDORS;
} }
$this->portability = $params['portability']; $this->portability = $params['portability'];
} }
......
...@@ -51,7 +51,7 @@ class CompositeExpression implements Countable ...@@ -51,7 +51,7 @@ class CompositeExpression implements Countable
* *
* @param self[]|string[] $parts * @param self[]|string[] $parts
* *
* @return \Doctrine\DBAL\Query\Expression\CompositeExpression * @return CompositeExpression
*/ */
public function addMultiple(array $parts = []) public function addMultiple(array $parts = [])
{ {
...@@ -67,7 +67,7 @@ class CompositeExpression implements Countable ...@@ -67,7 +67,7 @@ class CompositeExpression implements Countable
* *
* @param mixed $part * @param mixed $part
* *
* @return \Doctrine\DBAL\Query\Expression\CompositeExpression * @return CompositeExpression
*/ */
public function add($part) public function add($part)
{ {
......
...@@ -231,6 +231,7 @@ class QueryBuilder ...@@ -231,6 +231,7 @@ class QueryBuilder
case self::INSERT: case self::INSERT:
$sql = $this->getSQLForInsert(); $sql = $this->getSQLForInsert();
break; break;
case self::DELETE: case self::DELETE:
$sql = $this->getSQLForDelete(); $sql = $this->getSQLForDelete();
break; break;
...@@ -1274,6 +1275,7 @@ class QueryBuilder ...@@ -1274,6 +1275,7 @@ class QueryBuilder
$this->boundCounter++; $this->boundCounter++;
$placeHolder = ':dcValue' . $this->boundCounter; $placeHolder = ':dcValue' . $this->boundCounter;
} }
$this->setParameter(substr($placeHolder, 1), $value, $type); $this->setParameter(substr($placeHolder, 1), $value, $type);
return $placeHolder; return $placeHolder;
...@@ -1326,11 +1328,13 @@ class QueryBuilder ...@@ -1326,11 +1328,13 @@ class QueryBuilder
if (array_key_exists($join['joinAlias'], $knownAliases)) { if (array_key_exists($join['joinAlias'], $knownAliases)) {
throw QueryException::nonUniqueAlias($join['joinAlias'], array_keys($knownAliases)); throw QueryException::nonUniqueAlias($join['joinAlias'], array_keys($knownAliases));
} }
$sql .= ' ' . strtoupper($join['joinType']) $sql .= ' ' . strtoupper($join['joinType'])
. ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias']; . ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias'];
if ($join['joinCondition'] !== null) { if ($join['joinCondition'] !== null) {
$sql .= ' ON ' . $join['joinCondition']; $sql .= ' ON ' . $join['joinCondition'];
} }
$knownAliases[$join['joinAlias']] = true; $knownAliases[$join['joinAlias']] = true;
} }
......
...@@ -14,7 +14,7 @@ class QueryException extends DBALException ...@@ -14,7 +14,7 @@ class QueryException extends DBALException
* @param string $alias * @param string $alias
* @param string[] $registeredAliases * @param string[] $registeredAliases
* *
* @return \Doctrine\DBAL\Query\QueryException * @return QueryException
*/ */
public static function unknownAlias($alias, $registeredAliases) public static function unknownAlias($alias, $registeredAliases)
{ {
...@@ -27,7 +27,7 @@ class QueryException extends DBALException ...@@ -27,7 +27,7 @@ class QueryException extends DBALException
* @param string $alias * @param string $alias
* @param string[] $registeredAliases * @param string[] $registeredAliases
* *
* @return \Doctrine\DBAL\Query\QueryException * @return QueryException
*/ */
public static function nonUniqueAlias($alias, $registeredAliases) public static function nonUniqueAlias($alias, $registeredAliases)
{ {
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
namespace Doctrine\DBAL; namespace Doctrine\DBAL;
use const PREG_OFFSET_CAPTURE;
use function array_fill; use function array_fill;
use function array_fill_keys; use function array_fill_keys;
use function array_key_exists; use function array_key_exists;
...@@ -20,6 +19,7 @@ use function sprintf; ...@@ -20,6 +19,7 @@ use function sprintf;
use function strlen; use function strlen;
use function strpos; use function strpos;
use function substr; use function substr;
use const PREG_OFFSET_CAPTURE;
/** /**
* Utility class that parses sql statements with regard to types and parameters. * Utility class that parses sql statements with regard to types and parameters.
...@@ -195,8 +195,8 @@ class SQLParserUtils ...@@ -195,8 +195,8 @@ class SQLParserUtils
$expandStr = $count ? implode(', ', array_fill(0, $count, '?')) : 'NULL'; $expandStr = $count ? implode(', ', array_fill(0, $count, '?')) : 'NULL';
$query = substr($query, 0, $needlePos) . $expandStr . substr($query, $needlePos + 1); $query = substr($query, 0, $needlePos) . $expandStr . substr($query, $needlePos + 1);
$paramOffset += ($count - 1); // Grows larger by number of parameters minus the replaced needle. $paramOffset += $count - 1; // Grows larger by number of parameters minus the replaced needle.
$queryOffset += (strlen($expandStr) - 1); $queryOffset += strlen($expandStr) - 1;
} }
return [$query, $params, $types]; return [$query, $params, $types];
...@@ -214,10 +214,10 @@ class SQLParserUtils ...@@ -214,10 +214,10 @@ class SQLParserUtils
if (! isset($arrayPositions[$paramName]) && ! isset($arrayPositions[':' . $paramName])) { if (! isset($arrayPositions[$paramName]) && ! isset($arrayPositions[':' . $paramName])) {
$pos += $queryOffset; $pos += $queryOffset;
$queryOffset -= ($paramLen - 1); $queryOffset -= $paramLen - 1;
$paramsOrd[] = $value; $paramsOrd[] = $value;
$typesOrd[] = static::extractParam($paramName, $types, false, ParameterType::STRING); $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; continue;
} }
...@@ -231,8 +231,8 @@ class SQLParserUtils ...@@ -231,8 +231,8 @@ class SQLParserUtils
} }
$pos += $queryOffset; $pos += $queryOffset;
$queryOffset += (strlen($expandStr) - $paramLen); $queryOffset += strlen($expandStr) - $paramLen;
$query = substr($query, 0, $pos) . $expandStr . substr($query, ($pos + $paramLen)); $query = substr($query, 0, $pos) . $expandStr . substr($query, $pos + $paramLen);
} }
return [$query, $paramsOrd, $typesOrd]; return [$query, $paramsOrd, $typesOrd];
......
...@@ -14,7 +14,7 @@ class SQLParserUtilsException extends DBALException ...@@ -14,7 +14,7 @@ class SQLParserUtilsException extends DBALException
/** /**
* @param string $paramName * @param string $paramName
* *
* @return \Doctrine\DBAL\SQLParserUtilsException * @return SQLParserUtilsException
*/ */
public static function missingParam($paramName) public static function missingParam($paramName)
{ {
...@@ -24,7 +24,7 @@ class SQLParserUtilsException extends DBALException ...@@ -24,7 +24,7 @@ class SQLParserUtilsException extends DBALException
/** /**
* @param string $typeName * @param string $typeName
* *
* @return \Doctrine\DBAL\SQLParserUtilsException * @return SQLParserUtilsException
*/ */
public static function missingType($typeName) public static function missingType($typeName)
{ {
......
...@@ -48,11 +48,13 @@ abstract class AbstractAsset ...@@ -48,11 +48,13 @@ abstract class AbstractAsset
$this->_quoted = true; $this->_quoted = true;
$name = $this->trimQuotes($name); $name = $this->trimQuotes($name);
} }
if (strpos($name, '.') !== false) { if (strpos($name, '.') !== false) {
$parts = explode('.', $name); $parts = explode('.', $name);
$this->_namespace = $parts[0]; $this->_namespace = $parts[0];
$name = $parts[1]; $name = $parts[1];
} }
$this->_name = $name; $this->_name = $name;
} }
......
...@@ -132,6 +132,7 @@ abstract class AbstractSchemaManager ...@@ -132,6 +132,7 @@ abstract class AbstractSchemaManager
if ($database === null) { if ($database === null) {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
} }
$sql = $this->_platform->getListSequencesSQL($database); $sql = $this->_platform->getListSequencesSQL($database);
$sequences = $this->_conn->fetchAll($sql); $sequences = $this->_conn->fetchAll($sql);
...@@ -273,6 +274,7 @@ abstract class AbstractSchemaManager ...@@ -273,6 +274,7 @@ abstract class AbstractSchemaManager
if ($this->_platform->supportsForeignKeyConstraints()) { if ($this->_platform->supportsForeignKeyConstraints()) {
$foreignKeys = $this->listTableForeignKeys($tableName); $foreignKeys = $this->listTableForeignKeys($tableName);
} }
$indexes = $this->listTableIndexes($tableName); $indexes = $this->listTableIndexes($tableName);
return new Table($tableName, $columns, $indexes, $foreignKeys); return new Table($tableName, $columns, $indexes, $foreignKeys);
...@@ -305,6 +307,7 @@ abstract class AbstractSchemaManager ...@@ -305,6 +307,7 @@ abstract class AbstractSchemaManager
if ($database === null) { if ($database === null) {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
} }
$sql = $this->_platform->getListTableForeignKeysSQL($table, $database); $sql = $this->_platform->getListTableForeignKeysSQL($table, $database);
$tableForeignKeys = $this->_conn->fetchAll($sql); $tableForeignKeys = $this->_conn->fetchAll($sql);
...@@ -846,6 +849,7 @@ abstract class AbstractSchemaManager ...@@ -846,6 +849,7 @@ abstract class AbstractSchemaManager
if ($tableIndex['primary']) { if ($tableIndex['primary']) {
$keyName = 'primary'; $keyName = 'primary';
} }
$keyName = strtolower($keyName); $keyName = strtolower($keyName);
if (! isset($result[$keyName])) { if (! isset($result[$keyName])) {
...@@ -1075,9 +1079,11 @@ abstract class AbstractSchemaManager ...@@ -1075,9 +1079,11 @@ abstract class AbstractSchemaManager
if (! isset($params['defaultTableOptions'])) { if (! isset($params['defaultTableOptions'])) {
$params['defaultTableOptions'] = []; $params['defaultTableOptions'] = [];
} }
if (! isset($params['defaultTableOptions']['charset']) && isset($params['charset'])) { if (! isset($params['defaultTableOptions']['charset']) && isset($params['charset'])) {
$params['defaultTableOptions']['charset'] = $params['charset']; $params['defaultTableOptions']['charset'] = $params['charset'];
} }
$schemaConfig->setDefaultTableOptions($params['defaultTableOptions']); $schemaConfig->setDefaultTableOptions($params['defaultTableOptions']);
return $schemaConfig; return $schemaConfig;
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use const E_USER_DEPRECATED;
use function array_merge; use function array_merge;
use function is_numeric; use function is_numeric;
use function method_exists; use function method_exists;
use function sprintf; use function sprintf;
use function trigger_error; use function trigger_error;
use const E_USER_DEPRECATED;
/** /**
* Object representation of a database column. * Object representation of a database column.
...@@ -86,6 +86,7 @@ class Column extends AbstractAsset ...@@ -86,6 +86,7 @@ class Column extends AbstractAsset
continue; continue;
} }
$this->$method($value); $this->$method($value);
} }
......
...@@ -89,6 +89,7 @@ class Comparator ...@@ -89,6 +89,7 @@ class Comparator
if (! isset($foreignKeysToTable[$foreignTable])) { if (! isset($foreignKeysToTable[$foreignTable])) {
$foreignKeysToTable[$foreignTable] = []; $foreignKeysToTable[$foreignTable] = [];
} }
$foreignKeysToTable[$foreignTable][] = $foreignKey; $foreignKeysToTable[$foreignTable][] = $foreignKey;
} }
} }
...@@ -116,6 +117,7 @@ class Comparator ...@@ -116,6 +117,7 @@ class Comparator
if ($tableName !== strtolower($removedForeignKey->getForeignTableName())) { if ($tableName !== strtolower($removedForeignKey->getForeignTableName())) {
continue; continue;
} }
unset($diff->changedTables[$localTableName]->removedForeignKeys[$key]); unset($diff->changedTables[$localTableName]->removedForeignKeys[$key]);
} }
} }
...@@ -205,6 +207,7 @@ class Comparator ...@@ -205,6 +207,7 @@ class Comparator
$tableDifferences->addedColumns[$columnName] = $column; $tableDifferences->addedColumns[$columnName] = $column;
$changes++; $changes++;
} }
/* See if there are any removed fields in table 2 */ /* See if there are any removed fields in table 2 */
foreach ($table1Columns as $columnName => $column) { foreach ($table1Columns as $columnName => $column) {
// See if column is removed in table 2. // See if column is removed in table 2.
...@@ -241,6 +244,7 @@ class Comparator ...@@ -241,6 +244,7 @@ class Comparator
$tableDifferences->addedIndexes[$indexName] = $index; $tableDifferences->addedIndexes[$indexName] = $index;
$changes++; $changes++;
} }
/* See if there are any removed indexes in table 2 */ /* See if there are any removed indexes in table 2 */
foreach ($table1Indexes as $indexName => $index) { foreach ($table1Indexes as $indexName => $index) {
// See if index is removed in table 2. // See if index is removed in table 2.
...@@ -465,6 +469,7 @@ class Comparator ...@@ -465,6 +469,7 @@ class Comparator
if (($properties1['precision'] ?: 10) !== ($properties2['precision'] ?: 10)) { if (($properties1['precision'] ?: 10) !== ($properties2['precision'] ?: 10)) {
$changedProperties[] = 'precision'; $changedProperties[] = 'precision';
} }
if ($properties1['scale'] !== $properties2['scale']) { if ($properties1['scale'] !== $properties2['scale']) {
$changedProperties[] = 'scale'; $changedProperties[] = 'scale';
} }
......
...@@ -4,14 +4,15 @@ namespace Doctrine\DBAL\Schema; ...@@ -4,14 +4,15 @@ namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Platforms\DB2Platform; use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use const CASE_LOWER;
use function array_change_key_case; use function array_change_key_case;
use function assert;
use function is_resource; use function is_resource;
use function preg_match; use function preg_match;
use function str_replace; use function str_replace;
use function strpos; use function strpos;
use function strtolower; use function strtolower;
use function substr; use function substr;
use const CASE_LOWER;
/** /**
* IBM Db2 Schema Manager. * IBM Db2 Schema Manager.
...@@ -68,13 +69,16 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -68,13 +69,16 @@ class DB2SchemaManager extends AbstractSchemaManager
$length = $tableColumn['length']; $length = $tableColumn['length'];
$fixed = false; $fixed = false;
break; break;
case 'character': case 'character':
$length = $tableColumn['length']; $length = $tableColumn['length'];
$fixed = true; $fixed = true;
break; break;
case 'clob': case 'clob':
$length = $tableColumn['length']; $length = $tableColumn['length'];
break; break;
case 'decimal': case 'decimal':
case 'double': case 'double':
case 'real': case 'real':
...@@ -213,13 +217,16 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -213,13 +217,16 @@ class DB2SchemaManager extends AbstractSchemaManager
return new View($view['name'], $sql); return new View($view['name'], $sql);
} }
/**
* {@inheritdoc}
*/
public function listTableDetails($tableName) : Table public function listTableDetails($tableName) : Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
/** @var DB2Platform $platform */
$platform = $this->_platform; $platform = $this->_platform;
$sql = $platform->getListTableCommentsSQL($tableName); assert($platform instanceof DB2Platform);
$sql = $platform->getListTableCommentsSQL($tableName);
$tableOptions = $this->_conn->fetchAssoc($sql); $tableOptions = $this->_conn->fetchAssoc($sql);
......
...@@ -65,6 +65,7 @@ class Index extends AbstractAsset implements Constraint ...@@ -65,6 +65,7 @@ class Index extends AbstractAsset implements Constraint
foreach ($columns as $column) { foreach ($columns as $column) {
$this->_addColumn($column); $this->_addColumn($column);
} }
foreach ($flags as $flag) { foreach ($flags as $flag) {
$this->addFlag($flag); $this->addFlag($flag);
} }
......
...@@ -5,7 +5,6 @@ namespace Doctrine\DBAL\Schema; ...@@ -5,7 +5,6 @@ namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Platforms\MariaDb1027Platform; use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use const CASE_LOWER;
use function array_change_key_case; use function array_change_key_case;
use function array_shift; use function array_shift;
use function array_values; use function array_values;
...@@ -17,6 +16,7 @@ use function strpos; ...@@ -17,6 +16,7 @@ use function strpos;
use function strtok; use function strtok;
use function strtolower; use function strtolower;
use function strtr; use function strtr;
use const CASE_LOWER;
/** /**
* Schema manager for the MySql RDBMS. * Schema manager for the MySql RDBMS.
...@@ -82,11 +82,13 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -82,11 +82,13 @@ class MySqlSchemaManager extends AbstractSchemaManager
} else { } else {
$v['primary'] = false; $v['primary'] = false;
} }
if (strpos($v['index_type'], 'FULLTEXT') !== false) { if (strpos($v['index_type'], 'FULLTEXT') !== false) {
$v['flags'] = ['FULLTEXT']; $v['flags'] = ['FULLTEXT'];
} elseif (strpos($v['index_type'], 'SPATIAL') !== false) { } elseif (strpos($v['index_type'], 'SPATIAL') !== false) {
$v['flags'] = ['SPATIAL']; $v['flags'] = ['SPATIAL'];
} }
$v['length'] = isset($v['sub_part']) ? (int) $v['sub_part'] : null; $v['length'] = isset($v['sub_part']) ? (int) $v['sub_part'] : null;
$tableIndexes[$k] = $v; $tableIndexes[$k] = $v;
...@@ -138,6 +140,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -138,6 +140,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
case 'binary': case 'binary':
$fixed = true; $fixed = true;
break; break;
case 'float': case 'float':
case 'double': case 'double':
case 'real': case 'real':
...@@ -148,25 +151,33 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -148,25 +151,33 @@ class MySqlSchemaManager extends AbstractSchemaManager
$scale = $match[2]; $scale = $match[2];
$length = null; $length = null;
} }
break; break;
case 'tinytext': case 'tinytext':
$length = MySqlPlatform::LENGTH_LIMIT_TINYTEXT; $length = MySqlPlatform::LENGTH_LIMIT_TINYTEXT;
break; break;
case 'text': case 'text':
$length = MySqlPlatform::LENGTH_LIMIT_TEXT; $length = MySqlPlatform::LENGTH_LIMIT_TEXT;
break; break;
case 'mediumtext': case 'mediumtext':
$length = MySqlPlatform::LENGTH_LIMIT_MEDIUMTEXT; $length = MySqlPlatform::LENGTH_LIMIT_MEDIUMTEXT;
break; break;
case 'tinyblob': case 'tinyblob':
$length = MySqlPlatform::LENGTH_LIMIT_TINYBLOB; $length = MySqlPlatform::LENGTH_LIMIT_TINYBLOB;
break; break;
case 'blob': case 'blob':
$length = MySqlPlatform::LENGTH_LIMIT_BLOB; $length = MySqlPlatform::LENGTH_LIMIT_BLOB;
break; break;
case 'mediumblob': case 'mediumblob':
$length = MySqlPlatform::LENGTH_LIMIT_MEDIUMBLOB; $length = MySqlPlatform::LENGTH_LIMIT_MEDIUMBLOB;
break; break;
case 'tinyint': case 'tinyint':
case 'smallint': case 'smallint':
case 'mediumint': case 'mediumint':
...@@ -208,6 +219,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -208,6 +219,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
if (isset($tableColumn['characterset'])) { if (isset($tableColumn['characterset'])) {
$column->setPlatformOption('charset', $tableColumn['characterset']); $column->setPlatformOption('charset', $tableColumn['characterset']);
} }
if (isset($tableColumn['collation'])) { if (isset($tableColumn['collation'])) {
$column->setPlatformOption('collation', $tableColumn['collation']); $column->setPlatformOption('collation', $tableColumn['collation']);
} }
...@@ -244,8 +256,10 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -244,8 +256,10 @@ class MySqlSchemaManager extends AbstractSchemaManager
switch ($columnDefault) { switch ($columnDefault) {
case 'current_timestamp()': case 'current_timestamp()':
return $platform->getCurrentTimestampSQL(); return $platform->getCurrentTimestampSQL();
case 'curdate()': case 'curdate()':
return $platform->getCurrentDateSQL(); return $platform->getCurrentDateSQL();
case 'curtime()': case 'curtime()':
return $platform->getCurrentTimeSQL(); return $platform->getCurrentTimeSQL();
} }
...@@ -265,6 +279,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -265,6 +279,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
if (! isset($value['delete_rule']) || $value['delete_rule'] === 'RESTRICT') { if (! isset($value['delete_rule']) || $value['delete_rule'] === 'RESTRICT') {
$value['delete_rule'] = null; $value['delete_rule'] = null;
} }
if (! isset($value['update_rule']) || $value['update_rule'] === 'RESTRICT') { if (! isset($value['update_rule']) || $value['update_rule'] === 'RESTRICT') {
$value['update_rule'] = null; $value['update_rule'] = null;
} }
...@@ -278,6 +293,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -278,6 +293,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
'onUpdate' => $value['update_rule'], 'onUpdate' => $value['update_rule'],
]; ];
} }
$list[$value['constraint_name']]['local'][] = $value['column_name']; $list[$value['constraint_name']]['local'][] = $value['column_name'];
$list[$value['constraint_name']]['foreign'][] = $value['referenced_column_name']; $list[$value['constraint_name']]['foreign'][] = $value['referenced_column_name'];
} }
...@@ -299,13 +315,16 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -299,13 +315,16 @@ class MySqlSchemaManager extends AbstractSchemaManager
return $result; return $result;
} }
/**
* {@inheritdoc}
*/
public function listTableDetails($tableName) public function listTableDetails($tableName)
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
/** @var MySqlPlatform $platform */
$platform = $this->_platform; $platform = $this->_platform;
$sql = $platform->getListTableMetadataSQL($tableName); assert($platform instanceof MySqlPlatform);
$sql = $platform->getListTableMetadataSQL($tableName);
$tableOptions = $this->_conn->fetchAssoc($sql); $tableOptions = $this->_conn->fetchAssoc($sql);
......
...@@ -7,7 +7,6 @@ use Doctrine\DBAL\Driver\DriverException; ...@@ -7,7 +7,6 @@ use Doctrine\DBAL\Driver\DriverException;
use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Throwable; use Throwable;
use const CASE_LOWER;
use function array_change_key_case; use function array_change_key_case;
use function array_values; use function array_values;
use function assert; use function assert;
...@@ -18,6 +17,7 @@ use function strpos; ...@@ -18,6 +17,7 @@ use function strpos;
use function strtolower; use function strtolower;
use function strtoupper; use function strtoupper;
use function trim; use function trim;
use const CASE_LOWER;
/** /**
* Oracle Schema Manager. * Oracle Schema Manager.
...@@ -107,6 +107,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -107,6 +107,7 @@ class OracleSchemaManager extends AbstractSchemaManager
$buffer['primary'] = false; $buffer['primary'] = false;
$buffer['non_unique'] = ! $tableIndex['is_unique']; $buffer['non_unique'] = ! $tableIndex['is_unique'];
} }
$buffer['key_name'] = $keyName; $buffer['key_name'] = $keyName;
$buffer['column_name'] = $this->getQuotedIdentifierName($tableIndex['column_name']); $buffer['column_name'] = $this->getQuotedIdentifierName($tableIndex['column_name']);
$indexBuffer[] = $buffer; $indexBuffer[] = $buffer;
...@@ -176,12 +177,14 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -176,12 +177,14 @@ class OracleSchemaManager extends AbstractSchemaManager
} }
break; break;
case 'varchar': case 'varchar':
case 'varchar2': case 'varchar2':
case 'nvarchar2': case 'nvarchar2':
$length = $tableColumn['char_length']; $length = $tableColumn['char_length'];
$fixed = false; $fixed = false;
break; break;
case 'char': case 'char':
case 'nchar': case 'nchar':
$length = $tableColumn['char_length']; $length = $tableColumn['char_length'];
...@@ -392,13 +395,16 @@ SQL; ...@@ -392,13 +395,16 @@ SQL;
} }
} }
/**
* {@inheritdoc}
*/
public function listTableDetails($tableName) : Table public function listTableDetails($tableName) : Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
/** @var OraclePlatform $platform */
$platform = $this->_platform; $platform = $this->_platform;
$sql = $platform->getListTableCommentsSQL($tableName); assert($platform instanceof OraclePlatform);
$sql = $platform->getListTableCommentsSQL($tableName);
$tableOptions = $this->_conn->fetchAssoc($sql); $tableOptions = $this->_conn->fetchAssoc($sql);
......
...@@ -7,7 +7,6 @@ use Doctrine\DBAL\FetchMode; ...@@ -7,7 +7,6 @@ use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use const CASE_LOWER;
use function array_change_key_case; use function array_change_key_case;
use function array_filter; use function array_filter;
use function array_keys; use function array_keys;
...@@ -25,6 +24,7 @@ use function strlen; ...@@ -25,6 +24,7 @@ use function strlen;
use function strpos; use function strpos;
use function strtolower; use function strtolower;
use function trim; use function trim;
use const CASE_LOWER;
/** /**
* PostgreSQL Schema Manager. * PostgreSQL Schema Manager.
...@@ -141,6 +141,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -141,6 +141,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
if (preg_match('(ON UPDATE ([a-zA-Z0-9]+( (NULL|ACTION|DEFAULT))?))', $tableForeignKey['condef'], $match)) { if (preg_match('(ON UPDATE ([a-zA-Z0-9]+( (NULL|ACTION|DEFAULT))?))', $tableForeignKey['condef'], $match)) {
$onUpdate = $match[1]; $onUpdate = $match[1];
} }
if (preg_match('(ON DELETE ([a-zA-Z0-9]+( (NULL|ACTION|DEFAULT))?))', $tableForeignKey['condef'], $match)) { if (preg_match('(ON DELETE ([a-zA-Z0-9]+( (NULL|ACTION|DEFAULT))?))', $tableForeignKey['condef'], $match)) {
$onDelete = $match[1]; $onDelete = $match[1];
} }
...@@ -339,9 +340,11 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -339,9 +340,11 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
if ($length === '-1' && isset($tableColumn['atttypmod'])) { if ($length === '-1' && isset($tableColumn['atttypmod'])) {
$length = $tableColumn['atttypmod'] - 4; $length = $tableColumn['atttypmod'] - 4;
} }
if ((int) $length <= 0) { if ((int) $length <= 0) {
$length = null; $length = null;
} }
$fixed = null; $fixed = null;
if (! isset($tableColumn['name'])) { if (! isset($tableColumn['name'])) {
...@@ -368,17 +371,20 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -368,17 +371,20 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']); $tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']);
$length = null; $length = null;
break; break;
case 'int': case 'int':
case 'int4': case 'int4':
case 'integer': case 'integer':
$tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']); $tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']);
$length = null; $length = null;
break; break;
case 'bigint': case 'bigint':
case 'int8': case 'int8':
$tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']); $tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']);
$length = null; $length = null;
break; break;
case 'bool': case 'bool':
case 'boolean': case 'boolean':
if ($tableColumn['default'] === 'true') { if ($tableColumn['default'] === 'true') {
...@@ -391,6 +397,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -391,6 +397,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$length = null; $length = null;
break; break;
case 'text': case 'text':
case '_varchar': case '_varchar':
case 'varchar': case 'varchar':
...@@ -400,10 +407,12 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -400,10 +407,12 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
case 'interval': case 'interval':
$fixed = false; $fixed = false;
break; break;
case 'char': case 'char':
case 'bpchar': case 'bpchar':
$fixed = true; $fixed = true;
break; break;
case 'float': case 'float':
case 'float4': case 'float4':
case 'float8': case 'float8':
...@@ -420,7 +429,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -420,7 +429,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$scale = $match[2]; $scale = $match[2];
$length = null; $length = null;
} }
break; break;
case 'year': case 'year':
$length = null; $length = null;
break; break;
...@@ -490,13 +501,16 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -490,13 +501,16 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
return str_replace("''", "'", $default); return str_replace("''", "'", $default);
} }
/**
* {@inheritdoc}
*/
public function listTableDetails($tableName) : Table public function listTableDetails($tableName) : Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
/** @var PostgreSqlPlatform $platform */
$platform = $this->_platform; $platform = $this->_platform;
$sql = $platform->getListTableMetadataSQL($tableName); assert($platform instanceof PostgreSqlPlatform);
$sql = $platform->getListTableMetadataSQL($tableName);
$tableOptions = $this->_conn->fetchAssoc($sql); $tableOptions = $this->_conn->fetchAssoc($sql);
......
...@@ -112,6 +112,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -112,6 +112,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
case 'char': case 'char':
case 'nchar': case 'nchar':
$fixed = true; $fixed = true;
break;
} }
switch ($type) { switch ($type) {
...@@ -119,6 +120,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -119,6 +120,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
case 'float': case 'float':
$precision = $tableColumn['length']; $precision = $tableColumn['length'];
$scale = $tableColumn['scale']; $scale = $tableColumn['scale'];
break;
} }
return new Column( return new Column(
......
...@@ -87,11 +87,13 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -87,11 +87,13 @@ class SQLServerSchemaManager extends AbstractSchemaManager
// Unicode data requires 2 bytes per character // Unicode data requires 2 bytes per character
$length /= 2; $length /= 2;
break; break;
case 'varchar': case 'varchar':
// TEXT type is returned as VARCHAR(MAX) with a length of -1 // TEXT type is returned as VARCHAR(MAX) with a length of -1
if ($length === -1) { if ($length === -1) {
$dbType = 'text'; $dbType = 'text';
} }
break; break;
} }
...@@ -334,9 +336,9 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -334,9 +336,9 @@ class SQLServerSchemaManager extends AbstractSchemaManager
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
/** @var SQLServerPlatform $platform */
$platform = $this->_platform; $platform = $this->_platform;
$sql = $platform->getListTableMetadataSQL($tableName); assert($platform instanceof SQLServerPlatform);
$sql = $platform->getListTableMetadataSQL($tableName);
$tableOptions = $this->_conn->fetchAssoc($sql); $tableOptions = $this->_conn->fetchAssoc($sql);
......
...@@ -67,6 +67,7 @@ class Schema extends AbstractAsset ...@@ -67,6 +67,7 @@ class Schema extends AbstractAsset
if ($schemaConfig === null) { if ($schemaConfig === null) {
$schemaConfig = new SchemaConfig(); $schemaConfig = new SchemaConfig();
} }
$this->_schemaConfig = $schemaConfig; $this->_schemaConfig = $schemaConfig;
$this->_setName($schemaConfig->getName() ?: 'public'); $this->_setName($schemaConfig->getName() ?: 'public');
...@@ -287,7 +288,7 @@ class Schema extends AbstractAsset ...@@ -287,7 +288,7 @@ class Schema extends AbstractAsset
* *
* @param string $namespaceName The name of the namespace to create. * @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 * @throws SchemaException
*/ */
...@@ -329,7 +330,7 @@ class Schema extends AbstractAsset ...@@ -329,7 +330,7 @@ class Schema extends AbstractAsset
* @param string $oldTableName * @param string $oldTableName
* @param string $newTableName * @param string $newTableName
* *
* @return \Doctrine\DBAL\Schema\Schema * @return Schema
*/ */
public function renameTable($oldTableName, $newTableName) public function renameTable($oldTableName, $newTableName)
{ {
...@@ -347,7 +348,7 @@ class Schema extends AbstractAsset ...@@ -347,7 +348,7 @@ class Schema extends AbstractAsset
* *
* @param string $tableName * @param string $tableName
* *
* @return \Doctrine\DBAL\Schema\Schema * @return Schema
*/ */
public function dropTable($tableName) public function dropTable($tableName)
{ {
...@@ -378,7 +379,7 @@ class Schema extends AbstractAsset ...@@ -378,7 +379,7 @@ class Schema extends AbstractAsset
/** /**
* @param string $sequenceName * @param string $sequenceName
* *
* @return \Doctrine\DBAL\Schema\Schema * @return Schema
*/ */
public function dropSequence($sequenceName) public function dropSequence($sequenceName)
{ {
...@@ -468,6 +469,7 @@ class Schema extends AbstractAsset ...@@ -468,6 +469,7 @@ class Schema extends AbstractAsset
foreach ($this->_tables as $k => $table) { foreach ($this->_tables as $k => $table) {
$this->_tables[$k] = clone $table; $this->_tables[$k] = clone $table;
} }
foreach ($this->_sequences as $k => $sequence) { foreach ($this->_sequences as $k => $sequence) {
$this->_sequences[$k] = clone $sequence; $this->_sequences[$k] = clone $sequence;
} }
......
...@@ -155,6 +155,7 @@ class SchemaDiff ...@@ -155,6 +155,7 @@ class SchemaDiff
$foreignKeySql[] = $platform->getCreateForeignKeySQL($foreignKey, $table); $foreignKeySql[] = $platform->getCreateForeignKeySQL($foreignKey, $table);
} }
} }
$sql = array_merge($sql, $foreignKeySql); $sql = array_merge($sql, $foreignKeySql);
if ($saveMode === false) { if ($saveMode === false) {
......
...@@ -26,7 +26,7 @@ class SchemaException extends DBALException ...@@ -26,7 +26,7 @@ class SchemaException extends DBALException
/** /**
* @param string $tableName * @param string $tableName
* *
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function tableDoesNotExist($tableName) public static function tableDoesNotExist($tableName)
{ {
...@@ -36,7 +36,7 @@ class SchemaException extends DBALException ...@@ -36,7 +36,7 @@ class SchemaException extends DBALException
/** /**
* @param string $indexName * @param string $indexName
* *
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function indexNameInvalid($indexName) public static function indexNameInvalid($indexName)
{ {
...@@ -50,7 +50,7 @@ class SchemaException extends DBALException ...@@ -50,7 +50,7 @@ class SchemaException extends DBALException
* @param string $indexName * @param string $indexName
* @param string $table * @param string $table
* *
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function indexDoesNotExist($indexName, $table) public static function indexDoesNotExist($indexName, $table)
{ {
...@@ -64,7 +64,7 @@ class SchemaException extends DBALException ...@@ -64,7 +64,7 @@ class SchemaException extends DBALException
* @param string $indexName * @param string $indexName
* @param string $table * @param string $table
* *
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function indexAlreadyExists($indexName, $table) public static function indexAlreadyExists($indexName, $table)
{ {
...@@ -78,7 +78,7 @@ class SchemaException extends DBALException ...@@ -78,7 +78,7 @@ class SchemaException extends DBALException
* @param string $columnName * @param string $columnName
* @param string $table * @param string $table
* *
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function columnDoesNotExist($columnName, $table) public static function columnDoesNotExist($columnName, $table)
{ {
...@@ -91,7 +91,7 @@ class SchemaException extends DBALException ...@@ -91,7 +91,7 @@ class SchemaException extends DBALException
/** /**
* @param string $namespaceName * @param string $namespaceName
* *
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function namespaceAlreadyExists($namespaceName) public static function namespaceAlreadyExists($namespaceName)
{ {
...@@ -104,7 +104,7 @@ class SchemaException extends DBALException ...@@ -104,7 +104,7 @@ class SchemaException extends DBALException
/** /**
* @param string $tableName * @param string $tableName
* *
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function tableAlreadyExists($tableName) public static function tableAlreadyExists($tableName)
{ {
...@@ -115,7 +115,7 @@ class SchemaException extends DBALException ...@@ -115,7 +115,7 @@ class SchemaException extends DBALException
* @param string $tableName * @param string $tableName
* @param string $columnName * @param string $columnName
* *
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function columnAlreadyExists($tableName, $columnName) public static function columnAlreadyExists($tableName, $columnName)
{ {
...@@ -128,7 +128,7 @@ class SchemaException extends DBALException ...@@ -128,7 +128,7 @@ class SchemaException extends DBALException
/** /**
* @param string $sequenceName * @param string $sequenceName
* *
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function sequenceAlreadyExists($sequenceName) public static function sequenceAlreadyExists($sequenceName)
{ {
...@@ -138,7 +138,7 @@ class SchemaException extends DBALException ...@@ -138,7 +138,7 @@ class SchemaException extends DBALException
/** /**
* @param string $sequenceName * @param string $sequenceName
* *
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function sequenceDoesNotExist($sequenceName) public static function sequenceDoesNotExist($sequenceName)
{ {
...@@ -149,7 +149,7 @@ class SchemaException extends DBALException ...@@ -149,7 +149,7 @@ class SchemaException extends DBALException
* @param string $fkName * @param string $fkName
* @param string $table * @param string $table
* *
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function foreignKeyDoesNotExist($fkName, $table) public static function foreignKeyDoesNotExist($fkName, $table)
{ {
...@@ -160,7 +160,7 @@ class SchemaException extends DBALException ...@@ -160,7 +160,7 @@ class SchemaException extends DBALException
} }
/** /**
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function namedForeignKeyRequired(Table $localTable, ForeignKeyConstraint $foreignKey) public static function namedForeignKeyRequired(Table $localTable, ForeignKeyConstraint $foreignKey)
{ {
...@@ -175,7 +175,7 @@ class SchemaException extends DBALException ...@@ -175,7 +175,7 @@ class SchemaException extends DBALException
/** /**
* @param string $changeName * @param string $changeName
* *
* @return \Doctrine\DBAL\Schema\SchemaException * @return SchemaException
*/ */
public static function alterTableChangeNotSupported($changeName) public static function alterTableChangeNotSupported($changeName)
{ {
......
...@@ -61,7 +61,7 @@ class Sequence extends AbstractAsset ...@@ -61,7 +61,7 @@ class Sequence extends AbstractAsset
/** /**
* @param int $allocationSize * @param int $allocationSize
* *
* @return \Doctrine\DBAL\Schema\Sequence * @return Sequence
*/ */
public function setAllocationSize($allocationSize) public function setAllocationSize($allocationSize)
{ {
...@@ -73,7 +73,7 @@ class Sequence extends AbstractAsset ...@@ -73,7 +73,7 @@ class Sequence extends AbstractAsset
/** /**
* @param int $initialValue * @param int $initialValue
* *
* @return \Doctrine\DBAL\Schema\Sequence * @return Sequence
*/ */
public function setInitialValue($initialValue) public function setInitialValue($initialValue)
{ {
...@@ -85,7 +85,7 @@ class Sequence extends AbstractAsset ...@@ -85,7 +85,7 @@ class Sequence extends AbstractAsset
/** /**
* @param int $cache * @param int $cache
* *
* @return \Doctrine\DBAL\Schema\Sequence * @return Sequence
*/ */
public function setCache($cache) public function setCache($cache)
{ {
......
...@@ -8,7 +8,6 @@ use Doctrine\DBAL\FetchMode; ...@@ -8,7 +8,6 @@ use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Types\StringType; use Doctrine\DBAL\Types\StringType;
use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\TextType;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use const CASE_LOWER;
use function array_change_key_case; use function array_change_key_case;
use function array_map; use function array_map;
use function array_reverse; use function array_reverse;
...@@ -27,6 +26,7 @@ use function strtolower; ...@@ -27,6 +26,7 @@ use function strtolower;
use function trim; use function trim;
use function unlink; use function unlink;
use function usort; use function usort;
use const CASE_LOWER;
/** /**
* Sqlite SchemaManager. * Sqlite SchemaManager.
...@@ -113,6 +113,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -113,6 +113,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
if ($database === null) { if ($database === null) {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
} }
$sql = $this->_platform->getListTableForeignKeysSQL($table, $database); $sql = $this->_platform->getListTableForeignKeysSQL($table, $database);
$tableForeignKeys = $this->_conn->fetchAll($sql); $tableForeignKeys = $this->_conn->fetchAll($sql);
...@@ -358,8 +359,10 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -358,8 +359,10 @@ class SqliteSchemaManager extends AbstractSchemaManager
if (strpos($tableColumn['length'], ',') === false) { if (strpos($tableColumn['length'], ',') === false) {
$tableColumn['length'] .= ',0'; $tableColumn['length'] .= ',0';
} }
[$precision, $scale] = array_map('trim', explode(',', $tableColumn['length'])); [$precision, $scale] = array_map('trim', explode(',', $tableColumn['length']));
} }
$length = null; $length = null;
break; break;
} }
...@@ -399,6 +402,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -399,6 +402,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
if (! isset($value['on_delete']) || $value['on_delete'] === 'RESTRICT') { if (! isset($value['on_delete']) || $value['on_delete'] === 'RESTRICT') {
$value['on_delete'] = null; $value['on_delete'] = null;
} }
if (! isset($value['on_update']) || $value['on_update'] === 'RESTRICT') { if (! isset($value['on_update']) || $value['on_update'] === 'RESTRICT') {
$value['on_update'] = null; $value['on_update'] = null;
} }
...@@ -414,6 +418,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -414,6 +418,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
'deferred'=> $value['deferred'], 'deferred'=> $value['deferred'],
]; ];
} }
$list[$name]['local'][] = $value['from']; $list[$name]['local'][] = $value['from'];
$list[$name]['foreign'][] = $value['to']; $list[$name]['foreign'][] = $value['to'];
} }
......
...@@ -5,13 +5,13 @@ namespace Doctrine\DBAL\Schema; ...@@ -5,13 +5,13 @@ namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\DBAL\Schema\Visitor\Visitor;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use const ARRAY_FILTER_USE_KEY;
use function array_filter; use function array_filter;
use function array_merge; use function array_merge;
use function in_array; use function in_array;
use function preg_match; use function preg_match;
use function strlen; use function strlen;
use function strtolower; use function strtolower;
use const ARRAY_FILTER_USE_KEY;
/** /**
* Object Representation of a table. * Object Representation of a table.
...@@ -161,6 +161,7 @@ class Table extends AbstractAsset ...@@ -161,6 +161,7 @@ class Table extends AbstractAsset
if (! $this->hasIndex($indexName)) { if (! $this->hasIndex($indexName)) {
throw SchemaException::indexDoesNotExist($indexName, $this->_name); throw SchemaException::indexDoesNotExist($indexName, $this->_name);
} }
unset($this->_indexes[$indexName]); unset($this->_indexes[$indexName]);
} }
...@@ -240,7 +241,6 @@ class Table extends AbstractAsset ...@@ -240,7 +241,6 @@ class Table extends AbstractAsset
public function columnsAreIndexed(array $columnNames) public function columnsAreIndexed(array $columnNames)
{ {
foreach ($this->getIndexes() as $index) { foreach ($this->getIndexes() as $index) {
/** @var $index Index */
if ($index->spansColumns($columnNames)) { if ($index->spansColumns($columnNames)) {
return true; return true;
} }
...@@ -510,6 +510,7 @@ class Table extends AbstractAsset ...@@ -510,6 +510,7 @@ class Table extends AbstractAsset
$this->_getMaxIdentifierLength() $this->_getMaxIdentifierLength()
); );
} }
$name = $this->normalizeIdentifier($name); $name = $this->normalizeIdentifier($name);
$this->_fkConstraints[$name] = $constraint; $this->_fkConstraints[$name] = $constraint;
...@@ -816,9 +817,11 @@ class Table extends AbstractAsset ...@@ -816,9 +817,11 @@ class Table extends AbstractAsset
foreach ($this->_columns as $k => $column) { foreach ($this->_columns as $k => $column) {
$this->_columns[$k] = clone $column; $this->_columns[$k] = clone $column;
} }
foreach ($this->_indexes as $k => $index) { foreach ($this->_indexes as $k => $index) {
$this->_indexes[$k] = clone $index; $this->_indexes[$k] = clone $index;
} }
foreach ($this->_fkConstraints as $k => $fk) { foreach ($this->_fkConstraints as $k => $fk) {
$this->_fkConstraints[$k] = clone $fk; $this->_fkConstraints[$k] = clone $fk;
$this->_fkConstraints[$k]->setLocalTable($this); $this->_fkConstraints[$k]->setLocalTable($this);
......
...@@ -8,6 +8,7 @@ use Doctrine\DBAL\Schema\SchemaException; ...@@ -8,6 +8,7 @@ use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use SplObjectStorage; use SplObjectStorage;
use function assert;
use function strlen; use function strlen;
/** /**
...@@ -82,19 +83,19 @@ class DropSchemaSqlCollector extends AbstractVisitor ...@@ -82,19 +83,19 @@ class DropSchemaSqlCollector extends AbstractVisitor
{ {
$sql = []; $sql = [];
/** @var ForeignKeyConstraint $fkConstraint */
foreach ($this->constraints as $fkConstraint) { foreach ($this->constraints as $fkConstraint) {
assert($fkConstraint instanceof ForeignKeyConstraint);
$localTable = $this->constraints[$fkConstraint]; $localTable = $this->constraints[$fkConstraint];
$sql[] = $this->platform->getDropForeignKeySQL($fkConstraint, $localTable); $sql[] = $this->platform->getDropForeignKeySQL($fkConstraint, $localTable);
} }
/** @var Sequence $sequence */
foreach ($this->sequences as $sequence) { foreach ($this->sequences as $sequence) {
assert($sequence instanceof Sequence);
$sql[] = $this->platform->getDropSequenceSQL($sequence); $sql[] = $this->platform->getDropSequenceSQL($sequence);
} }
/** @var Table $table */
foreach ($this->tables as $table) { foreach ($this->tables as $table) {
assert($table instanceof Table);
$sql[] = $this->platform->getDropTableSQL($table); $sql[] = $this->platform->getDropTableSQL($table);
} }
......
...@@ -87,6 +87,7 @@ class Graphviz extends AbstractVisitor ...@@ -87,6 +87,7 @@ class Graphviz extends AbstractVisitor
if ($primaryKey !== null && in_array($column->getName(), $primaryKey->getColumns())) { if ($primaryKey !== null && in_array($column->getName(), $primaryKey->getColumns())) {
$label .= "\xe2\x9c\xb7"; $label .= "\xe2\x9c\xb7";
} }
$label .= '</TD></TR>'; $label .= '</TD></TR>';
} }
...@@ -108,6 +109,7 @@ class Graphviz extends AbstractVisitor ...@@ -108,6 +109,7 @@ class Graphviz extends AbstractVisitor
foreach ($options as $key => $value) { foreach ($options as $key => $value) {
$node .= $key . '=' . $value . ' '; $node .= $key . '=' . $value . ' ';
} }
$node .= "]\n"; $node .= "]\n";
return $node; return $node;
...@@ -126,6 +128,7 @@ class Graphviz extends AbstractVisitor ...@@ -126,6 +128,7 @@ class Graphviz extends AbstractVisitor
foreach ($options as $key => $value) { foreach ($options as $key => $value) {
$relation .= $key . '=' . $value . ' '; $relation .= $key . '=' . $value . ' ';
} }
$relation .= "]\n"; $relation .= "]\n";
return $relation; return $relation;
......
...@@ -108,6 +108,7 @@ class MultiTenantVisitor implements Visitor ...@@ -108,6 +108,7 @@ class MultiTenantVisitor implements Visitor
return $index; return $index;
} }
} }
throw new RuntimeException('No clustered index found on table ' . $table->getName()); throw new RuntimeException('No clustered index found on table ' . $table->getName());
} }
......
...@@ -12,7 +12,7 @@ use Doctrine\DBAL\DBALException; ...@@ -12,7 +12,7 @@ use Doctrine\DBAL\DBALException;
class ShardingException extends DBALException class ShardingException extends DBALException
{ {
/** /**
* @return \Doctrine\DBAL\Sharding\ShardingException * @return ShardingException
*/ */
public static function notImplemented() public static function notImplemented()
{ {
...@@ -20,7 +20,7 @@ class ShardingException extends DBALException ...@@ -20,7 +20,7 @@ class ShardingException extends DBALException
} }
/** /**
* @return \Doctrine\DBAL\Sharding\ShardingException * @return ShardingException
*/ */
public static function missingDefaultFederationName() public static function missingDefaultFederationName()
{ {
...@@ -28,7 +28,7 @@ class ShardingException extends DBALException ...@@ -28,7 +28,7 @@ class ShardingException extends DBALException
} }
/** /**
* @return \Doctrine\DBAL\Sharding\ShardingException * @return ShardingException
*/ */
public static function missingDefaultDistributionKey() public static function missingDefaultDistributionKey()
{ {
...@@ -36,7 +36,7 @@ class ShardingException extends DBALException ...@@ -36,7 +36,7 @@ class ShardingException extends DBALException
} }
/** /**
* @return \Doctrine\DBAL\Sharding\ShardingException * @return ShardingException
*/ */
public static function activeTransaction() public static function activeTransaction()
{ {
...@@ -44,7 +44,7 @@ class ShardingException extends DBALException ...@@ -44,7 +44,7 @@ class ShardingException extends DBALException
} }
/** /**
* @return \Doctrine\DBAL\Sharding\ShardingException * @return ShardingException
*/ */
public static function noShardDistributionValue() public static function noShardDistributionValue()
{ {
...@@ -52,7 +52,7 @@ class ShardingException extends DBALException ...@@ -52,7 +52,7 @@ class ShardingException extends DBALException
} }
/** /**
* @return \Doctrine\DBAL\Sharding\ShardingException * @return ShardingException
*/ */
public static function missingDistributionType() public static function missingDistributionType()
{ {
......
...@@ -95,6 +95,7 @@ class Statement implements IteratorAggregate, DriverStatement ...@@ -95,6 +95,7 @@ class Statement implements IteratorAggregate, DriverStatement
if (is_string($type)) { if (is_string($type)) {
$type = Type::getType($type); $type = Type::getType($type);
} }
if ($type instanceof Type) { if ($type instanceof Type) {
$value = $type->convertToDatabaseValue($value, $this->platform); $value = $type->convertToDatabaseValue($value, $this->platform);
$bindingType = $type->getBindingType(); $bindingType = $type->getBindingType();
...@@ -155,6 +156,7 @@ class Statement implements IteratorAggregate, DriverStatement ...@@ -155,6 +156,7 @@ class Statement implements IteratorAggregate, DriverStatement
if ($logger) { if ($logger) {
$logger->stopQuery(); $logger->stopQuery();
} }
throw DBALException::driverExceptionDuringQuery( throw DBALException::driverExceptionDuringQuery(
$this->conn->getDriver(), $this->conn->getDriver(),
$ex, $ex,
...@@ -166,6 +168,7 @@ class Statement implements IteratorAggregate, DriverStatement ...@@ -166,6 +168,7 @@ class Statement implements IteratorAggregate, DriverStatement
if ($logger) { if ($logger) {
$logger->stopQuery(); $logger->stopQuery();
} }
$this->params = []; $this->params = [];
$this->types = []; $this->types = [];
......
...@@ -11,7 +11,6 @@ use Symfony\Component\Console\Command\Command; ...@@ -11,7 +11,6 @@ use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use const PHP_EOL;
use function assert; use function assert;
use function error_get_last; use function error_get_last;
use function file_exists; use function file_exists;
...@@ -19,6 +18,7 @@ use function file_get_contents; ...@@ -19,6 +18,7 @@ use function file_get_contents;
use function is_readable; use function is_readable;
use function realpath; use function realpath;
use function sprintf; use function sprintf;
use const PHP_EOL;
/** /**
* Task for executing arbitrary SQL that can come from a file or directly from * Task for executing arbitrary SQL that can come from a file or directly from
......
...@@ -27,6 +27,7 @@ use Symfony\Component\Console\Input\InputInterface; ...@@ -27,6 +27,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use function array_keys; use function array_keys;
use function assert;
use function count; use function count;
use function implode; use function implode;
...@@ -120,8 +121,8 @@ EOT ...@@ -120,8 +121,8 @@ EOT
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
/** @var Connection $conn */
$conn = $this->getHelper('db')->getConnection(); $conn = $this->getHelper('db')->getConnection();
assert($conn instanceof Connection);
$keywordLists = (array) $input->getOption('list'); $keywordLists = (array) $input->getOption('list');
if (! $keywordLists) { if (! $keywordLists) {
...@@ -152,6 +153,7 @@ EOT ...@@ -152,6 +153,7 @@ EOT
'Known lists: ' . implode(', ', array_keys($this->keywordListClasses)) 'Known lists: ' . implode(', ', array_keys($this->keywordListClasses))
); );
} }
$class = $this->keywordListClasses[$keywordList]; $class = $this->keywordListClasses[$keywordList];
$keywords[] = new $class(); $keywords[] = new $class();
} }
......
...@@ -150,6 +150,7 @@ final class Dumper ...@@ -150,6 +150,7 @@ final class Dumper
if ($aux[0] === '') { if ($aux[0] === '') {
$name .= ':' . ($aux[1] === '*' ? 'protected' : $aux[1] . ':private'); $name .= ':' . ($aux[1] === '*' ? 'protected' : $aux[1] . ':private');
} }
$return->$name = self::export($clone[$key], $maxDepth - 1); $return->$name = self::export($clone[$key], $maxDepth - 1);
} }
......
...@@ -26,7 +26,7 @@ class ConversionException extends DBALException ...@@ -26,7 +26,7 @@ class ConversionException extends DBALException
* @param string $value * @param string $value
* @param string $toType * @param string $toType
* *
* @return \Doctrine\DBAL\Types\ConversionException * @return ConversionException
*/ */
public static function conversionFailed($value, $toType, ?Throwable $previous = null) public static function conversionFailed($value, $toType, ?Throwable $previous = null)
{ {
...@@ -43,7 +43,7 @@ class ConversionException extends DBALException ...@@ -43,7 +43,7 @@ class ConversionException extends DBALException
* @param string $toType * @param string $toType
* @param string $expectedFormat * @param string $expectedFormat
* *
* @return \Doctrine\DBAL\Types\ConversionException * @return ConversionException
*/ */
public static function conversionFailedFormat($value, $toType, $expectedFormat, ?Throwable $previous = null) public static function conversionFailedFormat($value, $toType, $expectedFormat, ?Throwable $previous = null)
{ {
...@@ -64,7 +64,7 @@ class ConversionException extends DBALException ...@@ -64,7 +64,7 @@ class ConversionException extends DBALException
* @param string $toType * @param string $toType
* @param string[] $possibleTypes * @param string[] $possibleTypes
* *
* @return \Doctrine\DBAL\Types\ConversionException * @return ConversionException
*/ */
public static function conversionFailedInvalidType( public static function conversionFailedInvalidType(
$value, $value,
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
namespace Doctrine\DBAL\Types; namespace Doctrine\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use const JSON_ERROR_NONE;
use function is_resource; use function is_resource;
use function json_decode; use function json_decode;
use function json_encode; use function json_encode;
use function json_last_error; use function json_last_error;
use function json_last_error_msg; use function json_last_error_msg;
use function stream_get_contents; use function stream_get_contents;
use const JSON_ERROR_NONE;
/** /**
* Type generating json objects values * Type generating json objects values
......
...@@ -222,7 +222,7 @@ abstract class Type ...@@ -222,7 +222,7 @@ abstract class Type
* *
* @param string $name The name of the type (as returned by getName()). * @param string $name The name of the type (as returned by getName()).
* *
* @return \Doctrine\DBAL\Types\Type * @return Type
* *
* @throws DBALException * @throws DBALException
*/ */
......
<?xml version="1.0"?> <?xml version="1.0"?>
<ruleset> <ruleset
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
>
<arg name="basepath" value="."/> <arg name="basepath" value="."/>
<arg name="extensions" value="php"/> <arg name="extensions" value="php"/>
<arg name="parallel" value="80"/> <arg name="parallel" value="80"/>
...@@ -17,15 +20,32 @@ ...@@ -17,15 +20,32 @@
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"/> <exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/> <exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/> <exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>
<exclude name="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing.IncorrectLinesCountAfterLastControlStructure"/>
<exclude name="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants.DisallowedLateStaticBindingForConstant"/> <exclude name="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants.DisallowedLateStaticBindingForConstant"/>
<exclude name="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing.IncorrectLinesCountAfterLastControlStructure"/>
<!-- https://github.com/slevomat/coding-standard/issues/867 -->
<exclude name="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing.IncorrectLinesCountAfterLastControlStructure"/>
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/issues/2937 -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline"/>
<exclude name="Squiz.NamingConventions.ValidVariableName.PublicHasUnderscore"/>
</rule> </rule>
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint"> <!-- Disable the rules that will require PHP 7.4 -->
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<property name="enableNativeTypeHint" value="false"/>
</properties>
</rule>
<rule ref="Squiz.NamingConventions.ValidVariableName.PublicHasUnderscore">
<exclude-pattern>*/lib/*</exclude-pattern> <exclude-pattern>*/lib/*</exclude-pattern>
</rule> </rule>
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint"> <rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint">
<exclude-pattern>*/lib/*</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint">
<exclude-pattern>*/lib/*</exclude-pattern> <exclude-pattern>*/lib/*</exclude-pattern>
</rule> </rule>
...@@ -45,6 +65,11 @@ ...@@ -45,6 +65,11 @@
<exclude-pattern>tests/Doctrine/Tests/DBAL/Tools/TestAsset/*</exclude-pattern> <exclude-pattern>tests/Doctrine/Tests/DBAL/Tools/TestAsset/*</exclude-pattern>
</rule> </rule>
<!-- https://github.com/slevomat/coding-standard/issues/868 -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses.UselessParentheses">
<exclude-pattern>tests/continuousphp/bootstrap.php</exclude-pattern>
</rule>
<!-- see https://github.com/squizlabs/PHP_CodeSniffer/issues/2099 --> <!-- see https://github.com/squizlabs/PHP_CodeSniffer/issues/2099 -->
<rule ref="Squiz.Commenting.FunctionComment.InvalidNoReturn"> <rule ref="Squiz.Commenting.FunctionComment.InvalidNoReturn">
<exclude-pattern>lib/Doctrine/DBAL/Platforms/AbstractPlatform.php</exclude-pattern> <exclude-pattern>lib/Doctrine/DBAL/Platforms/AbstractPlatform.php</exclude-pattern>
...@@ -52,6 +77,31 @@ ...@@ -52,6 +77,31 @@
<exclude-pattern>tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php</exclude-pattern> <exclude-pattern>tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php</exclude-pattern>
</rule> </rule>
<!-- see https://github.com/squizlabs/PHP_CodeSniffer/issues/2838 -->
<rule ref="Squiz.Commenting.FunctionComment.SpacingAfter">
<exclude-pattern>lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php</exclude-pattern>
</rule>
<rule ref="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps">
<!-- This test contains a fixture class that should use snake case -->
<exclude-pattern>tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php</exclude-pattern>
</rule>
<!-- https://github.com/squizlabs/PHP_CodeSniffer/issues/2837 -->
<rule ref="Squiz.NamingConventions.ValidVariableName.NotCamelCaps">
<!--
This file uses the return value db2_server_info(), which does not follow conventions
phpcs wrongly complains about it, and that has been reported here:
https://github.com/squizlabs/PHP_CodeSniffer/issues/2950
-->
<exclude-pattern>lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php</exclude-pattern>
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/issues/2837 -->
<exclude-pattern>lib/Doctrine/DBAL/SQLParserUtils.php</exclude-pattern>
<exclude-pattern>lib/Doctrine/DBAL/Tools/Dumper.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/DBAL/Tools/DumperTest.php</exclude-pattern>
</rule>
<!-- some statement classes close cursor using an empty while-loop --> <!-- some statement classes close cursor using an empty while-loop -->
<rule ref="Generic.CodeAnalysis.EmptyStatement.DetectedWhile"> <rule ref="Generic.CodeAnalysis.EmptyStatement.DetectedWhile">
<exclude-pattern>lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php</exclude-pattern> <exclude-pattern>lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php</exclude-pattern>
...@@ -62,21 +112,20 @@ ...@@ -62,21 +112,20 @@
<exclude-pattern>lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php</exclude-pattern> <exclude-pattern>lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php</exclude-pattern>
</rule> </rule>
<!-- see https://github.com/squizlabs/PHP_CodeSniffer/issues/2165 -->
<rule ref="Squiz.Arrays.ArrayDeclaration.SpaceBeforeComma">
<exclude-pattern>tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php</exclude-pattern>
</rule>
<!-- see https://github.com/doctrine/dbal/issues/3377 --> <!-- see https://github.com/doctrine/dbal/issues/3377 -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedNotEqualOperator"> <rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedNotEqualOperator">
<exclude-pattern>lib/Doctrine/DBAL/Schema/Comparator.php</exclude-pattern> <exclude-pattern>lib/Doctrine/DBAL/Schema/Comparator.php</exclude-pattern>
</rule> </rule>
<!-- see https://github.com/slevomat/coding-standard/issues/737 --> <!-- DB2_AUTOCOMMIT_ON/DB2_AUTOCOMMIT_OFF are of int type but db2_autocommit() incorrectly expects bool,
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.IncorrectReturnTypeHint"> see https://bugs.php.net/bug.php?id=77591 -->
<exclude-pattern>lib/Doctrine/DBAL/Types/ArrayType.php</exclude-pattern> <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing">
<exclude-pattern>lib/Doctrine/DBAL/Types/ObjectType.php</exclude-pattern> <exclude-pattern>lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php</exclude-pattern> </rule>
<!-- The SQLSRV_* functions are defined in the upper case by the sqlsrv extension and violate the standard
see https://docs.microsoft.com/en-us/sql/connect/php/constants-microsoft-drivers-for-php-for-sql-server -->
<rule ref="Squiz.PHP.LowercasePHPFunctions.UseStatementUppercase">
<exclude-pattern>lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php</exclude-pattern>
</rule> </rule>
</ruleset> </ruleset>
...@@ -17,9 +17,6 @@ class ConfigurationTest extends DbalTestCase ...@@ -17,9 +17,6 @@ class ConfigurationTest extends DbalTestCase
*/ */
protected $config; protected $config;
/**
* {@inheritdoc}
*/
protected function setUp() : void protected function setUp() : void
{ {
$this->config = new Configuration(); $this->config = new Configuration();
......
...@@ -165,13 +165,11 @@ class ConnectionTest extends DbalTestCase ...@@ -165,13 +165,11 @@ class ConnectionTest extends DbalTestCase
{ {
$eventManager = new EventManager(); $eventManager = new EventManager();
/** @var AbstractPlatform|MockObject $driver */
$platform = $this->createMock(AbstractPlatform::class); $platform = $this->createMock(AbstractPlatform::class);
$platform->expects($this->once()) $platform->expects($this->once())
->method('setEventManager') ->method('setEventManager')
->with($eventManager); ->with($eventManager);
/** @var Driver|MockObject $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
$driver->expects($this->any()) $driver->expects($this->any())
->method('getDatabasePlatform') ->method('getDatabasePlatform')
...@@ -564,7 +562,6 @@ class ConnectionTest extends DbalTestCase ...@@ -564,7 +562,6 @@ class ConnectionTest extends DbalTestCase
->with(FetchMode::ASSOCIATIVE) ->with(FetchMode::ASSOCIATIVE)
->will($this->returnValue($result)); ->will($this->returnValue($result));
/** @var Connection|MockObject $conn */
$conn = $this->getMockBuilder(Connection::class) $conn = $this->getMockBuilder(Connection::class)
->onlyMethods(['executeQuery']) ->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driverMock]) ->setConstructorArgs([[], $driverMock])
...@@ -600,7 +597,6 @@ class ConnectionTest extends DbalTestCase ...@@ -600,7 +597,6 @@ class ConnectionTest extends DbalTestCase
->with(FetchMode::NUMERIC) ->with(FetchMode::NUMERIC)
->will($this->returnValue($result)); ->will($this->returnValue($result));
/** @var Connection|MockObject $conn */
$conn = $this->getMockBuilder(Connection::class) $conn = $this->getMockBuilder(Connection::class)
->onlyMethods(['executeQuery']) ->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driverMock]) ->setConstructorArgs([[], $driverMock])
...@@ -637,7 +633,6 @@ class ConnectionTest extends DbalTestCase ...@@ -637,7 +633,6 @@ class ConnectionTest extends DbalTestCase
->with($column) ->with($column)
->will($this->returnValue($result)); ->will($this->returnValue($result));
/** @var Connection|MockObject $conn */
$conn = $this->getMockBuilder(Connection::class) $conn = $this->getMockBuilder(Connection::class)
->onlyMethods(['executeQuery']) ->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driverMock]) ->setConstructorArgs([[], $driverMock])
...@@ -672,7 +667,6 @@ class ConnectionTest extends DbalTestCase ...@@ -672,7 +667,6 @@ class ConnectionTest extends DbalTestCase
->method('fetchAll') ->method('fetchAll')
->will($this->returnValue($result)); ->will($this->returnValue($result));
/** @var Connection|MockObject $conn */
$conn = $this->getMockBuilder(Connection::class) $conn = $this->getMockBuilder(Connection::class)
->onlyMethods(['executeQuery']) ->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driverMock]) ->setConstructorArgs([[], $driverMock])
...@@ -710,7 +704,6 @@ class ConnectionTest extends DbalTestCase ...@@ -710,7 +704,6 @@ class ConnectionTest extends DbalTestCase
public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentException() : void public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentException() : void
{ {
/** @var Driver $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
$pdoMock = $this->createMock(\Doctrine\DBAL\Driver\Connection::class); $pdoMock = $this->createMock(\Doctrine\DBAL\Driver\Connection::class);
...@@ -769,13 +762,10 @@ class ConnectionTest extends DbalTestCase ...@@ -769,13 +762,10 @@ class ConnectionTest extends DbalTestCase
*/ */
public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() : void public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() : void
{ {
/** @var Driver|VersionAwarePlatformDriver|MockObject $driverMock */
$driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]); $driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]);
/** @var ServerInfoAwareConnection|MockObject $driverConnectionMock */
$driverConnectionMock = $this->createMock(ServerInfoAwareConnection::class); $driverConnectionMock = $this->createMock(ServerInfoAwareConnection::class);
/** @var AbstractPlatform|MockObject $platformMock */
$platformMock = $this->getMockForAbstractClass(AbstractPlatform::class); $platformMock = $this->getMockForAbstractClass(AbstractPlatform::class);
$connection = new Connection([], $driverMock); $connection = new Connection([], $driverMock);
...@@ -814,7 +804,6 @@ class ConnectionTest extends DbalTestCase ...@@ -814,7 +804,6 @@ class ConnectionTest extends DbalTestCase
$params = [666]; $params = [666];
$types = [ParameterType::INTEGER]; $types = [ParameterType::INTEGER];
/** @var QueryCacheProfile|MockObject $queryCacheProfileMock */
$queryCacheProfileMock = $this->createMock(QueryCacheProfile::class); $queryCacheProfileMock = $this->createMock(QueryCacheProfile::class);
$queryCacheProfileMock $queryCacheProfileMock
...@@ -829,7 +818,6 @@ class ConnectionTest extends DbalTestCase ...@@ -829,7 +818,6 @@ class ConnectionTest extends DbalTestCase
->with($query, $params, $types, $this->params) ->with($query, $params, $types, $this->params)
->will($this->returnValue(['cacheKey', 'realKey'])); ->will($this->returnValue(['cacheKey', 'realKey']));
/** @var Driver $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
self::assertInstanceOf( self::assertInstanceOf(
...@@ -851,7 +839,6 @@ class ConnectionTest extends DbalTestCase ...@@ -851,7 +839,6 @@ class ConnectionTest extends DbalTestCase
->with('cacheKey') ->with('cacheKey')
->will($this->returnValue(['realKey' => []])); ->will($this->returnValue(['realKey' => []]));
/** @var QueryCacheProfile|MockObject $queryCacheProfileMock */
$queryCacheProfileMock = $this->createMock(QueryCacheProfile::class); $queryCacheProfileMock = $this->createMock(QueryCacheProfile::class);
$queryCacheProfileMock $queryCacheProfileMock
...@@ -871,7 +858,6 @@ class ConnectionTest extends DbalTestCase ...@@ -871,7 +858,6 @@ class ConnectionTest extends DbalTestCase
$connectionParams['platform'] = $this->createMock(AbstractPlatform::class); $connectionParams['platform'] = $this->createMock(AbstractPlatform::class);
/** @var Driver $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
(new Connection($connectionParams, $driver))->executeCacheQuery($query, [], [], $queryCacheProfileMock); (new Connection($connectionParams, $driver))->executeCacheQuery($query, [], [], $queryCacheProfileMock);
...@@ -885,7 +871,6 @@ class ConnectionTest extends DbalTestCase ...@@ -885,7 +871,6 @@ class ConnectionTest extends DbalTestCase
$connectionParams = $this->params; $connectionParams = $this->params;
$connectionParams['platform'] = new stdClass(); $connectionParams['platform'] = new stdClass();
/** @var Driver $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
$this->expectException(DBALException::class); $this->expectException(DBALException::class);
...@@ -898,7 +883,6 @@ class ConnectionTest extends DbalTestCase ...@@ -898,7 +883,6 @@ class ConnectionTest extends DbalTestCase
*/ */
public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase() : void public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase() : void
{ {
/** @var Driver|VersionAwarePlatformDriver|MockObject $driverMock */
$driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]); $driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]);
$connection = new Connection(['dbname' => 'foo'], $driverMock); $connection = new Connection(['dbname' => 'foo'], $driverMock);
...@@ -923,16 +907,12 @@ class ConnectionTest extends DbalTestCase ...@@ -923,16 +907,12 @@ class ConnectionTest extends DbalTestCase
*/ */
public function testExecuteCacheQueryStripsPlatformFromConnectionParamsBeforeGeneratingCacheKeys() : void public function testExecuteCacheQueryStripsPlatformFromConnectionParamsBeforeGeneratingCacheKeys() : void
{ {
/** @var Driver|MockObject $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
/** @var AbstractPlatform|MockObject $platform */
$platform = $this->createMock(AbstractPlatform::class); $platform = $this->createMock(AbstractPlatform::class);
/** @var QueryCacheProfile|MockObject $queryCacheProfile */
$queryCacheProfile = $this->createMock(QueryCacheProfile::class); $queryCacheProfile = $this->createMock(QueryCacheProfile::class);
/** @var Cache|MockObject $resultCacheDriver */
$resultCacheDriver = $this->createMock(Cache::class); $resultCacheDriver = $this->createMock(Cache::class);
$queryCacheProfile $queryCacheProfile
......
...@@ -17,7 +17,6 @@ class DBALExceptionTest extends DbalTestCase ...@@ -17,7 +17,6 @@ class DBALExceptionTest extends DbalTestCase
{ {
public function testDriverExceptionDuringQueryAcceptsBinaryData() : void public function testDriverExceptionDuringQueryAcceptsBinaryData() : void
{ {
/** @var Driver $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
$e = DBALException::driverExceptionDuringQuery($driver, new Exception(), '', ['ABC', chr(128)]); $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), '', ['ABC', chr(128)]);
self::assertStringContainsString('with params ["ABC", "\x80"]', $e->getMessage()); self::assertStringContainsString('with params ["ABC", "\x80"]', $e->getMessage());
...@@ -25,7 +24,6 @@ class DBALExceptionTest extends DbalTestCase ...@@ -25,7 +24,6 @@ class DBALExceptionTest extends DbalTestCase
public function testDriverExceptionDuringQueryAcceptsResource() : void public function testDriverExceptionDuringQueryAcceptsResource() : void
{ {
/** @var Driver $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
$e = DBALException::driverExceptionDuringQuery($driver, new Exception(), 'INSERT INTO file (`content`) VALUES (?)', [1 => fopen(__FILE__, 'r')]); $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), 'INSERT INTO file (`content`) VALUES (?)', [1 => fopen(__FILE__, 'r')]);
self::assertStringContainsString('Resource', $e->getMessage()); self::assertStringContainsString('Resource', $e->getMessage());
...@@ -33,10 +31,8 @@ class DBALExceptionTest extends DbalTestCase ...@@ -33,10 +31,8 @@ class DBALExceptionTest extends DbalTestCase
public function testAvoidOverWrappingOnDriverException() : void public function testAvoidOverWrappingOnDriverException() : void
{ {
/** @var Driver $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
/** @var InnerDriverException $inner */
$inner = $this->createMock(InnerDriverException::class); $inner = $this->createMock(InnerDriverException::class);
$ex = new DriverException('', $inner); $ex = new DriverException('', $inner);
......
...@@ -28,7 +28,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; ...@@ -28,7 +28,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver; use Doctrine\DBAL\VersionAwarePlatformDriver;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use ReflectionProperty; use ReflectionProperty;
use function array_merge; use function array_merge;
use function get_class; use function get_class;
...@@ -79,7 +78,6 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -79,7 +78,6 @@ abstract class AbstractDriverTest extends DbalTestCase
$this->markTestSkipped('This test is only intended for exception converter drivers.'); $this->markTestSkipped('This test is only intended for exception converter drivers.');
} }
/** @var DriverExceptionInterface|MockObject $driverException */
$driverException = $this->getMockBuilder(DriverExceptionInterface::class) $driverException = $this->getMockBuilder(DriverExceptionInterface::class)
->setConstructorArgs([$message]) ->setConstructorArgs([$message])
->getMock(); ->getMock();
......
...@@ -44,10 +44,11 @@ class MysqliConnectionTest extends DbalFunctionalTestCase ...@@ -44,10 +44,11 @@ class MysqliConnectionTest extends DbalFunctionalTestCase
public function testRestoresErrorHandlerOnException() : void public function testRestoresErrorHandlerOnException() : void
{ {
$handler = static function () : bool { $handler = static function () : bool {
self::fail('Never expected this to be called'); self::fail('Never expected this to be called');
}; };
$default_handler = set_error_handler($handler);
$defaultHandler = set_error_handler($handler);
try { try {
new MysqliConnection(['host' => '255.255.255.255'], 'user', 'pass'); new MysqliConnection(['host' => '255.255.255.255'], 'user', 'pass');
...@@ -56,7 +57,7 @@ class MysqliConnectionTest extends DbalFunctionalTestCase ...@@ -56,7 +57,7 @@ class MysqliConnectionTest extends DbalFunctionalTestCase
self::assertSame('Network is unreachable', $e->getMessage()); 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();
restore_error_handler(); restore_error_handler();
} }
......
...@@ -97,9 +97,6 @@ class DriverTest extends AbstractPostgreSQLDriverTest ...@@ -97,9 +97,6 @@ class DriverTest extends AbstractPostgreSQLDriverTest
} }
} }
/**
* {@inheritDoc}
*/
protected function createDriver() : DriverInterface protected function createDriver() : DriverInterface
{ {
return new Driver(); return new Driver();
......
...@@ -11,7 +11,6 @@ use Doctrine\DBAL\Driver\Statement; ...@@ -11,7 +11,6 @@ use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\Driver\StatementIterator;
use Doctrine\DBAL\Portability\Statement as PortabilityStatement; use Doctrine\DBAL\Portability\Statement as PortabilityStatement;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use IteratorAggregate;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use Traversable; use Traversable;
use function extension_loaded; use function extension_loaded;
...@@ -23,7 +22,6 @@ class StatementIteratorTest extends DbalTestCase ...@@ -23,7 +22,6 @@ class StatementIteratorTest extends DbalTestCase
*/ */
public function testGettingIteratorDoesNotCallFetch(string $class) : void public function testGettingIteratorDoesNotCallFetch(string $class) : void
{ {
/** @var IteratorAggregate|MockObject $stmt */
$stmt = $this->createPartialMock($class, ['fetch', 'fetchAll', 'fetchColumn']); $stmt = $this->createPartialMock($class, ['fetch', 'fetchAll', 'fetchColumn']);
$stmt->expects($this->never())->method('fetch'); $stmt->expects($this->never())->method('fetch');
$stmt->expects($this->never())->method('fetchAll'); $stmt->expects($this->never())->method('fetchAll');
...@@ -71,6 +69,9 @@ class StatementIteratorTest extends DbalTestCase ...@@ -71,6 +69,9 @@ class StatementIteratorTest extends DbalTestCase
}); });
} }
/**
* @param Traversable<int, mixed> $iterator
*/
private function assertIterationCallsFetchOncePerStep(Traversable $iterator, int &$calls) : void private function assertIterationCallsFetchOncePerStep(Traversable $iterator, int &$calls) : void
{ {
foreach ($iterator as $i => $_) { foreach ($iterator as $i => $_) {
......
...@@ -60,13 +60,16 @@ class ConnectionTest extends DbalFunctionalTestCase ...@@ -60,13 +60,16 @@ class ConnectionTest extends DbalFunctionalTestCase
try { try {
$this->connection->beginTransaction(); $this->connection->beginTransaction();
self::assertEquals(2, $this->connection->getTransactionNestingLevel()); self::assertEquals(2, $this->connection->getTransactionNestingLevel());
throw new Exception(); throw new Exception();
$this->connection->commit(); // never reached $this->connection->commit(); // never reached
} catch (Throwable $e) { } catch (Throwable $e) {
$this->connection->rollBack(); $this->connection->rollBack();
self::assertEquals(1, $this->connection->getTransactionNestingLevel()); self::assertEquals(1, $this->connection->getTransactionNestingLevel());
//no rethrow //no rethrow
} }
self::assertTrue($this->connection->isRollbackOnly()); self::assertTrue($this->connection->isRollbackOnly());
$this->connection->commit(); // should throw exception $this->connection->commit(); // should throw exception
...@@ -130,13 +133,16 @@ class ConnectionTest extends DbalFunctionalTestCase ...@@ -130,13 +133,16 @@ class ConnectionTest extends DbalFunctionalTestCase
self::assertEquals(3, $this->connection->getTransactionNestingLevel()); self::assertEquals(3, $this->connection->getTransactionNestingLevel());
self::assertTrue($this->connection->commit()); self::assertTrue($this->connection->commit());
self::assertEquals(2, $this->connection->getTransactionNestingLevel()); self::assertEquals(2, $this->connection->getTransactionNestingLevel());
throw new Exception(); throw new Exception();
$this->connection->commit(); // never reached $this->connection->commit(); // never reached
} catch (Throwable $e) { } catch (Throwable $e) {
$this->connection->rollBack(); $this->connection->rollBack();
self::assertEquals(1, $this->connection->getTransactionNestingLevel()); self::assertEquals(1, $this->connection->getTransactionNestingLevel());
//no rethrow //no rethrow
} }
self::assertFalse($this->connection->isRollbackOnly()); self::assertFalse($this->connection->isRollbackOnly());
try { try {
$this->connection->setNestTransactionsWithSavepoints(false); $this->connection->setNestTransactionsWithSavepoints(false);
...@@ -144,6 +150,7 @@ class ConnectionTest extends DbalFunctionalTestCase ...@@ -144,6 +150,7 @@ class ConnectionTest extends DbalFunctionalTestCase
} catch (ConnectionException $e) { } catch (ConnectionException $e) {
self::assertTrue($this->connection->getNestTransactionsWithSavepoints()); self::assertTrue($this->connection->getNestTransactionsWithSavepoints());
} }
$this->connection->commit(); // should not throw exception $this->connection->commit(); // should not throw exception
} catch (ConnectionException $e) { } catch (ConnectionException $e) {
$this->fail('Transaction commit after failed nested transaction should not fail when using savepoints.'); $this->fail('Transaction commit after failed nested transaction should not fail when using savepoints.');
...@@ -246,6 +253,7 @@ class ConnectionTest extends DbalFunctionalTestCase ...@@ -246,6 +253,7 @@ class ConnectionTest extends DbalFunctionalTestCase
$this->connection->transactional(static function ($conn) : void { $this->connection->transactional(static function ($conn) : void {
/** @var Connection $conn */ /** @var Connection $conn */
$conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
throw new RuntimeException('Ooops!'); throw new RuntimeException('Ooops!');
}); });
$this->fail('Expected exception'); $this->fail('Expected exception');
...@@ -260,6 +268,7 @@ class ConnectionTest extends DbalFunctionalTestCase ...@@ -260,6 +268,7 @@ class ConnectionTest extends DbalFunctionalTestCase
$this->connection->transactional(static function ($conn) : void { $this->connection->transactional(static function ($conn) : void {
/** @var Connection $conn */ /** @var Connection $conn */
$conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
throw new Error('Ooops!'); throw new Error('Ooops!');
}); });
$this->fail('Expected exception'); $this->fail('Expected exception');
......
...@@ -19,8 +19,6 @@ use Doctrine\DBAL\Statement; ...@@ -19,8 +19,6 @@ use Doctrine\DBAL\Statement;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\DbalFunctionalTestCase;
use PDO; use PDO;
use const CASE_LOWER;
use const PHP_EOL;
use function array_change_key_case; use function array_change_key_case;
use function array_filter; use function array_filter;
use function array_keys; use function array_keys;
...@@ -32,6 +30,8 @@ use function json_encode; ...@@ -32,6 +30,8 @@ use function json_encode;
use function property_exists; use function property_exists;
use function sprintf; use function sprintf;
use function strtotime; use function strtotime;
use const CASE_LOWER;
use const PHP_EOL;
class DataAccessTest extends DbalFunctionalTestCase class DataAccessTest extends DbalFunctionalTestCase
{ {
...@@ -953,8 +953,8 @@ class DataAccessTest extends DbalFunctionalTestCase ...@@ -953,8 +953,8 @@ class DataAccessTest extends DbalFunctionalTestCase
return; return;
} }
/** @var PDOConnection $connection */
$connection = $this->connection->getWrappedConnection(); $connection = $this->connection->getWrappedConnection();
self::assertInstanceOf(PDOConnection::class, $connection);
$connection->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); $connection->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
} }
} }
......
...@@ -24,25 +24,16 @@ class DB2DriverTest extends AbstractDriverTest ...@@ -24,25 +24,16 @@ class DB2DriverTest extends AbstractDriverTest
$this->markTestSkipped('ibm_db2 only test.'); $this->markTestSkipped('ibm_db2 only test.');
} }
/**
* {@inheritdoc}
*/
public function testConnectsWithoutDatabaseNameParameter() : void public function testConnectsWithoutDatabaseNameParameter() : void
{ {
$this->markTestSkipped('IBM DB2 does not support connecting without database name.'); $this->markTestSkipped('IBM DB2 does not support connecting without database name.');
} }
/**
* {@inheritdoc}
*/
public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void
{ {
$this->markTestSkipped('IBM DB2 does not support connecting without database name.'); $this->markTestSkipped('IBM DB2 does not support connecting without database name.');
} }
/**
* {@inheritdoc}
*/
protected function createDriver() : Driver protected function createDriver() : Driver
{ {
return new DB2Driver(); return new DB2Driver();
......
...@@ -6,8 +6,8 @@ use Doctrine\DBAL\Driver\Mysqli\Driver; ...@@ -6,8 +6,8 @@ use Doctrine\DBAL\Driver\Mysqli\Driver;
use Doctrine\DBAL\Driver\Mysqli\MysqliConnection; use Doctrine\DBAL\Driver\Mysqli\MysqliConnection;
use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\DBAL\Driver\Mysqli\MysqliException;
use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\DbalFunctionalTestCase;
use const MYSQLI_OPT_CONNECT_TIMEOUT;
use function extension_loaded; use function extension_loaded;
use const MYSQLI_OPT_CONNECT_TIMEOUT;
class ConnectionTest extends DbalFunctionalTestCase class ConnectionTest extends DbalFunctionalTestCase
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment