Update doctrine/coding-standard to 8.1

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