Unverified Commit 61a01133 authored by Sergei Morozov's avatar Sergei Morozov Committed by GitHub

Merge pull request #4150 from morozov/coding-standard-8.1

Update doctrine/coding-standard to 8.1
parents 7dc21385 8739b528
...@@ -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": "dec9fb0cafafeca81a6e257452a8d7e2", "content-hash": "8fe7de32ab1cec3ff8b2908b5b9e8de4",
"packages": [ "packages": [
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
...@@ -477,22 +477,22 @@ ...@@ -477,22 +477,22 @@
}, },
{ {
"name": "dealerdirect/phpcodesniffer-composer-installer", "name": "dealerdirect/phpcodesniffer-composer-installer",
"version": "v0.5.0", "version": "v0.7.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
"reference": "e749410375ff6fb7a040a68878c656c2e610b132" "reference": "e8d808670b8f882188368faaf1144448c169c0b7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e749410375ff6fb7a040a68878c656c2e610b132", "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e8d808670b8f882188368faaf1144448c169c0b7",
"reference": "e749410375ff6fb7a040a68878c656c2e610b132", "reference": "e8d808670b8f882188368faaf1144448c169c0b7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"composer-plugin-api": "^1.0", "composer-plugin-api": "^1.0 || ^2.0",
"php": "^5.3|^7", "php": ">=5.3",
"squizlabs/php_codesniffer": "^2|^3" "squizlabs/php_codesniffer": "^2 || ^3 || 4.0.x-dev"
}, },
"require-dev": { "require-dev": {
"composer/composer": "*", "composer/composer": "*",
...@@ -539,27 +539,27 @@ ...@@ -539,27 +539,27 @@
"stylecheck", "stylecheck",
"tests" "tests"
], ],
"time": "2018-10-26T13:21:45+00:00" "time": "2020-06-25T14:57:39+00:00"
}, },
{ {
"name": "doctrine/coding-standard", "name": "doctrine/coding-standard",
"version": "7.0.2", "version": "8.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/coding-standard.git", "url": "https://github.com/doctrine/coding-standard.git",
"reference": "d8a60ec4da68025c42795b714f66e277dd3e11de" "reference": "637003febec655f1b27f4301b44bf2264be57434"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/coding-standard/zipball/d8a60ec4da68025c42795b714f66e277dd3e11de", "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/637003febec655f1b27f4301b44bf2264be57434",
"reference": "d8a60ec4da68025c42795b714f66e277dd3e11de", "reference": "637003febec655f1b27f4301b44bf2264be57434",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7",
"php": "^7.2", "php": "^7.2 || ^8.0",
"slevomat/coding-standard": "^6.0", "slevomat/coding-standard": "^6.3.9",
"squizlabs/php_codesniffer": "^3.5.3" "squizlabs/php_codesniffer": "^3.5.5"
}, },
"type": "phpcodesniffer-standard", "type": "phpcodesniffer-standard",
"extra": { "extra": {
...@@ -567,11 +567,6 @@ ...@@ -567,11 +567,6 @@
"dev-master": "7.0.x-dev" "dev-master": "7.0.x-dev"
} }
}, },
"autoload": {
"psr-4": {
"Doctrine\\Sniffs\\": "lib/Doctrine/Sniffs"
}
},
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
...@@ -600,7 +595,7 @@ ...@@ -600,7 +595,7 @@
"standard", "standard",
"style" "style"
], ],
"time": "2019-12-11T07:59:21+00:00" "time": "2020-07-05T20:35:22+00:00"
}, },
{ {
"name": "doctrine/instantiator", "name": "doctrine/instantiator",
......
...@@ -8,6 +8,7 @@ use Doctrine\DBAL\FetchMode; ...@@ -8,6 +8,7 @@ use Doctrine\DBAL\FetchMode;
use InvalidArgumentException; use InvalidArgumentException;
use IteratorAggregate; use IteratorAggregate;
use PDO; use PDO;
use function array_merge; use function array_merge;
use function array_values; use function array_values;
use function count; use function count;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Cache; namespace Doctrine\DBAL\Cache;
use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\Cache;
use function hash; use function hash;
use function serialize; use function serialize;
use function sha1; use function sha1;
......
...@@ -10,6 +10,7 @@ use Doctrine\DBAL\FetchMode; ...@@ -10,6 +10,7 @@ use Doctrine\DBAL\FetchMode;
use InvalidArgumentException; use InvalidArgumentException;
use IteratorAggregate; use IteratorAggregate;
use PDO; use PDO;
use function array_merge; use function array_merge;
use function array_values; use function array_values;
use function assert; use function assert;
......
...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL; ...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL;
use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\Cache;
use Doctrine\DBAL\Logging\SQLLogger; use Doctrine\DBAL\Logging\SQLLogger;
use Doctrine\DBAL\Schema\AbstractAsset; use Doctrine\DBAL\Schema\AbstractAsset;
use function preg_match; use function preg_match;
/** /**
...@@ -101,7 +102,7 @@ class Configuration ...@@ -101,7 +102,7 @@ class Configuration
/** /**
* @param string $filterExpression * @param string $filterExpression
*/ */
private function buildSchemaAssetsFilterFromExpression($filterExpression) : callable private function buildSchemaAssetsFilterFromExpression($filterExpression): callable
{ {
return static function ($assetName) use ($filterExpression) { return static function ($assetName) use ($filterExpression) {
if ($assetName instanceof AbstractAsset) { if ($assetName instanceof AbstractAsset) {
...@@ -115,7 +116,7 @@ class Configuration ...@@ -115,7 +116,7 @@ class Configuration
/** /**
* Sets the callable to use to filter schema assets. * Sets the callable to use to filter schema assets.
*/ */
public function setSchemaAssetsFilter(?callable $callable = null) : ?callable public function setSchemaAssetsFilter(?callable $callable = null): ?callable
{ {
$this->_attributes['filterSchemaAssetsExpression'] = null; $this->_attributes['filterSchemaAssetsExpression'] = null;
...@@ -125,7 +126,7 @@ class Configuration ...@@ -125,7 +126,7 @@ class Configuration
/** /**
* Returns the callable to use to filter schema assets. * Returns the callable to use to filter schema assets.
*/ */
public function getSchemaAssetsFilter() : ?callable public function getSchemaAssetsFilter(): ?callable
{ {
return $this->_attributes['filterSchemaAssetsExpressionCallable'] ?? null; return $this->_attributes['filterSchemaAssetsExpressionCallable'] ?? null;
} }
......
...@@ -20,6 +20,7 @@ use Doctrine\DBAL\Schema\AbstractSchemaManager; ...@@ -20,6 +20,7 @@ use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Exception; use Exception;
use Throwable; use Throwable;
use function array_key_exists; use function array_key_exists;
use function assert; use function assert;
use function func_get_args; use function func_get_args;
...@@ -382,7 +383,7 @@ class Connection implements DriverConnection ...@@ -382,7 +383,7 @@ class Connection implements DriverConnection
* *
* @throws DBALException If an invalid platform was specified for this connection. * @throws DBALException If an invalid platform was specified for this connection.
*/ */
private function detectDatabasePlatform() : void private function detectDatabasePlatform(): void
{ {
$version = $this->getDatabasePlatformVersion(); $version = $this->getDatabasePlatformVersion();
...@@ -622,7 +623,7 @@ class Connection implements DriverConnection ...@@ -622,7 +623,7 @@ class Connection implements DriverConnection
array &$columns, array &$columns,
array &$values, array &$values,
array &$conditions array &$conditions
) : void { ): void {
$platform = $this->getDatabasePlatform(); $platform = $this->getDatabasePlatform();
foreach ($identifier as $columnName => $value) { foreach ($identifier as $columnName => $value) {
...@@ -1323,7 +1324,7 @@ class Connection implements DriverConnection ...@@ -1323,7 +1324,7 @@ class Connection implements DriverConnection
/** /**
* Commits all current nesting transactions. * Commits all current nesting transactions.
*/ */
private function commitAll() : void private function commitAll(): void
{ {
while ($this->transactionNestingLevel !== 0) { while ($this->transactionNestingLevel !== 0) {
if ($this->autoCommit === false && $this->transactionNestingLevel === 1) { if ($this->autoCommit === false && $this->transactionNestingLevel === 1) {
......
...@@ -10,6 +10,7 @@ use Doctrine\DBAL\Driver\Connection as DriverConnection; ...@@ -10,6 +10,7 @@ use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events; use Doctrine\DBAL\Events;
use InvalidArgumentException; use InvalidArgumentException;
use function array_rand; use function array_rand;
use function assert; use function assert;
use function count; use function count;
......
...@@ -9,6 +9,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; ...@@ -9,6 +9,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Exception; use Exception;
use Throwable; use Throwable;
use function array_map; use function array_map;
use function bin2hex; use function bin2hex;
use function get_class; use function get_class;
...@@ -37,7 +38,7 @@ class DBALException extends Exception ...@@ -37,7 +38,7 @@ class DBALException extends Exception
return new self(sprintf("Operation '%s' is not supported by platform.", $method)); return new self(sprintf("Operation '%s' is not supported by platform.", $method));
} }
public static function invalidPlatformSpecified() : self public static function invalidPlatformSpecified(): self
{ {
return new self( return new self(
"Invalid 'platform' option specified, need to give an instance of " . AbstractPlatform::class . '.' "Invalid 'platform' option specified, need to give an instance of " . AbstractPlatform::class . '.'
...@@ -47,7 +48,7 @@ class DBALException extends Exception ...@@ -47,7 +48,7 @@ class DBALException extends Exception
/** /**
* @param mixed $invalidPlatform * @param mixed $invalidPlatform
*/ */
public static function invalidPlatformType($invalidPlatform) : self public static function invalidPlatformType($invalidPlatform): self
{ {
if (is_object($invalidPlatform)) { if (is_object($invalidPlatform)) {
return new self( return new self(
...@@ -285,12 +286,12 @@ class DBALException extends Exception ...@@ -285,12 +286,12 @@ class DBALException extends Exception
return new self('Type to be overwritten ' . $name . ' does not exist.'); return new self('Type to be overwritten ' . $name . ' does not exist.');
} }
public static function typeNotRegistered(Type $type) : self public static function typeNotRegistered(Type $type): self
{ {
return new self(sprintf('Type of the class %s@%s is not registered.', get_class($type), spl_object_hash($type))); return new self(sprintf('Type of the class %s@%s is not registered.', get_class($type), spl_object_hash($type)));
} }
public static function typeAlreadyRegistered(Type $type) : self public static function typeAlreadyRegistered(Type $type): self
{ {
return new self( return new self(
sprintf('Type of the class %s@%s is already registered.', get_class($type), spl_object_hash($type)) sprintf('Type of the class %s@%s is already registered.', get_class($type), spl_object_hash($type))
......
...@@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\MySQL80Platform; ...@@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\MySqlSchemaManager; use Doctrine\DBAL\Schema\MySqlSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver; use Doctrine\DBAL\VersionAwarePlatformDriver;
use function assert; use function assert;
use function preg_match; use function preg_match;
use function stripos; use function stripos;
...@@ -143,13 +144,15 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -143,13 +144,15 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
* *
* @throws DBALException * @throws DBALException
*/ */
private function getOracleMysqlVersionNumber(string $versionString) : string private function getOracleMysqlVersionNumber(string $versionString): string
{ {
if (! preg_match( if (
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', ! preg_match(
$versionString, '/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/',
$versionParts $versionString,
)) { $versionParts
)
) {
throw DBALException::invalidPlatformVersionSpecified( throw DBALException::invalidPlatformVersionSpecified(
$versionString, $versionString,
'<major_version>.<minor_version>.<patch_version>' '<major_version>.<minor_version>.<patch_version>'
...@@ -175,13 +178,15 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, ...@@ -175,13 +178,15 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
* *
* @throws DBALException * @throws DBALException
*/ */
private function getMariaDbMysqlVersionNumber(string $versionString) : string private function getMariaDbMysqlVersionNumber(string $versionString): string
{ {
if (! preg_match( if (
'/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i', ! preg_match(
$versionString, '/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i',
$versionParts $versionString,
)) { $versionParts
)
) {
throw DBALException::invalidPlatformVersionSpecified( throw DBALException::invalidPlatformVersionSpecified(
$versionString, $versionString,
'^(?:5\.5\.5-)?(mariadb-)?<major_version>.<minor_version>.<patch_version>' '^(?:5\.5\.5-)?(mariadb-)?<major_version>.<minor_version>.<patch_version>'
......
...@@ -23,7 +23,7 @@ final class EasyConnectString ...@@ -23,7 +23,7 @@ final class EasyConnectString
$this->string = $string; $this->string = $string;
} }
public function __toString() : string public function __toString(): string
{ {
return $this->string; return $this->string;
} }
...@@ -33,7 +33,7 @@ final class EasyConnectString ...@@ -33,7 +33,7 @@ final class EasyConnectString
* *
* @param mixed[] $params * @param mixed[] $params
*/ */
public static function fromArray(array $params) : self public static function fromArray(array $params): self
{ {
return new self(self::renderParams($params)); return new self(self::renderParams($params));
} }
...@@ -43,7 +43,7 @@ final class EasyConnectString ...@@ -43,7 +43,7 @@ final class EasyConnectString
* *
* @param mixed[] $params * @param mixed[] $params
*/ */
public static function fromConnectionParameters(array $params) : self public static function fromConnectionParameters(array $params): self
{ {
if (! empty($params['connectstring'])) { if (! empty($params['connectstring'])) {
return new self($params['connectstring']); return new self($params['connectstring']);
...@@ -90,7 +90,7 @@ final class EasyConnectString ...@@ -90,7 +90,7 @@ final class EasyConnectString
/** /**
* @param mixed[] $params * @param mixed[] $params
*/ */
private static function renderParams(array $params) : string private static function renderParams(array $params): string
{ {
$chunks = []; $chunks = [];
...@@ -110,7 +110,7 @@ final class EasyConnectString ...@@ -110,7 +110,7 @@ final class EasyConnectString
/** /**
* @param mixed $value * @param mixed $value
*/ */
private static function renderValue($value) : string private static function renderValue($value): string
{ {
if (is_array($value)) { if (is_array($value)) {
return self::renderParams($value); return self::renderParams($value);
......
...@@ -13,6 +13,7 @@ use Doctrine\DBAL\Platforms\PostgreSQL94Platform; ...@@ -13,6 +13,7 @@ use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager; use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver; use Doctrine\DBAL\VersionAwarePlatformDriver;
use function assert; use function assert;
use function preg_match; use function preg_match;
use function strpos; use function strpos;
......
...@@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\SQLAnywhere16Platform; ...@@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\SQLAnywhere16Platform;
use Doctrine\DBAL\Platforms\SQLAnywherePlatform; use Doctrine\DBAL\Platforms\SQLAnywherePlatform;
use Doctrine\DBAL\Schema\SQLAnywhereSchemaManager; use Doctrine\DBAL\Schema\SQLAnywhereSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver; use Doctrine\DBAL\VersionAwarePlatformDriver;
use function assert; use function assert;
use function preg_match; use function preg_match;
use function version_compare; use function version_compare;
...@@ -81,11 +82,13 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr ...@@ -81,11 +82,13 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
*/ */
public function createDatabasePlatformForVersion($version) public function createDatabasePlatformForVersion($version)
{ {
if (! preg_match( if (
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/', ! preg_match(
$version, '/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/',
$versionParts $version,
)) { $versionParts
)
) {
throw DBALException::invalidPlatformVersionSpecified( throw DBALException::invalidPlatformVersionSpecified(
$version, $version,
'<major_version>.<minor_version>.<patch_version>.<build_version>' '<major_version>.<minor_version>.<patch_version>.<build_version>'
......
...@@ -11,6 +11,7 @@ use Doctrine\DBAL\Platforms\SQLServer2012Platform; ...@@ -11,6 +11,7 @@ use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\SQLServerSchemaManager; use Doctrine\DBAL\Schema\SQLServerSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver; use Doctrine\DBAL\VersionAwarePlatformDriver;
use function assert; use function assert;
use function preg_match; use function preg_match;
use function version_compare; use function version_compare;
...@@ -25,11 +26,13 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr ...@@ -25,11 +26,13 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
*/ */
public function createDatabasePlatformForVersion($version) public function createDatabasePlatformForVersion($version)
{ {
if (! preg_match( if (
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/', ! preg_match(
$version, '/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/',
$versionParts $version,
)) { $versionParts
)
) {
throw DBALException::invalidPlatformVersionSpecified( throw DBALException::invalidPlatformVersionSpecified(
$version, $version,
'<major_version>.<minor_version>.<patch_version>.<build_version>' '<major_version>.<minor_version>.<patch_version>.<build_version>'
......
...@@ -13,7 +13,7 @@ use Doctrine\DBAL\Driver\AbstractDriverException; ...@@ -13,7 +13,7 @@ use Doctrine\DBAL\Driver\AbstractDriverException;
*/ */
final class PortWithoutHost extends AbstractDriverException final class PortWithoutHost extends AbstractDriverException
{ {
public static function new() : self public static function new(): self
{ {
return new self('Connection port specified without the host'); return new self('Connection port specified without the host');
} }
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver; ...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\SqliteSchemaManager; use Doctrine\DBAL\Schema\SqliteSchemaManager;
use function strpos; use function strpos;
/** /**
...@@ -25,7 +26,8 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver ...@@ -25,7 +26,8 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver
return new Exception\LockWaitTimeoutException($message, $exception); return new Exception\LockWaitTimeoutException($message, $exception);
} }
if (strpos($exception->getMessage(), 'must be unique') !== false || if (
strpos($exception->getMessage(), 'must be unique') !== false ||
strpos($exception->getMessage(), 'is not unique') !== false || strpos($exception->getMessage(), 'is not unique') !== false ||
strpos($exception->getMessage(), 'are not unique') !== false || strpos($exception->getMessage(), 'are not unique') !== false ||
strpos($exception->getMessage(), 'UNIQUE constraint failed') !== false strpos($exception->getMessage(), 'UNIQUE constraint failed') !== false
...@@ -33,7 +35,8 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver ...@@ -33,7 +35,8 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver
return new Exception\UniqueConstraintViolationException($message, $exception); return new Exception\UniqueConstraintViolationException($message, $exception);
} }
if (strpos($exception->getMessage(), 'may not be NULL') !== false || if (
strpos($exception->getMessage(), 'may not be NULL') !== false ||
strpos($exception->getMessage(), 'NOT NULL constraint failed') !== false strpos($exception->getMessage(), 'NOT NULL constraint failed') !== false
) { ) {
return new Exception\NotNullConstraintViolationException($message, $exception); return new Exception\NotNullConstraintViolationException($message, $exception);
......
...@@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\Connection; ...@@ -6,6 +6,7 @@ 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 function assert; use function assert;
use function db2_autocommit; use function db2_autocommit;
use function db2_commit; use function db2_commit;
...@@ -23,6 +24,7 @@ use function db2_server_info; ...@@ -23,6 +24,7 @@ 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_OFF;
use const DB2_AUTOCOMMIT_ON; use const DB2_AUTOCOMMIT_ON;
......
...@@ -12,6 +12,7 @@ use ReflectionClass; ...@@ -12,6 +12,7 @@ use ReflectionClass;
use ReflectionObject; use ReflectionObject;
use ReflectionProperty; use ReflectionProperty;
use stdClass; use stdClass;
use function array_change_key_case; use function array_change_key_case;
use function assert; use function assert;
use function db2_bind_param; use function db2_bind_param;
...@@ -41,6 +42,7 @@ use function stream_copy_to_stream; ...@@ -41,6 +42,7 @@ 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 CASE_LOWER;
use const DB2_BINARY; use const DB2_BINARY;
use const DB2_CHAR; use const DB2_CHAR;
...@@ -138,7 +140,7 @@ class DB2Statement implements IteratorAggregate, Statement ...@@ -138,7 +140,7 @@ class DB2Statement implements IteratorAggregate, Statement
* *
* @throws DB2Exception * @throws DB2Exception
*/ */
private function bind($position, &$variable, int $parameterType, int $dataType) : void private function bind($position, &$variable, int $parameterType, int $dataType): void
{ {
$this->bindParam[$position] =& $variable; $this->bindParam[$position] =& $variable;
...@@ -443,7 +445,7 @@ class DB2Statement implements IteratorAggregate, Statement ...@@ -443,7 +445,7 @@ class DB2Statement implements IteratorAggregate, Statement
* *
* @throws DB2Exception * @throws DB2Exception
*/ */
private function copyStreamToStream($source, $target) : void private function copyStreamToStream($source, $target): void
{ {
if (@stream_copy_to_stream($source, $target) === false) { if (@stream_copy_to_stream($source, $target) === false) {
throw new DB2Exception('Could not copy source stream to temporary file: ' . error_get_last()['message']); throw new DB2Exception('Could not copy source stream to temporary file: ' . error_get_last()['message']);
...@@ -455,7 +457,7 @@ class DB2Statement implements IteratorAggregate, Statement ...@@ -455,7 +457,7 @@ class DB2Statement implements IteratorAggregate, Statement
* *
* @throws DB2Exception * @throws DB2Exception
*/ */
private function writeStringToStream(string $string, $target) : void private function writeStringToStream(string $string, $target): void
{ {
if (@fwrite($target, $string) === false) { if (@fwrite($target, $string) === false) {
throw new DB2Exception('Could not write string to temporary file: ' . error_get_last()['message']); throw new DB2Exception('Could not write string to temporary file: ' . error_get_last()['message']);
......
...@@ -21,7 +21,7 @@ final class DataSourceName ...@@ -21,7 +21,7 @@ final class DataSourceName
$this->string = $string; $this->string = $string;
} }
public function toString() : string public function toString(): string
{ {
return $this->string; return $this->string;
} }
...@@ -31,7 +31,7 @@ final class DataSourceName ...@@ -31,7 +31,7 @@ final class DataSourceName
* *
* @param array<string,mixed> $params * @param array<string,mixed> $params
*/ */
public static function fromArray(array $params) : self public static function fromArray(array $params): self
{ {
$chunks = []; $chunks = [];
...@@ -47,7 +47,7 @@ final class DataSourceName ...@@ -47,7 +47,7 @@ final class DataSourceName
* *
* @param array<string,mixed> $params * @param array<string,mixed> $params
*/ */
public static function fromConnectionParameters(array $params) : self public static function fromConnectionParameters(array $params): self
{ {
if (isset($params['dbname']) && strpos($params['dbname'], '=') !== false) { if (isset($params['dbname']) && strpos($params['dbname'], '=') !== false) {
return new self($params['dbname']); return new self($params['dbname']);
...@@ -55,14 +55,16 @@ final class DataSourceName ...@@ -55,14 +55,16 @@ final class DataSourceName
$dsnParams = []; $dsnParams = [];
foreach ([ foreach (
'host' => 'HOSTNAME', [
'port' => 'PORT', 'host' => 'HOSTNAME',
'protocol' => 'PROTOCOL', 'port' => 'PORT',
'dbname' => 'DATABASE', 'protocol' => 'PROTOCOL',
'user' => 'UID', 'dbname' => 'DATABASE',
'password' => 'PWD', 'user' => 'UID',
] as $dbalParam => $dsnParam) { 'password' => 'PWD',
] as $dbalParam => $dsnParam
) {
if (! isset($params[$dbalParam])) { if (! isset($params[$dbalParam])) {
continue; continue;
} }
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\PingableConnection; ...@@ -7,6 +7,7 @@ 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 function defined; use function defined;
use function floor; use function floor;
use function func_get_args; use function func_get_args;
...@@ -20,6 +21,7 @@ use function restore_error_handler; ...@@ -20,6 +21,7 @@ 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_INIT_COMMAND;
use const MYSQLI_OPT_CONNECT_TIMEOUT; use const MYSQLI_OPT_CONNECT_TIMEOUT;
use const MYSQLI_OPT_LOCAL_INFILE; use const MYSQLI_OPT_LOCAL_INFILE;
...@@ -226,7 +228,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar ...@@ -226,7 +228,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
* @throws MysqliException When one of of the options is not supported. * @throws MysqliException When one of of the options is not supported.
* @throws MysqliException When applying doesn't work - e.g. due to incorrect value. * @throws MysqliException When applying doesn't work - e.g. due to incorrect value.
*/ */
private function setDriverOptions(array $driverOptions = []) : void private function setDriverOptions(array $driverOptions = []): void
{ {
$supportedDriverOptions = [ $supportedDriverOptions = [
MYSQLI_OPT_CONNECT_TIMEOUT, MYSQLI_OPT_CONNECT_TIMEOUT,
...@@ -285,9 +287,10 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar ...@@ -285,9 +287,10 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
* *
* @throws MysqliException * @throws MysqliException
*/ */
private function setSecureConnection(array $params) : void private function setSecureConnection(array $params): void
{ {
if (! isset($params['ssl_key']) && if (
! isset($params['ssl_key']) &&
! isset($params['ssl_cert']) && ! isset($params['ssl_cert']) &&
! isset($params['ssl_ca']) && ! isset($params['ssl_ca']) &&
! isset($params['ssl_capath']) && ! isset($params['ssl_capath']) &&
......
...@@ -11,6 +11,7 @@ use IteratorAggregate; ...@@ -11,6 +11,7 @@ use IteratorAggregate;
use mysqli; use mysqli;
use mysqli_stmt; use mysqli_stmt;
use PDO; use PDO;
use function array_combine; use function array_combine;
use function array_fill; use function array_fill;
use function assert; use function assert;
...@@ -207,7 +208,7 @@ class MysqliStatement implements IteratorAggregate, Statement ...@@ -207,7 +208,7 @@ class MysqliStatement implements IteratorAggregate, Statement
/** /**
* Binds parameters with known types previously bound to the statement * Binds parameters with known types previously bound to the statement
*/ */
private function bindTypedParameters() : void private function bindTypedParameters(): void
{ {
$streams = $values = []; $streams = $values = [];
$types = $this->types; $types = $this->types;
...@@ -250,7 +251,7 @@ class MysqliStatement implements IteratorAggregate, Statement ...@@ -250,7 +251,7 @@ class MysqliStatement implements IteratorAggregate, Statement
* *
* @throws MysqliException * @throws MysqliException
*/ */
private function sendLongData(array $streams) : void private function sendLongData(array $streams): void
{ {
foreach ($streams as $paramNr => $stream) { foreach ($streams as $paramNr => $stream) {
while (! feof($stream)) { while (! feof($stream)) {
......
...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Driver\OCI8; ...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Driver\OCI8;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\AbstractOracleDriver; use Doctrine\DBAL\Driver\AbstractOracleDriver;
use const OCI_NO_AUTO_COMMIT; use const OCI_NO_AUTO_COMMIT;
/** /**
......
...@@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\Connection; ...@@ -6,6 +6,7 @@ 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 function addcslashes; use function addcslashes;
use function func_get_args; use function func_get_args;
use function is_float; use function is_float;
...@@ -19,6 +20,7 @@ use function oci_server_version; ...@@ -19,6 +20,7 @@ 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_COMMIT_ON_SUCCESS;
use const OCI_NO_AUTO_COMMIT; use const OCI_NO_AUTO_COMMIT;
......
...@@ -9,6 +9,7 @@ use Doctrine\DBAL\ParameterType; ...@@ -9,6 +9,7 @@ use Doctrine\DBAL\ParameterType;
use InvalidArgumentException; use InvalidArgumentException;
use IteratorAggregate; use IteratorAggregate;
use PDO; use PDO;
use function array_key_exists; use function array_key_exists;
use function assert; use function assert;
use function count; use function count;
...@@ -30,6 +31,7 @@ use function preg_match; ...@@ -30,6 +31,7 @@ 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_ASSOC;
use const OCI_B_BIN; use const OCI_B_BIN;
use const OCI_B_BLOB; use const OCI_B_BLOB;
...@@ -311,7 +313,7 @@ class OCI8Statement implements IteratorAggregate, Statement ...@@ -311,7 +313,7 @@ class OCI8Statement implements IteratorAggregate, Statement
/** /**
* Converts DBAL parameter type to oci8 parameter type * Converts DBAL parameter type to oci8 parameter type
*/ */
private function convertParameterType(int $type) : int private function convertParameterType(int $type): int
{ {
switch ($type) { switch ($type) {
case ParameterType::BINARY: case ParameterType::BINARY:
......
...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Driver; ...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Driver;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use PDO; use PDO;
use function assert; use function assert;
use function func_get_args; use function func_get_args;
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver; ...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\Driver\PDOConnection;
use PDO; use PDO;
use PDOException; use PDOException;
use function defined; use function defined;
/** /**
...@@ -27,7 +28,8 @@ class Driver extends AbstractPostgreSQLDriver ...@@ -27,7 +28,8 @@ class Driver extends AbstractPostgreSQLDriver
$driverOptions $driverOptions
); );
if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES') if (
defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')
&& (! isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES]) && (! isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES])
|| $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES] === true || $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES] === true
) )
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\AbstractSQLiteDriver; ...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\AbstractSQLiteDriver;
use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Platforms\SqlitePlatform;
use PDOException; use PDOException;
use function array_merge; use function array_merge;
/** /**
......
...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; ...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv;
use Doctrine\DBAL\Driver\AbstractSQLServerDriver; use Doctrine\DBAL\Driver\AbstractSQLServerDriver;
use Doctrine\DBAL\Driver\AbstractSQLServerDriver\PortWithoutHost; use Doctrine\DBAL\Driver\AbstractSQLServerDriver\PortWithoutHost;
use function is_int; use function is_int;
use function sprintf; use function sprintf;
...@@ -73,7 +74,7 @@ class Driver extends AbstractSQLServerDriver ...@@ -73,7 +74,7 @@ class Driver extends AbstractSQLServerDriver
* *
* @param string[] $connectionOptions * @param string[] $connectionOptions
*/ */
private function getConnectionOptionsDsn(array $connectionOptions) : string private function getConnectionOptionsDsn(array $connectionOptions): string
{ {
$connectionOptionsDsn = ''; $connectionOptionsDsn = '';
......
...@@ -16,7 +16,8 @@ class Statement extends PDOStatement ...@@ -16,7 +16,8 @@ class Statement extends PDOStatement
*/ */
public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null, $driverOptions = null) public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null, $driverOptions = null)
{ {
if (($type === ParameterType::LARGE_OBJECT || $type === ParameterType::BINARY) if (
($type === ParameterType::LARGE_OBJECT || $type === ParameterType::BINARY)
&& $driverOptions === null && $driverOptions === null
) { ) {
$driverOptions = PDO::SQLSRV_ENCODING_BINARY; $driverOptions = PDO::SQLSRV_ENCODING_BINARY;
......
...@@ -5,12 +5,14 @@ namespace Doctrine\DBAL\Driver; ...@@ -5,12 +5,14 @@ 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 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; use const E_USER_DEPRECATED;
/** /**
...@@ -196,7 +198,7 @@ class PDOStatement extends \PDOStatement implements Statement ...@@ -196,7 +198,7 @@ class PDOStatement extends \PDOStatement implements Statement
* *
* @param int $type Parameter type * @param int $type Parameter type
*/ */
private function convertParamType(int $type) : int private function convertParamType(int $type): int
{ {
if (! isset(self::PARAM_TYPE_MAP[$type])) { if (! isset(self::PARAM_TYPE_MAP[$type])) {
// TODO: next major: throw an exception // TODO: next major: throw an exception
...@@ -216,7 +218,7 @@ class PDOStatement extends \PDOStatement implements Statement ...@@ -216,7 +218,7 @@ class PDOStatement extends \PDOStatement implements Statement
* *
* @param int $fetchMode Fetch mode * @param int $fetchMode Fetch mode
*/ */
private function convertFetchMode(int $fetchMode) : int private function convertFetchMode(int $fetchMode): int
{ {
if (! isset(self::FETCH_MODE_MAP[$fetchMode])) { if (! isset(self::FETCH_MODE_MAP[$fetchMode])) {
// TODO: next major: throw an exception // TODO: next major: throw an exception
......
...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere; ...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver; use Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver;
use function array_keys; use function array_keys;
use function array_map; use function array_map;
use function implode; use function implode;
......
...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere; ...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere;
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 function assert; use function assert;
use function func_get_args; use function func_get_args;
use function is_float; use function is_float;
......
...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere; ...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere;
use Doctrine\DBAL\Driver\AbstractDriverException; use Doctrine\DBAL\Driver\AbstractDriverException;
use InvalidArgumentException; use InvalidArgumentException;
use function sasql_error; use function sasql_error;
use function sasql_errorcode; use function sasql_errorcode;
use function sasql_sqlstate; use function sasql_sqlstate;
......
...@@ -11,6 +11,7 @@ use PDO; ...@@ -11,6 +11,7 @@ use PDO;
use ReflectionClass; use ReflectionClass;
use ReflectionObject; use ReflectionObject;
use stdClass; use stdClass;
use function array_key_exists; use function array_key_exists;
use function assert; use function assert;
use function func_get_args; use function func_get_args;
...@@ -35,6 +36,7 @@ use function sasql_stmt_field_count; ...@@ -35,6 +36,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; use const SASQL_BOTH;
/** /**
......
...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Driver\SQLSrv; ...@@ -5,6 +5,7 @@ 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 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;
...@@ -19,6 +20,7 @@ use function sqlsrv_rollback; ...@@ -19,6 +20,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; use const SQLSRV_ERR_ERRORS;
/** /**
......
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
namespace Doctrine\DBAL\Driver\SQLSrv; namespace Doctrine\DBAL\Driver\SQLSrv;
use Doctrine\DBAL\Driver\AbstractDriverException; use Doctrine\DBAL\Driver\AbstractDriverException;
use function rtrim; use function rtrim;
use function sqlsrv_errors; use function sqlsrv_errors;
use const SQLSRV_ERR_ERRORS; use const SQLSRV_ERR_ERRORS;
/** /**
......
...@@ -8,6 +8,7 @@ use Doctrine\DBAL\FetchMode; ...@@ -8,6 +8,7 @@ use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use IteratorAggregate; use IteratorAggregate;
use PDO; use PDO;
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;
...@@ -28,6 +29,7 @@ use function sqlsrv_prepare; ...@@ -28,6 +29,7 @@ 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_ENC_BINARY;
use const SQLSRV_ERR_ERRORS; use const SQLSRV_ERR_ERRORS;
use const SQLSRV_FETCH_ASSOC; use const SQLSRV_FETCH_ASSOC;
......
...@@ -15,6 +15,7 @@ use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSrvDriver; ...@@ -15,6 +15,7 @@ use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSrvDriver;
use Doctrine\DBAL\Driver\SQLAnywhere\Driver as SQLAnywhereDriver; use Doctrine\DBAL\Driver\SQLAnywhere\Driver as SQLAnywhereDriver;
use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver;
use PDO; use PDO;
use function array_keys; use function array_keys;
use function array_map; use function array_map;
use function array_merge; use function array_merge;
...@@ -129,7 +130,7 @@ final class DriverManager ...@@ -129,7 +130,7 @@ final class DriverManager
array $params, array $params,
?Configuration $config = null, ?Configuration $config = null,
?EventManager $eventManager = null ?EventManager $eventManager = null
) : Connection { ): Connection {
// create default config and event manager, if not set // create default config and event manager, if not set
if (! $config) { if (! $config) {
$config = new Configuration(); $config = new Configuration();
...@@ -196,7 +197,7 @@ final class DriverManager ...@@ -196,7 +197,7 @@ final class DriverManager
* *
* @return string[] * @return string[]
*/ */
public static function getAvailableDrivers() : array public static function getAvailableDrivers(): array
{ {
return array_keys(self::$_driverMap); return array_keys(self::$_driverMap);
} }
...@@ -208,7 +209,7 @@ final class DriverManager ...@@ -208,7 +209,7 @@ final class DriverManager
* *
* @throws DBALException * @throws DBALException
*/ */
private static function _checkParams(array $params) : void private static function _checkParams(array $params): void
{ {
// check existence of mandatory parameters // check existence of mandatory parameters
...@@ -234,7 +235,7 @@ final class DriverManager ...@@ -234,7 +235,7 @@ final class DriverManager
* *
* @return string The normalized connection URL path * @return string The normalized connection URL path
*/ */
private static function normalizeDatabaseUrlPath(string $urlPath) : string private static function normalizeDatabaseUrlPath(string $urlPath): string
{ {
// Trim leading slash from URL path. // Trim leading slash from URL path.
return substr($urlPath, 1); return substr($urlPath, 1);
...@@ -251,7 +252,7 @@ final class DriverManager ...@@ -251,7 +252,7 @@ final class DriverManager
* *
* @throws DBALException * @throws DBALException
*/ */
private static function parseDatabaseUrl(array $params) : array private static function parseDatabaseUrl(array $params): array
{ {
if (! isset($params['url'])) { if (! isset($params['url'])) {
return $params; return $params;
...@@ -310,7 +311,7 @@ final class DriverManager ...@@ -310,7 +311,7 @@ final class DriverManager
* *
* @return mixed[] The resolved connection parameters. * @return mixed[] The resolved connection parameters.
*/ */
private static function parseDatabaseUrlPath(array $url, array $params) : array private static function parseDatabaseUrlPath(array $url, array $params): array
{ {
if (! isset($url['path'])) { if (! isset($url['path'])) {
return $params; return $params;
...@@ -339,7 +340,7 @@ final class DriverManager ...@@ -339,7 +340,7 @@ final class DriverManager
* *
* @return mixed[] The resolved connection parameters. * @return mixed[] The resolved connection parameters.
*/ */
private static function parseDatabaseUrlQuery(array $url, array $params) : array private static function parseDatabaseUrlQuery(array $url, array $params): array
{ {
if (! isset($url['query'])) { if (! isset($url['query'])) {
return $params; return $params;
...@@ -364,7 +365,7 @@ final class DriverManager ...@@ -364,7 +365,7 @@ final class DriverManager
* *
* @return mixed[] The resolved connection parameters. * @return mixed[] The resolved connection parameters.
*/ */
private static function parseRegularDatabaseUrlPath(array $url, array $params) : array private static function parseRegularDatabaseUrlPath(array $url, array $params): array
{ {
$params['dbname'] = $url['path']; $params['dbname'] = $url['path'];
...@@ -383,7 +384,7 @@ final class DriverManager ...@@ -383,7 +384,7 @@ final class DriverManager
* *
* @return mixed[] The resolved connection parameters. * @return mixed[] The resolved connection parameters.
*/ */
private static function parseSqliteDatabaseUrlPath(array $url, array $params) : array private static function parseSqliteDatabaseUrlPath(array $url, array $params): array
{ {
if ($url['path'] === ':memory:') { if ($url['path'] === ':memory:') {
$params['memory'] = true; $params['memory'] = true;
...@@ -406,7 +407,7 @@ final class DriverManager ...@@ -406,7 +407,7 @@ final class DriverManager
* *
* @throws DBALException If parsing failed or resolution is not possible. * @throws DBALException If parsing failed or resolution is not possible.
*/ */
private static function parseDatabaseUrlScheme(array $url, array $params) : array private static function parseDatabaseUrlScheme(array $url, array $params): array
{ {
if (isset($url['scheme'])) { if (isset($url['scheme'])) {
// The requested driver from the URL scheme takes precedence // The requested driver from the URL scheme takes precedence
......
...@@ -5,10 +5,12 @@ namespace Doctrine\DBAL\Event\Listeners; ...@@ -5,10 +5,12 @@ 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 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; use const CASE_UPPER;
/** /**
......
...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Event; ...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use function array_merge; use function array_merge;
use function func_get_args; use function func_get_args;
use function is_array; use function is_array;
......
...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Event; ...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use function array_merge; use function array_merge;
use function func_get_args; use function func_get_args;
use function is_array; use function is_array;
......
...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Event; ...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use function array_merge; use function array_merge;
use function func_get_args; use function func_get_args;
use function is_array; use function is_array;
......
...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Event; ...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use function array_merge; use function array_merge;
use function func_get_args; use function func_get_args;
use function is_array; use function is_array;
......
...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Event; ...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use function array_merge; use function array_merge;
use function func_get_args; use function func_get_args;
use function is_array; use function is_array;
......
...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Event; ...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use function array_merge; use function array_merge;
use function func_get_args; use function func_get_args;
use function is_array; use function is_array;
......
...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Event; ...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use function array_merge; use function array_merge;
use function func_get_args; use function func_get_args;
use function is_array; use function is_array;
......
...@@ -8,9 +8,11 @@ use Doctrine\DBAL\DriverManager; ...@@ -8,9 +8,11 @@ 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 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; use const CASE_LOWER;
/** /**
......
...@@ -35,7 +35,7 @@ final class DependencyOrderCalculator ...@@ -35,7 +35,7 @@ final class DependencyOrderCalculator
/** /**
* Checks for node (vertex) existence in graph. * Checks for node (vertex) existence in graph.
*/ */
public function hasNode(string $hash) : bool public function hasNode(string $hash): bool
{ {
return isset($this->nodeList[$hash]); return isset($this->nodeList[$hash]);
} }
...@@ -45,7 +45,7 @@ final class DependencyOrderCalculator ...@@ -45,7 +45,7 @@ final class DependencyOrderCalculator
* *
* @param object $node * @param object $node
*/ */
public function addNode(string $hash, $node) : void public function addNode(string $hash, $node): void
{ {
$vertex = new DependencyOrderNode(); $vertex = new DependencyOrderNode();
...@@ -59,7 +59,7 @@ final class DependencyOrderCalculator ...@@ -59,7 +59,7 @@ final class DependencyOrderCalculator
/** /**
* Adds a new dependency (edge) to the graph using their hashes. * Adds a new dependency (edge) to the graph using their hashes.
*/ */
public function addDependency(string $fromHash, string $toHash) : void public function addDependency(string $fromHash, string $toHash): void
{ {
$vertex = $this->nodeList[$fromHash]; $vertex = $this->nodeList[$fromHash];
$edge = new DependencyOrderEdge(); $edge = new DependencyOrderEdge();
...@@ -78,7 +78,7 @@ final class DependencyOrderCalculator ...@@ -78,7 +78,7 @@ final class DependencyOrderCalculator
* *
* @return array<object> * @return array<object>
*/ */
public function sort() : array public function sort(): array
{ {
foreach ($this->nodeList as $vertex) { foreach ($this->nodeList as $vertex) {
if ($vertex->state !== self::NOT_VISITED) { if ($vertex->state !== self::NOT_VISITED) {
...@@ -101,7 +101,7 @@ final class DependencyOrderCalculator ...@@ -101,7 +101,7 @@ final class DependencyOrderCalculator
* *
* {@internal Highly performance-sensitive method.} * {@internal Highly performance-sensitive method.}
*/ */
private function visit(DependencyOrderNode $vertex) : void private function visit(DependencyOrderNode $vertex): void
{ {
$vertex->state = self::IN_PROGRESS; $vertex->state = self::IN_PROGRESS;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Logging; namespace Doctrine\DBAL\Logging;
use function var_dump; use function var_dump;
use const PHP_EOL; use const PHP_EOL;
/** /**
......
...@@ -28,6 +28,7 @@ use Doctrine\DBAL\Types; ...@@ -28,6 +28,7 @@ use Doctrine\DBAL\Types;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use InvalidArgumentException; use InvalidArgumentException;
use UnexpectedValueException; use UnexpectedValueException;
use function addcslashes; use function addcslashes;
use function array_map; use function array_map;
use function array_merge; use function array_merge;
...@@ -54,6 +55,7 @@ use function strpos; ...@@ -54,6 +55,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; use const E_USER_DEPRECATED;
/** /**
...@@ -574,7 +576,7 @@ abstract class AbstractPlatform ...@@ -574,7 +576,7 @@ abstract class AbstractPlatform
/** /**
* Gets the maximum length of a char field. * Gets the maximum length of a char field.
*/ */
public function getCharMaxLength() : int public function getCharMaxLength(): int
{ {
return $this->getVarcharMaxLength(); return $this->getVarcharMaxLength();
} }
...@@ -1550,7 +1552,7 @@ abstract class AbstractPlatform ...@@ -1550,7 +1552,7 @@ abstract class AbstractPlatform
$options['indexes'] = []; $options['indexes'] = [];
$options['primary'] = []; $options['primary'] = [];
if (($createFlags&self::CREATE_INDEXES) > 0) { if (($createFlags & self::CREATE_INDEXES) > 0) {
foreach ($table->getIndexes() as $index) { foreach ($table->getIndexes() as $index) {
if ($index->isPrimary()) { if ($index->isPrimary()) {
$options['primary'] = $index->getQuotedColumns($this); $options['primary'] = $index->getQuotedColumns($this);
...@@ -1592,7 +1594,7 @@ abstract class AbstractPlatform ...@@ -1592,7 +1594,7 @@ abstract class AbstractPlatform
$columns[$columnData['name']] = $columnData; $columns[$columnData['name']] = $columnData;
} }
if (($createFlags&self::CREATE_FOREIGNKEYS) > 0) { if (($createFlags & self::CREATE_FOREIGNKEYS) > 0) {
$options['foreignKeys'] = []; $options['foreignKeys'] = [];
foreach ($table->getForeignKeys() as $fkConstraint) { foreach ($table->getForeignKeys() as $fkConstraint) {
$options['foreignKeys'][] = $fkConstraint; $options['foreignKeys'][] = $fkConstraint;
...@@ -1628,7 +1630,7 @@ abstract class AbstractPlatform ...@@ -1628,7 +1630,7 @@ abstract class AbstractPlatform
return array_merge($sql, $columnSql); return array_merge($sql, $columnSql);
} }
protected function getCommentOnTableSQL(string $tableName, ?string $comment) : string protected function getCommentOnTableSQL(string $tableName, ?string $comment): string
{ {
$tableName = new Identifier($tableName); $tableName = new Identifier($tableName);
...@@ -2437,7 +2439,7 @@ abstract class AbstractPlatform ...@@ -2437,7 +2439,7 @@ abstract class AbstractPlatform
* *
* @param mixed[]|Index $columnsOrIndex array declaration is deprecated, prefer passing Index to this method * @param mixed[]|Index $columnsOrIndex array declaration is deprecated, prefer passing Index to this method
*/ */
public function getIndexFieldDeclarationListSQL($columnsOrIndex) : string public function getIndexFieldDeclarationListSQL($columnsOrIndex): string
{ {
if ($columnsOrIndex instanceof Index) { if ($columnsOrIndex instanceof Index) {
return implode(', ', $columnsOrIndex->getQuotedColumns($this)); return implode(', ', $columnsOrIndex->getQuotedColumns($this));
...@@ -2692,7 +2694,7 @@ abstract class AbstractPlatform ...@@ -2692,7 +2694,7 @@ abstract class AbstractPlatform
*/ */
public function convertFromBoolean($item) public function convertFromBoolean($item)
{ {
return $item === null ? null: (bool) $item; return $item === null ? null : (bool) $item;
} }
/** /**
...@@ -3133,7 +3135,7 @@ abstract class AbstractPlatform ...@@ -3133,7 +3135,7 @@ abstract class AbstractPlatform
/** /**
* Whether the platform supports indexes with column length definitions. * Whether the platform supports indexes with column length definitions.
*/ */
public function supportsColumnLengthIndexes() : bool public function supportsColumnLengthIndexes(): bool
{ {
return false; return false;
} }
...@@ -3203,7 +3205,7 @@ abstract class AbstractPlatform ...@@ -3203,7 +3205,7 @@ abstract class AbstractPlatform
* *
* If false, then getDropForeignKeySQL() throws exception. * If false, then getDropForeignKeySQL() throws exception.
*/ */
public function supportsCreateDropForeignKeyConstraints() : bool public function supportsCreateDropForeignKeyConstraints(): bool
{ {
return true; return true;
} }
...@@ -3646,7 +3648,7 @@ abstract class AbstractPlatform ...@@ -3646,7 +3648,7 @@ abstract class AbstractPlatform
* @param string $escapeChar should be reused by the caller in the LIKE * @param string $escapeChar should be reused by the caller in the LIKE
* expression. * expression.
*/ */
final public function escapeStringForLike(string $inputString, string $escapeChar) : string final public function escapeStringForLike(string $inputString, string $escapeChar): string
{ {
return preg_replace( return preg_replace(
'~([' . preg_quote($this->getLikeWildcardCharacters() . $escapeChar, '~') . '])~u', '~([' . preg_quote($this->getLikeWildcardCharacters() . $escapeChar, '~') . '])~u',
...@@ -3655,7 +3657,7 @@ abstract class AbstractPlatform ...@@ -3655,7 +3657,7 @@ abstract class AbstractPlatform
); );
} }
protected function getLikeWildcardCharacters() : string protected function getLikeWildcardCharacters(): string
{ {
return '%_'; return '%_';
} }
......
...@@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\Index; ...@@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use function array_merge; use function array_merge;
use function count; use function count;
use function current; use function current;
...@@ -22,7 +23,7 @@ use function strtoupper; ...@@ -22,7 +23,7 @@ use function strtoupper;
class DB2Platform extends AbstractPlatform class DB2Platform extends AbstractPlatform
{ {
public function getCharMaxLength() : int public function getCharMaxLength(): int
{ {
return 254; return 254;
} }
...@@ -523,7 +524,8 @@ class DB2Platform extends AbstractPlatform ...@@ -523,7 +524,8 @@ class DB2Platform extends AbstractPlatform
$queryPart = 'ADD COLUMN ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnDef); $queryPart = 'ADD COLUMN ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnDef);
// Adding non-nullable columns to a table requires a default value to be specified. // Adding non-nullable columns to a table requires a default value to be specified.
if (! empty($columnDef['notnull']) && if (
! empty($columnDef['notnull']) &&
! isset($columnDef['default']) && ! isset($columnDef['default']) &&
empty($columnDef['autoincrement']) empty($columnDef['autoincrement'])
) { ) {
...@@ -626,7 +628,7 @@ class DB2Platform extends AbstractPlatform ...@@ -626,7 +628,7 @@ class DB2Platform extends AbstractPlatform
* @param string[] $sql The sequence of table alteration statements to fill. * @param string[] $sql The sequence of table alteration statements to fill.
* @param mixed[] $queryParts The sequence of column alteration clauses to fill. * @param mixed[] $queryParts The sequence of column alteration clauses to fill.
*/ */
private function gatherAlterColumnSQL(Identifier $table, ColumnDiff $columnDiff, array &$sql, array &$queryParts) : void private function gatherAlterColumnSQL(Identifier $table, ColumnDiff $columnDiff, array &$sql, array &$queryParts): void
{ {
$alterColumnClauses = $this->getAlterColumnClausesSQL($columnDiff); $alterColumnClauses = $this->getAlterColumnClausesSQL($columnDiff);
...@@ -668,7 +670,8 @@ class DB2Platform extends AbstractPlatform ...@@ -668,7 +670,8 @@ class DB2Platform extends AbstractPlatform
$clauses = []; $clauses = [];
if ($columnDiff->hasChanged('type') || if (
$columnDiff->hasChanged('type') ||
$columnDiff->hasChanged('length') || $columnDiff->hasChanged('length') ||
$columnDiff->hasChanged('precision') || $columnDiff->hasChanged('precision') ||
$columnDiff->hasChanged('scale') || $columnDiff->hasChanged('scale') ||
...@@ -901,7 +904,7 @@ class DB2Platform extends AbstractPlatform ...@@ -901,7 +904,7 @@ class DB2Platform extends AbstractPlatform
return Keywords\DB2Keywords::class; return Keywords\DB2Keywords::class;
} }
public function getListTableCommentsSQL(string $table) : string public function getListTableCommentsSQL(string $table): string
{ {
return sprintf( return sprintf(
<<<'SQL' <<<'SQL'
......
...@@ -8,6 +8,7 @@ use Doctrine\DBAL\Schema\Table; ...@@ -8,6 +8,7 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BinaryType; use Doctrine\DBAL\Types\BinaryType;
use InvalidArgumentException; 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;
...@@ -518,7 +519,8 @@ class DrizzlePlatform extends AbstractPlatform ...@@ -518,7 +519,8 @@ class DrizzlePlatform extends AbstractPlatform
// Do not generate column alteration clause if type is binary and only fixed property has changed. // Do not generate column alteration clause if type is binary and only fixed property has changed.
// Drizzle only supports binary type columns with variable length. // Drizzle only supports binary type columns with variable length.
// Avoids unnecessary table alteration statements. // Avoids unnecessary table alteration statements.
if ($columnArray['type'] instanceof BinaryType && if (
$columnArray['type'] instanceof BinaryType &&
$columnDiff->hasChanged('fixed') && $columnDiff->hasChanged('fixed') &&
count($columnDiff->changedProperties) === 1 count($columnDiff->changedProperties) === 1
) { ) {
......
...@@ -9,7 +9,7 @@ namespace Doctrine\DBAL\Platforms\Keywords; ...@@ -9,7 +9,7 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/ */
final class MariaDb102Keywords extends MySQLKeywords final class MariaDb102Keywords extends MySQLKeywords
{ {
public function getName() : string public function getName(): string
{ {
return 'MariaDb102'; return 'MariaDb102';
} }
...@@ -17,7 +17,7 @@ final class MariaDb102Keywords extends MySQLKeywords ...@@ -17,7 +17,7 @@ final class MariaDb102Keywords extends MySQLKeywords
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getKeywords() : array protected function getKeywords(): array
{ {
return [ return [
'ACCESSIBLE', 'ACCESSIBLE',
......
...@@ -9,7 +9,7 @@ namespace Doctrine\DBAL\Platforms\Keywords; ...@@ -9,7 +9,7 @@ namespace Doctrine\DBAL\Platforms\Keywords;
*/ */
class PostgreSQL100Keywords extends PostgreSQL94Keywords class PostgreSQL100Keywords extends PostgreSQL94Keywords
{ {
public function getName() : string public function getName(): string
{ {
return 'PostgreSQL100'; return 'PostgreSQL100';
} }
......
...@@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\Schema; ...@@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\DBAL\Schema\Visitor\Visitor;
use function implode; use function implode;
use function str_replace; use function str_replace;
......
...@@ -16,17 +16,17 @@ final class MariaDb1027Platform extends MySqlPlatform ...@@ -16,17 +16,17 @@ final class MariaDb1027Platform extends MySqlPlatform
* *
* @link https://mariadb.com/kb/en/library/json-data-type/ * @link https://mariadb.com/kb/en/library/json-data-type/
*/ */
public function getJsonTypeDeclarationSQL(array $field) : string public function getJsonTypeDeclarationSQL(array $field): string
{ {
return 'LONGTEXT'; return 'LONGTEXT';
} }
protected function getReservedKeywordsClass() : string protected function getReservedKeywordsClass(): string
{ {
return Keywords\MariaDb102Keywords::class; return Keywords\MariaDb102Keywords::class;
} }
protected function initializeDoctrineTypeMappings() : void protected function initializeDoctrineTypeMappings(): void
{ {
parent::initializeDoctrineTypeMappings(); parent::initializeDoctrineTypeMappings();
......
...@@ -11,6 +11,7 @@ use Doctrine\DBAL\TransactionIsolationLevel; ...@@ -11,6 +11,7 @@ use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\TextType;
use InvalidArgumentException; use InvalidArgumentException;
use function array_diff_key; use function array_diff_key;
use function array_merge; use function array_merge;
use function array_unique; use function array_unique;
...@@ -383,7 +384,7 @@ class MySqlPlatform extends AbstractPlatform ...@@ -383,7 +384,7 @@ class MySqlPlatform extends AbstractPlatform
' ORDER BY ORDINAL_POSITION ASC'; ' ORDER BY ORDINAL_POSITION ASC';
} }
public function getListTableMetadataSQL(string $table, ?string $database = null) : string public function getListTableMetadataSQL(string $table, ?string $database = null): string
{ {
return sprintf( return sprintf(
<<<'SQL' <<<'SQL'
...@@ -587,7 +588,8 @@ SQL ...@@ -587,7 +588,8 @@ SQL
$columnArray = $column->toArray(); $columnArray = $column->toArray();
// Don't propagate default value changes for unsupported column types. // Don't propagate default value changes for unsupported column types.
if ($columnDiff->hasChanged('default') && if (
$columnDiff->hasChanged('default') &&
count($columnDiff->changedProperties) === 1 && count($columnDiff->changedProperties) === 1 &&
($columnArray['type'] instanceof TextType || $columnArray['type'] instanceof BlobType) ($columnArray['type'] instanceof TextType || $columnArray['type'] instanceof BlobType)
) { ) {
...@@ -1184,7 +1186,7 @@ SQL ...@@ -1184,7 +1186,7 @@ SQL
return TransactionIsolationLevel::REPEATABLE_READ; return TransactionIsolationLevel::REPEATABLE_READ;
} }
public function supportsColumnLengthIndexes() : bool public function supportsColumnLengthIndexes(): bool
{ {
return true; return true;
} }
......
...@@ -12,6 +12,7 @@ use Doctrine\DBAL\Schema\TableDiff; ...@@ -12,6 +12,7 @@ use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\BinaryType; use Doctrine\DBAL\Types\BinaryType;
use InvalidArgumentException; use InvalidArgumentException;
use function array_merge; use function array_merge;
use function count; use function count;
use function explode; use function explode;
...@@ -394,8 +395,10 @@ class OraclePlatform extends AbstractPlatform ...@@ -394,8 +395,10 @@ class OraclePlatform extends AbstractPlatform
$sql[] = $this->getCreateSequenceSQL($column['sequence']); $sql[] = $this->getCreateSequenceSQL($column['sequence']);
} }
if (! isset($column['autoincrement']) || ! $column['autoincrement'] && if (
(! isset($column['autoinc']) || ! $column['autoinc'])) { ! isset($column['autoincrement']) || ! $column['autoincrement'] &&
(! isset($column['autoinc']) || ! $column['autoinc'])
) {
continue; continue;
} }
...@@ -592,7 +595,7 @@ END;'; ...@@ -592,7 +595,7 @@ END;';
* if the new string exceeds max identifier length, * if the new string exceeds max identifier length,
* keeps $suffix, cuts from $identifier as much as the part exceeding. * keeps $suffix, cuts from $identifier as much as the part exceeding.
*/ */
private function addSuffix(string $identifier, string $suffix) : string private function addSuffix(string $identifier, string $suffix): string
{ {
$maxPossibleLengthWithoutSuffix = $this->getMaxIdentifierLength() - strlen($suffix); $maxPossibleLengthWithoutSuffix = $this->getMaxIdentifierLength() - strlen($suffix);
if (strlen($identifier) > $maxPossibleLengthWithoutSuffix) { if (strlen($identifier) > $maxPossibleLengthWithoutSuffix) {
...@@ -830,7 +833,8 @@ SQL ...@@ -830,7 +833,8 @@ SQL
// Do not generate column alteration clause if type is binary and only fixed property has changed. // Do not generate column alteration clause if type is binary and only fixed property has changed.
// Oracle only supports binary type columns with variable length. // Oracle only supports binary type columns with variable length.
// Avoids unnecessary table alteration statements. // Avoids unnecessary table alteration statements.
if ($column->getType() instanceof BinaryType && if (
$column->getType() instanceof BinaryType &&
$columnDiff->hasChanged('fixed') && $columnDiff->hasChanged('fixed') &&
count($columnDiff->changedProperties) === 1 count($columnDiff->changedProperties) === 1
) { ) {
...@@ -1206,7 +1210,7 @@ SQL ...@@ -1206,7 +1210,7 @@ SQL
return 'BLOB'; return 'BLOB';
} }
public function getListTableCommentsSQL(string $table, ?string $database = null) : string public function getListTableCommentsSQL(string $table, ?string $database = null): string
{ {
$tableCommentsName = 'user_tab_comments'; $tableCommentsName = 'user_tab_comments';
$ownerCondition = ''; $ownerCondition = '';
......
...@@ -11,7 +11,7 @@ use Doctrine\DBAL\Platforms\Keywords\PostgreSQL100Keywords; ...@@ -11,7 +11,7 @@ use Doctrine\DBAL\Platforms\Keywords\PostgreSQL100Keywords;
*/ */
class PostgreSQL100Platform extends PostgreSQL94Platform class PostgreSQL100Platform extends PostgreSQL94Platform
{ {
protected function getReservedKeywordsClass() : string protected function getReservedKeywordsClass(): string
{ {
return PostgreSQL100Keywords::class; return PostgreSQL100Keywords::class;
} }
...@@ -19,7 +19,7 @@ class PostgreSQL100Platform extends PostgreSQL94Platform ...@@ -19,7 +19,7 @@ class PostgreSQL100Platform extends PostgreSQL94Platform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getListSequencesSQL($database) : string public function getListSequencesSQL($database): string
{ {
return 'SELECT sequence_name AS relname, return 'SELECT sequence_name AS relname,
sequence_schema AS schemaname, sequence_schema AS schemaname,
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Platforms; namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use function sprintf; use function sprintf;
/** /**
......
...@@ -15,6 +15,7 @@ use Doctrine\DBAL\Types\BlobType; ...@@ -15,6 +15,7 @@ use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\IntegerType; use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use UnexpectedValueException; use UnexpectedValueException;
use function array_diff; use function array_diff;
use function array_merge; use function array_merge;
use function array_unique; use function array_unique;
...@@ -113,7 +114,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -113,7 +114,7 @@ class PostgreSqlPlatform extends AbstractPlatform
if ($startPos !== false) { if ($startPos !== false) {
$str = $this->getSubstringExpression($str, $startPos); $str = $this->getSubstringExpression($str, $startPos);
return 'CASE WHEN (POSITION(' . $substr . ' IN ' . $str . ') = 0) THEN 0 ELSE (POSITION(' . $substr . ' IN ' . $str . ') + ' . ($startPos-1) . ') END'; return 'CASE WHEN (POSITION(' . $substr . ' IN ' . $str . ') = 0) THEN 0 ELSE (POSITION(' . $substr . ' IN ' . $str . ') + ' . ($startPos - 1) . ') END';
} }
return 'POSITION(' . $substr . ' IN ' . $str . ')'; return 'POSITION(' . $substr . ' IN ' . $str . ')';
...@@ -480,7 +481,8 @@ SQL ...@@ -480,7 +481,8 @@ SQL
$query .= ' NOT DEFERRABLE'; $query .= ' NOT DEFERRABLE';
} }
if (($foreignKey->hasOption('feferred') && $foreignKey->getOption('feferred') !== false) if (
($foreignKey->hasOption('feferred') && $foreignKey->getOption('feferred') !== false)
|| ($foreignKey->hasOption('deferred') && $foreignKey->getOption('deferred') !== false) || ($foreignKey->hasOption('deferred') && $foreignKey->getOption('deferred') !== false)
) { ) {
$query .= ' INITIALLY DEFERRED'; $query .= ' INITIALLY DEFERRED';
...@@ -1222,7 +1224,7 @@ SQL ...@@ -1222,7 +1224,7 @@ SQL
/** /**
* @param mixed[] $field * @param mixed[] $field
*/ */
private function isSerialField(array $field) : bool private function isSerialField(array $field): bool
{ {
return isset($field['type'], $field['autoincrement']) return isset($field['type'], $field['autoincrement'])
&& $field['autoincrement'] === true && $field['autoincrement'] === true
...@@ -1232,7 +1234,7 @@ SQL ...@@ -1232,7 +1234,7 @@ SQL
/** /**
* Check whether the type of a column is changed in a way that invalidates the default value for the column * Check whether the type of a column is changed in a way that invalidates the default value for the column
*/ */
private function typeChangeBreaksDefaultValue(ColumnDiff $columnDiff) : bool private function typeChangeBreaksDefaultValue(ColumnDiff $columnDiff): bool
{ {
if (! $columnDiff->fromColumn) { if (! $columnDiff->fromColumn) {
return $columnDiff->hasChanged('type'); return $columnDiff->hasChanged('type');
...@@ -1246,17 +1248,17 @@ SQL ...@@ -1246,17 +1248,17 @@ SQL
&& ! ($oldTypeIsNumeric && $newTypeIsNumeric && $columnDiff->column->getAutoincrement()); && ! ($oldTypeIsNumeric && $newTypeIsNumeric && $columnDiff->column->getAutoincrement());
} }
private function isNumericType(Type $type) : bool private function isNumericType(Type $type): bool
{ {
return $type instanceof IntegerType || $type instanceof BigIntType; return $type instanceof IntegerType || $type instanceof BigIntType;
} }
private function getOldColumnComment(ColumnDiff $columnDiff) : ?string private function getOldColumnComment(ColumnDiff $columnDiff): ?string
{ {
return $columnDiff->fromColumn ? $this->getColumnComment($columnDiff->fromColumn) : null; return $columnDiff->fromColumn ? $this->getColumnComment($columnDiff->fromColumn) : null;
} }
public function getListTableMetadataSQL(string $table, ?string $schema = null) : string public function getListTableMetadataSQL(string $table, ?string $schema = null): string
{ {
if ($schema !== null) { if ($schema !== null) {
$table = $schema . '.' . $table; $table = $schema . '.' . $table;
......
...@@ -14,6 +14,7 @@ use Doctrine\DBAL\Schema\Table; ...@@ -14,6 +14,7 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\TransactionIsolationLevel;
use InvalidArgumentException; 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;
...@@ -1333,7 +1334,7 @@ SQL ...@@ -1333,7 +1334,7 @@ SQL
return $matches[1] . $limitOffsetClause . ' ' . $matches[3]; return $matches[1] . $limitOffsetClause . ' ' . $matches[3];
} }
private function getTopClauseSQL(?int $limit, ?int $offset) : string private function getTopClauseSQL(?int $limit, ?int $offset): string
{ {
if ($offset > 0) { if ($offset > 0) {
return sprintf('TOP %s START AT %d', $limit ?? 'ALL', $offset + 1); return sprintf('TOP %s START AT %d', $limit ?? 'ALL', $offset + 1);
......
...@@ -110,7 +110,7 @@ class SQLServer2008Platform extends SQLServer2005Platform ...@@ -110,7 +110,7 @@ class SQLServer2008Platform extends SQLServer2005Platform
return Keywords\SQLServer2008Keywords::class; return Keywords\SQLServer2008Keywords::class;
} }
protected function getLikeWildcardCharacters() : string protected function getLikeWildcardCharacters(): string
{ {
return parent::getLikeWildcardCharacters() . '[]^'; return parent::getLikeWildcardCharacters() . '[]^';
} }
......
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
namespace Doctrine\DBAL\Platforms; namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Sequence;
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; use const PREG_OFFSET_CAPTURE;
/** /**
...@@ -108,7 +110,8 @@ class SQLServer2012Platform extends SQLServer2008Platform ...@@ -108,7 +110,8 @@ class SQLServer2012Platform extends SQLServer2008Platform
$orderByPos = $matches[0][$matchesCount - 1][1]; $orderByPos = $matches[0][$matchesCount - 1][1];
} }
if ($orderByPos === false if (
$orderByPos === false
|| substr_count($query, '(', $orderByPos) - substr_count($query, ')', $orderByPos) || substr_count($query, '(', $orderByPos) - substr_count($query, ')', $orderByPos)
) { ) {
if (preg_match('/^SELECT\s+DISTINCT/im', $query)) { if (preg_match('/^SELECT\s+DISTINCT/im', $query)) {
......
...@@ -11,6 +11,7 @@ use Doctrine\DBAL\Schema\Index; ...@@ -11,6 +11,7 @@ use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use InvalidArgumentException; 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;
...@@ -1667,7 +1668,7 @@ SQL ...@@ -1667,7 +1668,7 @@ SQL
return strtoupper(dechex(crc32($identifier->getName()))); return strtoupper(dechex(crc32($identifier->getName())));
} }
protected function getCommentOnTableSQL(string $tableName, ?string $comment) : string protected function getCommentOnTableSQL(string $tableName, ?string $comment): string
{ {
return sprintf( return sprintf(
<<<'SQL' <<<'SQL'
...@@ -1681,7 +1682,7 @@ SQL ...@@ -1681,7 +1682,7 @@ SQL
); );
} }
public function getListTableMetadataSQL(string $table) : string public function getListTableMetadataSQL(string $table): string
{ {
return sprintf( return sprintf(
<<<'SQL' <<<'SQL'
......
...@@ -12,6 +12,7 @@ use Doctrine\DBAL\Schema\Table; ...@@ -12,6 +12,7 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types; use Doctrine\DBAL\Types;
use function array_merge; use function array_merge;
use function array_unique; use function array_unique;
use function array_values; use function array_values;
...@@ -376,7 +377,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -376,7 +377,7 @@ class SqlitePlatform extends AbstractPlatform
* @param mixed[][] $columns * @param mixed[][] $columns
* @param mixed[] $options * @param mixed[] $options
*/ */
private function getNonAutoincrementPrimaryKeyDefinition(array $columns, array $options) : string private function getNonAutoincrementPrimaryKeyDefinition(array $columns, array $options): string
{ {
if (empty($options['primary'])) { if (empty($options['primary'])) {
return ''; return '';
...@@ -622,7 +623,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -622,7 +623,7 @@ class SqlitePlatform extends AbstractPlatform
return '--' . str_replace("\n", "\n--", $comment) . "\n"; return '--' . str_replace("\n", "\n--", $comment) . "\n";
} }
private function getInlineTableCommentSQL(string $comment) : string private function getInlineTableCommentSQL(string $comment): string
{ {
return $this->getInlineColumnCommentSQL($comment); return $this->getInlineColumnCommentSQL($comment);
} }
...@@ -776,7 +777,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -776,7 +777,7 @@ class SqlitePlatform extends AbstractPlatform
return true; return true;
} }
public function supportsCreateDropForeignKeyConstraints() : bool public function supportsCreateDropForeignKeyConstraints(): bool
{ {
return false; return false;
} }
...@@ -968,7 +969,8 @@ class SqlitePlatform extends AbstractPlatform ...@@ -968,7 +969,8 @@ class SqlitePlatform extends AbstractPlatform
{ {
// Suppress changes on integer type autoincrement columns. // Suppress changes on integer type autoincrement columns.
foreach ($diff->changedColumns as $oldColumnName => $columnDiff) { foreach ($diff->changedColumns as $oldColumnName => $columnDiff) {
if (! $columnDiff->fromColumn instanceof Column || if (
! $columnDiff->fromColumn instanceof Column ||
! $columnDiff->column instanceof Column || ! $columnDiff->column instanceof Column ||
! $columnDiff->column->getAutoincrement() || ! $columnDiff->column->getAutoincrement() ||
! $columnDiff->column->getType() instanceof Types\IntegerType ! $columnDiff->column->getType() instanceof Types\IntegerType
...@@ -991,7 +993,8 @@ class SqlitePlatform extends AbstractPlatform ...@@ -991,7 +993,8 @@ class SqlitePlatform extends AbstractPlatform
unset($diff->changedColumns[$oldColumnName]); unset($diff->changedColumns[$oldColumnName]);
} }
if (! empty($diff->renamedColumns) || ! empty($diff->addedForeignKeys) || ! empty($diff->addedIndexes) if (
! empty($diff->renamedColumns) || ! empty($diff->addedForeignKeys) || ! empty($diff->addedIndexes)
|| ! empty($diff->changedColumns) || ! empty($diff->changedForeignKeys) || ! empty($diff->changedIndexes) || ! empty($diff->changedColumns) || ! empty($diff->changedForeignKeys) || ! empty($diff->changedIndexes)
|| ! empty($diff->removedColumns) || ! empty($diff->removedForeignKeys) || ! empty($diff->removedIndexes) || ! empty($diff->removedColumns) || ! empty($diff->removedForeignKeys) || ! empty($diff->removedIndexes)
|| ! empty($diff->renamedIndexes) || ! empty($diff->renamedIndexes)
......
...@@ -6,7 +6,9 @@ use Doctrine\DBAL\Cache\QueryCacheProfile; ...@@ -6,7 +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 function func_get_args;
use const CASE_LOWER; use const CASE_LOWER;
use const CASE_UPPER; use const CASE_UPPER;
......
...@@ -9,6 +9,7 @@ use Doctrine\DBAL\FetchMode; ...@@ -9,6 +9,7 @@ use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use IteratorAggregate; use IteratorAggregate;
use PDO; use PDO;
use function array_change_key_case; use function array_change_key_case;
use function assert; use function assert;
use function is_string; use function is_string;
...@@ -136,7 +137,7 @@ class Statement implements IteratorAggregate, DriverStatement ...@@ -136,7 +137,7 @@ class Statement implements IteratorAggregate, DriverStatement
$row = $this->stmt->fetch($fetchMode); $row = $this->stmt->fetch($fetchMode);
$iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM); $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL | Connection::PORTABILITY_RTRIM);
$fixCase = $this->case !== null $fixCase = $this->case !== null
&& ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED) && ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED)
&& ($this->portability & Connection::PORTABILITY_FIX_CASE); && ($this->portability & Connection::PORTABILITY_FIX_CASE);
...@@ -159,7 +160,7 @@ class Statement implements IteratorAggregate, DriverStatement ...@@ -159,7 +160,7 @@ class Statement implements IteratorAggregate, DriverStatement
$rows = $this->stmt->fetchAll($fetchMode); $rows = $this->stmt->fetchAll($fetchMode);
} }
$iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM); $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL | Connection::PORTABILITY_RTRIM);
$fixCase = $this->case !== null $fixCase = $this->case !== null
&& ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED) && ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED)
&& ($this->portability & Connection::PORTABILITY_FIX_CASE); && ($this->portability & Connection::PORTABILITY_FIX_CASE);
...@@ -224,7 +225,7 @@ class Statement implements IteratorAggregate, DriverStatement ...@@ -224,7 +225,7 @@ class Statement implements IteratorAggregate, DriverStatement
{ {
$value = $this->stmt->fetchColumn($columnIndex); $value = $this->stmt->fetchColumn($columnIndex);
if ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM)) { if ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL | Connection::PORTABILITY_RTRIM)) {
if (($this->portability & Connection::PORTABILITY_EMPTY_TO_NULL) && $value === '') { if (($this->portability & Connection::PORTABILITY_EMPTY_TO_NULL) && $value === '') {
$value = null; $value = null;
} elseif (($this->portability & Connection::PORTABILITY_RTRIM) && is_string($value)) { } elseif (($this->portability & Connection::PORTABILITY_RTRIM) && is_string($value)) {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Query\Expression; namespace Doctrine\DBAL\Query\Expression;
use Countable; use Countable;
use function count; use function count;
use function implode; use function implode;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Query\Expression; namespace Doctrine\DBAL\Query\Expression;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use function func_get_arg; use function func_get_arg;
use function func_get_args; use function func_get_args;
use function func_num_args; use function func_num_args;
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\ResultStatement; ...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Query\Expression\CompositeExpression; use Doctrine\DBAL\Query\Expression\CompositeExpression;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder; use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
use function array_key_exists; use function array_key_exists;
use function array_keys; use function array_keys;
use function array_unshift; use function array_unshift;
...@@ -487,7 +488,7 @@ class QueryBuilder ...@@ -487,7 +488,7 @@ class QueryBuilder
* *
* @return $this This QueryBuilder instance. * @return $this This QueryBuilder instance.
*/ */
public function distinct() : self public function distinct(): self
{ {
$this->sqlParts['distinct'] = true; $this->sqlParts['distinct'] = true;
...@@ -1175,7 +1176,7 @@ class QueryBuilder ...@@ -1175,7 +1176,7 @@ class QueryBuilder
* *
* @throws QueryException * @throws QueryException
*/ */
private function verifyAllAliasesAreKnown(array $knownAliases) : void private function verifyAllAliasesAreKnown(array $knownAliases): void
{ {
foreach ($this->sqlParts['join'] as $fromAlias => $joins) { foreach ($this->sqlParts['join'] as $fromAlias => $joins) {
if (! isset($knownAliases[$fromAlias])) { if (! isset($knownAliases[$fromAlias])) {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Query; namespace Doctrine\DBAL\Query;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use function implode; use function implode;
/** /**
......
...@@ -19,6 +19,7 @@ use function sprintf; ...@@ -19,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; use const PREG_OFFSET_CAPTURE;
/** /**
...@@ -65,13 +66,13 @@ class SQLParserUtils ...@@ -65,13 +66,13 @@ class SQLParserUtils
* *
* @return int[] * @return int[]
*/ */
private static function getPositionalPlaceholderPositions(string $statement) : array private static function getPositionalPlaceholderPositions(string $statement): array
{ {
return self::collectPlaceholders( return self::collectPlaceholders(
$statement, $statement,
'?', '?',
self::POSITIONAL_TOKEN, self::POSITIONAL_TOKEN,
static function (string $_, int $placeholderPosition, int $fragmentPosition, array &$carry) : void { static function (string $_, int $placeholderPosition, int $fragmentPosition, array &$carry): void {
$carry[] = $placeholderPosition + $fragmentPosition; $carry[] = $placeholderPosition + $fragmentPosition;
} }
); );
...@@ -82,13 +83,13 @@ class SQLParserUtils ...@@ -82,13 +83,13 @@ class SQLParserUtils
* *
* @return string[] * @return string[]
*/ */
private static function getNamedPlaceholderPositions(string $statement) : array private static function getNamedPlaceholderPositions(string $statement): array
{ {
return self::collectPlaceholders( return self::collectPlaceholders(
$statement, $statement,
':', ':',
self::NAMED_TOKEN, self::NAMED_TOKEN,
static function (string $placeholder, int $placeholderPosition, int $fragmentPosition, array &$carry) : void { static function (string $placeholder, int $placeholderPosition, int $fragmentPosition, array &$carry): void {
$carry[$placeholderPosition + $fragmentPosition] = substr($placeholder, 1); $carry[$placeholderPosition + $fragmentPosition] = substr($placeholder, 1);
} }
); );
...@@ -97,7 +98,7 @@ class SQLParserUtils ...@@ -97,7 +98,7 @@ class SQLParserUtils
/** /**
* @return mixed[] * @return mixed[]
*/ */
private static function collectPlaceholders(string $statement, string $match, string $token, callable $collector) : array private static function collectPlaceholders(string $statement, string $match, string $token, callable $collector): array
{ {
if (strpos($statement, $match) === false) { if (strpos($statement, $match) === false) {
return []; return [];
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use function array_map; use function array_map;
use function crc32; use function crc32;
use function dechex; use function dechex;
......
...@@ -10,6 +10,7 @@ use Doctrine\DBAL\Event\SchemaIndexDefinitionEventArgs; ...@@ -10,6 +10,7 @@ use Doctrine\DBAL\Event\SchemaIndexDefinitionEventArgs;
use Doctrine\DBAL\Events; use Doctrine\DBAL\Events;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Throwable; use Throwable;
use function array_filter; use function array_filter;
use function array_intersect; use function array_intersect;
use function array_map; use function array_map;
...@@ -429,7 +430,7 @@ abstract class AbstractSchemaManager ...@@ -429,7 +430,7 @@ abstract class AbstractSchemaManager
*/ */
public function createTable(Table $table) public function createTable(Table $table)
{ {
$createFlags = AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS; $createFlags = AbstractPlatform::CREATE_INDEXES | AbstractPlatform::CREATE_FOREIGNKEYS;
$this->_execSql($this->_platform->getCreateTableSQL($table, $createFlags)); $this->_execSql($this->_platform->getCreateTableSQL($table, $createFlags));
} }
......
...@@ -3,11 +3,13 @@ ...@@ -3,11 +3,13 @@
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
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; use const E_USER_DEPRECATED;
/** /**
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Types; use Doctrine\DBAL\Types;
use function array_intersect_key; use function array_intersect_key;
use function array_key_exists; use function array_key_exists;
use function array_keys; use function array_keys;
...@@ -248,7 +249,8 @@ class Comparator ...@@ -248,7 +249,8 @@ class Comparator
/* 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.
if (($index->isPrimary() && ! $table2->hasPrimaryKey()) || if (
($index->isPrimary() && ! $table2->hasPrimaryKey()) ||
! $index->isPrimary() && ! $table2->hasIndex($indexName) ! $index->isPrimary() && ! $table2->hasIndex($indexName)
) { ) {
$tableDifferences->removedIndexes[$indexName] = $index; $tableDifferences->removedIndexes[$indexName] = $index;
...@@ -447,12 +449,15 @@ class Comparator ...@@ -447,12 +449,15 @@ class Comparator
// Null values need to be checked additionally as they tell whether to create or drop a default value. // Null values need to be checked additionally as they tell whether to create or drop a default value.
// null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation. // null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation.
if (($properties1['default'] === null) !== ($properties2['default'] === null) if (
|| $properties1['default'] != $properties2['default']) { ($properties1['default'] === null) !== ($properties2['default'] === null)
|| $properties1['default'] != $properties2['default']
) {
$changedProperties[] = 'default'; $changedProperties[] = 'default';
} }
if (($properties1['type'] instanceof Types\StringType && ! $properties1['type'] instanceof Types\GuidType) || if (
($properties1['type'] instanceof Types\StringType && ! $properties1['type'] instanceof Types\GuidType) ||
$properties1['type'] instanceof Types\BinaryType $properties1['type'] instanceof Types\BinaryType
) { ) {
// check if value of length is set at all, default value assumed otherwise. // check if value of length is set at all, default value assumed otherwise.
...@@ -476,7 +481,8 @@ class Comparator ...@@ -476,7 +481,8 @@ class Comparator
} }
// A null value and an empty string are actually equal for a comment so they should not trigger a change. // A null value and an empty string are actually equal for a comment so they should not trigger a change.
if ($properties1['comment'] !== $properties2['comment'] && if (
$properties1['comment'] !== $properties2['comment'] &&
! ($properties1['comment'] === null && $properties2['comment'] === '') && ! ($properties1['comment'] === null && $properties2['comment'] === '') &&
! ($properties2['comment'] === null && $properties1['comment'] === '') ! ($properties2['comment'] === null && $properties1['comment'] === '')
) { ) {
...@@ -513,7 +519,7 @@ class Comparator ...@@ -513,7 +519,7 @@ class Comparator
* *
* @deprecated * @deprecated
*/ */
private function isALegacyJsonComparison(Types\Type $one, Types\Type $other) : bool private function isALegacyJsonComparison(Types\Type $one, Types\Type $other): bool
{ {
if (! $one instanceof Types\JsonType || ! $other instanceof Types\JsonType) { if (! $one instanceof Types\JsonType || ! $other instanceof Types\JsonType) {
return false; return false;
......
...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Schema; ...@@ -4,6 +4,7 @@ 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 function array_change_key_case; use function array_change_key_case;
use function assert; use function assert;
use function is_resource; use function is_resource;
...@@ -12,6 +13,7 @@ use function str_replace; ...@@ -12,6 +13,7 @@ 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; use const CASE_LOWER;
/** /**
...@@ -209,7 +211,7 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -209,7 +211,7 @@ class DB2SchemaManager extends AbstractSchemaManager
//$view['text'] = (is_resource($view['text']) ? stream_get_contents($view['text']) : $view['text']); //$view['text'] = (is_resource($view['text']) ? stream_get_contents($view['text']) : $view['text']);
if (! is_resource($view['text'])) { if (! is_resource($view['text'])) {
$pos = strpos($view['text'], ' AS '); $pos = strpos($view['text'], ' AS ');
$sql = substr($view['text'], $pos+4); $sql = substr($view['text'], $pos + 4);
} else { } else {
$sql = ''; $sql = '';
} }
...@@ -220,7 +222,7 @@ class DB2SchemaManager extends AbstractSchemaManager ...@@ -220,7 +222,7 @@ class DB2SchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function listTableDetails($tableName) : Table public function listTableDetails($tableName): Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use function explode; use function explode;
use function strtolower; use function strtolower;
use function trim; use function trim;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use function array_keys; use function array_keys;
use function array_map; use function array_map;
use function in_array; use function in_array;
...@@ -85,7 +86,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -85,7 +86,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
* *
* @return Identifier[] * @return Identifier[]
*/ */
private function createIdentifierMap(array $names) : array private function createIdentifierMap(array $names): array
{ {
$identifiers = []; $identifiers = [];
......
...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Schema; ...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use InvalidArgumentException; use InvalidArgumentException;
use function array_filter; use function array_filter;
use function array_keys; use function array_keys;
use function array_map; use function array_map;
...@@ -348,9 +349,9 @@ class Index extends AbstractAsset implements Constraint ...@@ -348,9 +349,9 @@ class Index extends AbstractAsset implements Constraint
/** /**
* Returns whether the index has the same column lengths as the other * Returns whether the index has the same column lengths as the other
*/ */
private function hasSameColumnLengths(self $other) : bool private function hasSameColumnLengths(self $other): bool
{ {
$filter = static function (?int $length) : bool { $filter = static function (?int $length): bool {
return $length !== null; return $length !== null;
}; };
......
...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Schema; ...@@ -5,6 +5,7 @@ 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 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;
...@@ -16,6 +17,7 @@ use function strpos; ...@@ -16,6 +17,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; use const CASE_LOWER;
/** /**
...@@ -243,7 +245,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -243,7 +245,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
* *
* @param string|null $columnDefault default value as stored in information_schema for MariaDB >= 10.2.7 * @param string|null $columnDefault default value as stored in information_schema for MariaDB >= 10.2.7
*/ */
private function getMariaDb1027ColumnDefault(MariaDb1027Platform $platform, ?string $columnDefault) : ?string private function getMariaDb1027ColumnDefault(MariaDb1027Platform $platform, ?string $columnDefault): ?string
{ {
if ($columnDefault === 'NULL' || $columnDefault === null) { if ($columnDefault === 'NULL' || $columnDefault === null) {
return null; return null;
...@@ -351,7 +353,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -351,7 +353,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
/** /**
* @return string[]|true[] * @return string[]|true[]
*/ */
private function parseCreateOptions(?string $string) : array private function parseCreateOptions(?string $string): array
{ {
$options = []; $options = [];
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\DriverException; ...@@ -7,6 +7,7 @@ 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 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;
...@@ -17,6 +18,7 @@ use function strpos; ...@@ -17,6 +18,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; use const CASE_LOWER;
/** /**
...@@ -398,7 +400,7 @@ SQL; ...@@ -398,7 +400,7 @@ SQL;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function listTableDetails($tableName) : Table public function listTableDetails($tableName): Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\FetchMode; ...@@ -7,6 +7,7 @@ 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 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;
...@@ -24,6 +25,7 @@ use function strlen; ...@@ -24,6 +25,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; use const CASE_LOWER;
/** /**
...@@ -492,7 +494,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -492,7 +494,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* Parses a default value expression as given by PostgreSQL * Parses a default value expression as given by PostgreSQL
*/ */
private function parseDefaultExpression(?string $default) : ?string private function parseDefaultExpression(?string $default): ?string
{ {
if ($default === null) { if ($default === null) {
return $default; return $default;
...@@ -504,7 +506,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -504,7 +506,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function listTableDetails($tableName) : Table public function listTableDetails($tableName): Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
......
...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Schema; ...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Platforms\SQLAnywherePlatform; use Doctrine\DBAL\Platforms\SQLAnywherePlatform;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use function assert; use function assert;
use function is_string; use function is_string;
use function preg_replace; use function preg_replace;
......
...@@ -8,6 +8,7 @@ use Doctrine\DBAL\Platforms\SQLServerPlatform; ...@@ -8,6 +8,7 @@ use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use PDOException; use PDOException;
use Throwable; use Throwable;
use function assert; use function assert;
use function count; use function count;
use function in_array; use function in_array;
...@@ -126,7 +127,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -126,7 +127,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
return $column; return $column;
} }
private function parseDefaultExpression(string $value) : ?string private function parseDefaultExpression(string $value): ?string
{ {
while (preg_match('/^\((.*)\)$/s', $value, $matches)) { while (preg_match('/^\((.*)\)$/s', $value, $matches)) {
$value = $matches[1]; $value = $matches[1];
...@@ -332,7 +333,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -332,7 +333,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/** /**
* @param string $tableName * @param string $tableName
*/ */
public function listTableDetails($tableName) : Table public function listTableDetails($tableName): Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Schema\Visitor\CreateSchemaSqlCollector; ...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Schema\Visitor\CreateSchemaSqlCollector;
use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector;
use Doctrine\DBAL\Schema\Visitor\NamespaceVisitor; use Doctrine\DBAL\Schema\Visitor\NamespaceVisitor;
use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\DBAL\Schema\Visitor\Visitor;
use function array_keys; use function array_keys;
use function strpos; use function strpos;
use function strtolower; use function strtolower;
...@@ -106,9 +107,11 @@ class Schema extends AbstractAsset ...@@ -106,9 +107,11 @@ class Schema extends AbstractAsset
throw SchemaException::tableAlreadyExists($tableName); throw SchemaException::tableAlreadyExists($tableName);
} }
if ($namespaceName !== null if (
$namespaceName !== null
&& ! $table->isInDefaultNamespace($this->getName()) && ! $table->isInDefaultNamespace($this->getName())
&& ! $this->hasNamespace($namespaceName)) { && ! $this->hasNamespace($namespaceName)
) {
$this->createNamespace($namespaceName); $this->createNamespace($namespaceName);
} }
...@@ -130,9 +133,11 @@ class Schema extends AbstractAsset ...@@ -130,9 +133,11 @@ class Schema extends AbstractAsset
throw SchemaException::sequenceAlreadyExists($seqName); throw SchemaException::sequenceAlreadyExists($seqName);
} }
if ($namespaceName !== null if (
$namespaceName !== null
&& ! $sequence->isInDefaultNamespace($this->getName()) && ! $sequence->isInDefaultNamespace($this->getName())
&& ! $this->hasNamespace($namespaceName)) { && ! $this->hasNamespace($namespaceName)
) {
$this->createNamespace($namespaceName); $this->createNamespace($namespaceName);
} }
......
...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Schema; ...@@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Internal\DependencyOrderCalculator; use Doctrine\DBAL\Internal\DependencyOrderCalculator;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use function array_merge; use function array_merge;
/** /**
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use function implode; use function implode;
use function sprintf; use function sprintf;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\DBAL\Schema\Visitor\Visitor;
use function count; use function count;
use function sprintf; use function sprintf;
......
...@@ -8,6 +8,7 @@ use Doctrine\DBAL\FetchMode; ...@@ -8,6 +8,7 @@ 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 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;
...@@ -26,6 +27,7 @@ use function strtolower; ...@@ -26,6 +27,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; use const CASE_LOWER;
/** /**
...@@ -120,8 +122,9 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -120,8 +122,9 @@ class SqliteSchemaManager extends AbstractSchemaManager
if (! empty($tableForeignKeys)) { if (! empty($tableForeignKeys)) {
$createSql = $this->getCreateTableSQL($table); $createSql = $this->getCreateTableSQL($table);
if ($createSql !== null && preg_match_all( if (
'# $createSql !== null && preg_match_all(
'#
(?:CONSTRAINT\s+([^\s]+)\s+)? (?:CONSTRAINT\s+([^\s]+)\s+)?
(?:FOREIGN\s+KEY[^\)]+\)\s*)? (?:FOREIGN\s+KEY[^\)]+\)\s*)?
REFERENCES\s+[^\s]+\s+(?:\([^\)]+\))? REFERENCES\s+[^\s]+\s+(?:\([^\)]+\))?
...@@ -130,9 +133,10 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -130,9 +133,10 @@ class SqliteSchemaManager extends AbstractSchemaManager
(NOT\s+DEFERRABLE|DEFERRABLE) (NOT\s+DEFERRABLE|DEFERRABLE)
(?:\s+INITIALLY\s+(DEFERRED|IMMEDIATE))? (?:\s+INITIALLY\s+(DEFERRED|IMMEDIATE))?
)?#isx', )?#isx',
$createSql, $createSql,
$match $match
)) { )
) {
$names = array_reverse($match[1]); $names = array_reverse($match[1]);
$deferrable = array_reverse($match[2]); $deferrable = array_reverse($match[2]);
$deferred = array_reverse($match[3]); $deferred = array_reverse($match[3]);
...@@ -415,7 +419,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -415,7 +419,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
'onDelete' => $value['on_delete'], 'onDelete' => $value['on_delete'],
'onUpdate' => $value['on_update'], 'onUpdate' => $value['on_update'],
'deferrable' => $value['deferrable'], 'deferrable' => $value['deferrable'],
'deferred'=> $value['deferred'], 'deferred' => $value['deferred'],
]; ];
} }
...@@ -434,7 +438,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -434,7 +438,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
'onDelete' => $constraint['onDelete'], 'onDelete' => $constraint['onDelete'],
'onUpdate' => $constraint['onUpdate'], 'onUpdate' => $constraint['onUpdate'],
'deferrable' => $constraint['deferrable'], 'deferrable' => $constraint['deferrable'],
'deferred'=> $constraint['deferred'], 'deferred' => $constraint['deferred'],
] ]
); );
} }
...@@ -467,7 +471,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -467,7 +471,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
return $tableDiff; return $tableDiff;
} }
private function parseColumnCollationFromSQL(string $column, string $sql) : ?string private function parseColumnCollationFromSQL(string $column, string $sql): ?string
{ {
$pattern = '{(?:\W' . preg_quote($column) . '\W|\W' . preg_quote($this->_platform->quoteSingleIdentifier($column)) $pattern = '{(?:\W' . preg_quote($column) . '\W|\W' . preg_quote($this->_platform->quoteSingleIdentifier($column))
. '\W)[^,(]+(?:\([^()]+\)[^,]*)?(?:(?:DEFAULT|CHECK)\s*(?:\(.*?\))?[^,]*)*COLLATE\s+["\']?([^\s,"\')]+)}is'; . '\W)[^,(]+(?:\([^()]+\)[^,]*)?(?:(?:DEFAULT|CHECK)\s*(?:\(.*?\))?[^,]*)*COLLATE\s+["\']?([^\s,"\')]+)}is';
...@@ -479,7 +483,7 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -479,7 +483,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
return $match[1]; return $match[1];
} }
private function parseTableCommentFromSQL(string $table, string $sql) : ?string private function parseTableCommentFromSQL(string $table, string $sql): ?string
{ {
$pattern = '/\s* # Allow whitespace characters at start of line $pattern = '/\s* # Allow whitespace characters at start of line
CREATE\sTABLE # Match "CREATE TABLE" CREATE\sTABLE # Match "CREATE TABLE"
...@@ -498,7 +502,7 @@ CREATE\sTABLE # Match "CREATE TABLE" ...@@ -498,7 +502,7 @@ CREATE\sTABLE # Match "CREATE TABLE"
return $comment === '' ? null : $comment; return $comment === '' ? null : $comment;
} }
private function parseColumnCommentFromSQL(string $column, string $sql) : ?string private function parseColumnCommentFromSQL(string $column, string $sql): ?string
{ {
$pattern = '{[\s(,](?:\W' . preg_quote($this->_platform->quoteSingleIdentifier($column)) . '\W|\W' . preg_quote($column) $pattern = '{[\s(,](?:\W' . preg_quote($this->_platform->quoteSingleIdentifier($column)) . '\W|\W' . preg_quote($column)
. '\W)(?:\([^)]*?\)|[^,(])*?,?((?:(?!\n))(?:\s*--[^\n]*\n?)+)}i'; . '\W)(?:\([^)]*?\)|[^,(])*?,?((?:(?!\n))(?:\s*--[^\n]*\n?)+)}i';
...@@ -512,7 +516,7 @@ CREATE\sTABLE # Match "CREATE TABLE" ...@@ -512,7 +516,7 @@ CREATE\sTABLE # Match "CREATE TABLE"
return $comment === '' ? null : $comment; return $comment === '' ? null : $comment;
} }
private function getCreateTableSQL(string $table) : ?string private function getCreateTableSQL(string $table): ?string
{ {
return $this->_conn->fetchColumn( return $this->_conn->fetchColumn(
<<<'SQL' <<<'SQL'
...@@ -535,7 +539,7 @@ SQL ...@@ -535,7 +539,7 @@ SQL
/** /**
* @param string $tableName * @param string $tableName
*/ */
public function listTableDetails($tableName) : Table public function listTableDetails($tableName): Table
{ {
$table = parent::listTableDetails($tableName); $table = parent::listTableDetails($tableName);
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; ...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector;
use function count; use function count;
/** /**
......
...@@ -5,12 +5,14 @@ namespace Doctrine\DBAL\Schema; ...@@ -5,12 +5,14 @@ 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 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; use const ARRAY_FILTER_USE_KEY;
/** /**
...@@ -475,7 +477,8 @@ class Table extends AbstractAsset ...@@ -475,7 +477,8 @@ class Table extends AbstractAsset
$replacedImplicitIndexes[] = $name; $replacedImplicitIndexes[] = $name;
} }
if ((isset($this->_indexes[$indexName]) && ! in_array($indexName, $replacedImplicitIndexes, true)) || if (
(isset($this->_indexes[$indexName]) && ! in_array($indexName, $replacedImplicitIndexes, true)) ||
($this->_primaryKeyName !== false && $indexCandidate->isPrimary()) ($this->_primaryKeyName !== false && $indexCandidate->isPrimary())
) { ) {
throw SchemaException::indexAlreadyExists($indexName, $this->_name); throw SchemaException::indexAlreadyExists($indexName, $this->_name);
...@@ -846,7 +849,7 @@ class Table extends AbstractAsset ...@@ -846,7 +849,7 @@ class Table extends AbstractAsset
return $this->trimQuotes(strtolower($identifier)); return $this->trimQuotes(strtolower($identifier));
} }
public function setComment(?string $comment) : self public function setComment(?string $comment): self
{ {
// For keeping backward compatibility with MySQL in previous releases, table comments are stored as options. // For keeping backward compatibility with MySQL in previous releases, table comments are stored as options.
$this->addOption('comment', $comment); $this->addOption('comment', $comment);
...@@ -854,7 +857,7 @@ class Table extends AbstractAsset ...@@ -854,7 +857,7 @@ class Table extends AbstractAsset
return $this; return $this;
} }
public function getComment() : ?string public function getComment(): ?string
{ {
return $this->_options['comment'] ?? null; return $this->_options['comment'] ?? null;
} }
......
...@@ -6,6 +6,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; ...@@ -6,6 +6,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use function array_merge; use function array_merge;
class CreateSchemaSqlCollector extends AbstractVisitor class CreateSchemaSqlCollector extends AbstractVisitor
......
...@@ -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 assert;
use function strlen; use function strlen;
......
...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Schema\Visitor; ...@@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Schema\Visitor;
use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use function current; use function current;
use function file_put_contents; use function file_put_contents;
use function in_array; use function in_array;
......
...@@ -11,6 +11,7 @@ use Doctrine\DBAL\Event\ConnectionEventArgs; ...@@ -11,6 +11,7 @@ use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events; use Doctrine\DBAL\Events;
use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser; use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser;
use InvalidArgumentException; use InvalidArgumentException;
use function array_merge; use function array_merge;
use function is_numeric; use function is_numeric;
use function is_string; use function is_string;
......
...@@ -11,6 +11,7 @@ use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer; ...@@ -11,6 +11,7 @@ use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use RuntimeException; use RuntimeException;
use function array_merge; use function array_merge;
/** /**
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Sharding\ShardingException; ...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Sharding\ShardingException;
use Doctrine\DBAL\Sharding\ShardManager; use Doctrine\DBAL\Sharding\ShardManager;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use RuntimeException; use RuntimeException;
use function sprintf; use function sprintf;
/** /**
......
...@@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\Sequence; ...@@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\DBAL\Schema\Visitor\Visitor;
use RuntimeException; use RuntimeException;
use function in_array; use function in_array;
/** /**
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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