Manual coding style fixes

parent 9da1ea3e
......@@ -15,7 +15,7 @@ use function reset;
class ArrayStatement implements IteratorAggregate, ResultStatement
{
/** @var array */
/** @var mixed[] */
private $data;
/** @var int */
......@@ -28,7 +28,7 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
private $defaultFetchMode = FetchMode::MIXED;
/**
* @param array $data
* @param mixed[] $data
*/
public function __construct(array $data)
{
......
......@@ -67,12 +67,12 @@ class QueryCacheProfile
/**
* Generates the real cache key from query, params, types and connection parameters.
*
* @param string $query
* @param array $params
* @param array $types
* @param array $connectionParams
* @param string $query
* @param mixed[] $params
* @param int[]|string[] $types
* @param mixed[] $connectionParams
*
* @return array
* @return string[]
*/
public function generateCacheKeys($query, $params, $types, array $connectionParams = [])
{
......
......@@ -51,7 +51,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
*/
private $emptied = false;
/** @var array */
/** @var mixed[] */
private $data;
/** @var int */
......@@ -78,7 +78,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
{
$this->statement->closeCursor();
if (! $this->emptied || $this->data === null) {
return;
return true;
}
$data = $this->resultCache->fetch($this->cacheKey);
......@@ -89,6 +89,8 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
$this->resultCache->save($this->cacheKey, $data, $this->lifetime);
unset($this->data);
return true;
}
/**
......
......@@ -17,7 +17,7 @@ class Configuration
* The attributes that are contained in the configuration.
* Values are default values.
*
* @var array
* @var mixed[]
*/
protected $_attributes = [];
......
This diff is collapsed.
......@@ -85,7 +85,7 @@ class MasterSlaveConnection extends Connection
/**
* Creates Master Slave Connection.
*
* @param array $params
* @param mixed[] $params
*
* @throws InvalidArgumentException
*/
......@@ -195,8 +195,8 @@ class MasterSlaveConnection extends Connection
}
/**
* @param string $connectionName
* @param array $params
* @param string $connectionName
* @param mixed[] $params
*
* @return mixed
*/
......
......@@ -29,7 +29,7 @@ class DBALException extends Exception
*/
public static function notSupported($method)
{
return new self("Operation '$method' is not supported by platform.");
return new self(sprintf("Operation '%s' is not supported by platform.", $method));
}
public static function invalidPlatformSpecified() : self
......@@ -117,8 +117,8 @@ class DBALException extends Exception
}
/**
* @param string $unknownDriverName
* @param array $knownDrivers
* @param string $unknownDriverName
* @param string[] $knownDrivers
*
* @return \Doctrine\DBAL\DBALException
*/
......@@ -131,7 +131,7 @@ class DBALException extends Exception
/**
* @param Exception $driverEx
* @param string $sql
* @param array $params
* @param mixed[] $params
*
* @return \Doctrine\DBAL\DBALException
*/
......@@ -177,7 +177,7 @@ class DBALException extends Exception
* Returns a human-readable representation of an array of parameters.
* This properly handles binary data by returning a hex representation.
*
* @param array $params
* @param mixed[] $params
*
* @return string
*/
......
......@@ -14,10 +14,10 @@ interface Driver
/**
* Attempts to create a connection with the database.
*
* @param array $params All connection parameters passed by the user.
* @param mixed[] $params All connection parameters passed by the user.
* @param string|null $username The username to use when connecting.
* @param string|null $password The password to use when connecting.
* @param array $driverOptions The driver options to use when connecting.
* @param mixed[] $driverOptions The driver options to use when connecting.
*
* @return \Doctrine\DBAL\Driver\Connection The database connection.
*/
......
......@@ -88,7 +88,7 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
/**
* Returns an appropriate Easy Connect String for the given parameters.
*
* @param array $params The connection parameters to return the Easy Connect STring for.
* @param mixed[] $params The connection parameters to return the Easy Connect String for.
*
* @return string
*/
......
......@@ -76,7 +76,6 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
/**
* {@inheritdoc}
*/
public function getSchemaManager(Connection $conn)
{
return new SQLServerSchemaManager($conn);
......
......@@ -87,7 +87,7 @@ interface Connection
/**
* Returns extended error information associated with the last operation on the database handle.
*
* @return array
* @return mixed[]
*/
public function errorInfo();
}
......@@ -30,10 +30,10 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
private $_conn = null;
/**
* @param array $params
* @param string $username
* @param string $password
* @param array $driverOptions
* @param mixed[] $params
* @param string $username
* @param string $password
* @param mixed[] $driverOptions
*
* @throws DB2Exception
*/
......
......@@ -42,7 +42,7 @@ class DB2Statement implements IteratorAggregate, Statement
/** @var resource */
private $_stmt;
/** @var array */
/** @var mixed[] */
private $_bindParam = [];
/** @var string Name of the default class to instantiate when fetching class instances. */
......@@ -64,7 +64,7 @@ class DB2Statement implements IteratorAggregate, Statement
/**
* DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG
*
* @var array
* @var int[]
*/
static private $_typeMap = [
ParameterType::INTEGER => DB2_LONG,
......@@ -313,7 +313,7 @@ class DB2Statement implements IteratorAggregate, Statement
*
* @param stdClass $sourceObject Object to cast from.
* @param string|object $destinationClass Name of the class or class instance to cast to.
* @param array $ctorArgs Arguments to use for constructing the destination class instance.
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
*
* @return object
*
......
......@@ -38,10 +38,10 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
private $_conn;
/**
* @param array $params
* @param string $username
* @param string $password
* @param array $driverOptions
* @param mixed[] $params
* @param string $username
* @param string $password
* @param mixed[] $driverOptions
*
* @throws MysqliException
*/
......@@ -217,7 +217,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
/**
* Apply the driver options to the connection.
*
* @param array $driverOptions
* @param mixed[] $driverOptions
*
* @throws MysqliException When one of of the options is not supported.
* @throws MysqliException When applying doesn't work - e.g. due to incorrect value.
......@@ -277,7 +277,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
/**
* Establish a secure connection
*
* @param array $params
* @param mixed[] $params
*
* @throws MysqliException
*/
......
......@@ -19,11 +19,12 @@ use function feof;
use function fread;
use function get_resource_type;
use function is_resource;
use function sprintf;
use function str_repeat;
class MysqliStatement implements IteratorAggregate, Statement
{
/** @var array */
/** @var string[] */
protected static $_paramTypeMap = [
ParameterType::STRING => 's',
ParameterType::BINARY => 's',
......@@ -39,13 +40,13 @@ class MysqliStatement implements IteratorAggregate, Statement
/** @var mysqli_stmt */
protected $_stmt;
/** @var bool|array|null */
/** @var string[]|bool|null */
protected $_columnNames;
/** @var array|null */
/** @var mixed[]|null */
protected $_rowBindedValues;
/** @var array */
/** @var mixed[] */
protected $_bindedValues;
/** @var string */
......@@ -54,7 +55,7 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
* Contains ref values for bindValue().
*
* @var array
* @var mixed[]
*/
protected $_values = [];
......@@ -99,7 +100,7 @@ class MysqliStatement implements IteratorAggregate, Statement
$type = 's';
} else {
if (! isset(self::$_paramTypeMap[$type])) {
throw new MysqliException("Unknown type: '{$type}'");
throw new MysqliException(sprintf("Unknown type: '%s'", $type));
}
$type = self::$_paramTypeMap[$type];
......@@ -120,7 +121,7 @@ class MysqliStatement implements IteratorAggregate, Statement
$type = 's';
} else {
if (! isset(self::$_paramTypeMap[$type])) {
throw new MysqliException("Unknown type: '{$type}'");
throw new MysqliException(sprintf("Unknown type: '%s'", $type));
}
$type = self::$_paramTypeMap[$type];
......@@ -265,7 +266,7 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
* Binds a array of values to bound parameters.
*
* @param array $values
* @param mixed[] $values
*
* @return bool
*/
......@@ -350,7 +351,7 @@ class MysqliStatement implements IteratorAggregate, Statement
return $ret;
default:
throw new MysqliException("Unknown fetch type '{$fetchMode}'");
throw new MysqliException(sprintf("Unknown fetch type '%s'", $fetchMode));
}
}
......
......@@ -33,7 +33,7 @@ class Driver extends AbstractOracleDriver
/**
* Constructs the Oracle DSN.
*
* @param array $params
* @param mixed[] $params
*
* @return string The DSN.
*/
......
......@@ -66,8 +66,8 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*
* @throws UnexpectedValueException if the version string returned by the database server
* does not contain a parsable version number.
* @throws UnexpectedValueException If the version string returned by the database server
* does not contain a parsable version number.
*/
public function getServerVersion()
{
......
......@@ -7,7 +7,7 @@ use Doctrine\DBAL\Driver\AbstractDriverException;
class OCI8Exception extends AbstractDriverException
{
/**
* @param array $error
* @param mixed[] $error
*
* @return \Doctrine\DBAL\Driver\OCI8\OCI8Exception
*/
......
......@@ -59,7 +59,7 @@ class OCI8Statement implements IteratorAggregate, Statement
/** @var string */
protected static $_PARAM = ':param';
/** @var array */
/** @var int[] */
protected static $fetchModeMap = [
FetchMode::MIXED => OCI_BOTH,
FetchMode::ASSOCIATIVE => OCI_ASSOC,
......@@ -70,7 +70,7 @@ class OCI8Statement implements IteratorAggregate, Statement
/** @var int */
protected $_defaultFetchMode = FetchMode::MIXED;
/** @var array */
/** @var string[] */
protected $_paramMap = [];
/**
......@@ -78,7 +78,7 @@ class OCI8Statement implements IteratorAggregate, Statement
*
* This is a new requirement for PHP7's oci8 extension that prevents bound values from being garbage collected.
*
* @var array
* @var mixed[]
*/
private $boundValues = [];
......@@ -118,7 +118,7 @@ class OCI8Statement implements IteratorAggregate, Statement
*
* @param string $statement The SQL statement to convert.
*
* @return array [0] => the statement value (string), [1] => the paramMap value (array).
* @return mixed[] [0] => the statement value (string), [1] => the paramMap value (array).
*
* @throws OCI8Exception
*
......
......@@ -14,12 +14,12 @@ use function func_get_args;
class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
{
/**
* @param string $dsn
* @param string|null $user
* @param string|null $password
* @param array|null $options
* @param string $dsn
* @param string|null $user
* @param string|null $password
* @param mixed[]|null $options
*
* @throws PDOException in case of an error.
* @throws PDOException In case of an error.
*/
public function __construct($dsn, $user = null, $password = null, ?array $options = null)
{
......
......@@ -28,7 +28,7 @@ class Driver extends AbstractDB2Driver
/**
* Constructs the IBM PDO DSN.
*
* @param array $params
* @param mixed[] $params
*
* @return string The DSN.
*/
......
......@@ -34,7 +34,7 @@ class Driver extends AbstractMySQLDriver
/**
* Constructs the MySql PDO DSN.
*
* @param array $params
* @param mixed[] $params
*
* @return string The DSN.
*/
......
......@@ -37,7 +37,7 @@ class Driver extends AbstractOracleDriver
/**
* Constructs the Oracle PDO DSN.
*
* @param array $params
* @param mixed[] $params
*
* @return string The DSN.
*/
......
......@@ -52,7 +52,7 @@ class Driver extends AbstractPostgreSQLDriver
/**
* Constructs the Postgres PDO DSN.
*
* @param array $params
* @param mixed[] $params
*
* @return string The DSN.
*/
......@@ -76,7 +76,7 @@ class Driver extends AbstractPostgreSQLDriver
// Used for temporary connections to allow operations like dropping the database currently connected to.
// Connecting without an explicit database does not work, therefore "postgres" database is used
// as it is mostly present in every server setup.
$dsn .= 'dbname=postgres' . ';';
$dsn .= 'dbname=postgres;';
}
if (isset($params['sslmode'])) {
......
......@@ -13,7 +13,7 @@ use function array_merge;
*/
class Driver extends AbstractSQLiteDriver
{
/** @var array */
/** @var mixed[] */
protected $_userDefinedFunctions = [
'sqrt' => ['callback' => ['Doctrine\DBAL\Platforms\SqlitePlatform', 'udfSqrt'], 'numArgs' => 1],
'mod' => ['callback' => ['Doctrine\DBAL\Platforms\SqlitePlatform', 'udfMod'], 'numArgs' => 2],
......@@ -54,7 +54,7 @@ class Driver extends AbstractSQLiteDriver
/**
* Constructs the Sqlite PDO DSN.
*
* @param array $params
* @param mixed[] $params
*
* @return string The DSN.
*/
......
......@@ -29,7 +29,7 @@ class Driver extends AbstractSQLServerDriver
/**
* Constructs the Sqlsrv PDO DSN.
*
* @param array $params
* @param mixed[] $params
* @param string[] $connectionOptions
*
* @return string The DSN.
......@@ -54,9 +54,7 @@ class Driver extends AbstractSQLServerDriver
$connectionOptions['MultipleActiveResultSets'] = $params['MultipleActiveResultSets'] ? 'true' : 'false';
}
$dsn .= $this->getConnectionOptionsDsn($connectionOptions);
return $dsn;
return $dsn . $this->getConnectionOptionsDsn($connectionOptions);
}
/**
......
......@@ -67,22 +67,22 @@ interface ResultStatement extends Traversable
/**
* Returns an array containing all of the result set rows.
*
* @param int|null $fetchMode Controls how the next row will be returned to the caller.
* The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
* defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
* @param int|null $fetchArgument This argument has a different meaning depending on the value of the $fetchMode parameter:
* * {@link \Doctrine\DBAL\FetchMode::COLUMN}:
* Returns the indicated 0-indexed column.
* * {@link \Doctrine\DBAL\FetchMode::CUSTOM_OBJECT}:
* Returns instances of the specified class, mapping the columns of each row
* to named properties in the class.
* * \PDO::FETCH_FUNC: Returns the results of calling the specified function, using each row's
* columns as parameters in the call.
* @param array|null $ctorArgs Controls how the next row will be returned to the caller.
* The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
* defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
* @param int|null $fetchMode Controls how the next row will be returned to the caller.
* The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
* defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
* @param int|null $fetchArgument This argument has a different meaning depending on the value of the $fetchMode parameter:
* * {@link \Doctrine\DBAL\FetchMode::COLUMN}:
* Returns the indicated 0-indexed column.
* * {@link \Doctrine\DBAL\FetchMode::CUSTOM_OBJECT}:
* Returns instances of the specified class, mapping the columns of each row
* to named properties in the class.
* * \PDO::FETCH_FUNC: Returns the results of calling the specified function, using each row's
* columns as parameters in the call.
* @param mixed[]|null $ctorArgs Controls how the next row will be returned to the caller.
* The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
* defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
*
* @return array
* @return mixed[]
*/
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null);
......@@ -90,10 +90,9 @@ interface ResultStatement extends Traversable
* Returns a single column from the next row of a result set or FALSE if there are no more rows.
*
* @param int $columnIndex 0-indexed number of the column you wish to retrieve from the row.
* If no value is supplied, PDOStatement->fetchColumn()
* fetches the first column.
* If no value is supplied, fetches the first column.
*
* @return string|bool A single column in the next row of a result set, or FALSE if there are no more rows.
* @return mixed|false A single column in the next row of a result set, or FALSE if there are no more rows.
*/
public function fetchColumn($columnIndex = 0);
}
......@@ -18,7 +18,7 @@ class Driver extends AbstractSQLAnywhereDriver
/**
* {@inheritdoc}
*
* @throws DBALException if there was a problem establishing the connection.
* @throws DBALException If there was a problem establishing the connection.
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
......@@ -51,15 +51,15 @@ class Driver extends AbstractSQLAnywhereDriver
/**
* Build the connection string for given connection parameters and driver options.
*
* @param string $host Host address to connect to.
* @param int $port Port to use for the connection (default to SQL Anywhere standard port 2638).
* @param string $server Database server name on the host to connect to.
* SQL Anywhere allows multiple database server instances on the same host,
* therefore specifying the server instance name to use is mandatory.
* @param string $dbname Name of the database on the server instance to connect to.
* @param string $username User name to use for connection authentication.
* @param string $password Password to use for connection authentication.
* @param array $driverOptions Additional parameters to use for the connection.
* @param string $host Host address to connect to.
* @param int $port Port to use for the connection (default to SQL Anywhere standard port 2638).
* @param string $server Database server name on the host to connect to.
* SQL Anywhere allows multiple database server instances on the same host,
* therefore specifying the server instance name to use is mandatory.
* @param string $dbname Name of the database on the server instance to connect to.
* @param string $username User name to use for connection authentication.
* @param string $password Password to use for connection authentication.
* @param mixed[] $driverOptions Additional parameters to use for the connection.
*
* @return string
*/
......
......@@ -315,7 +315,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*
* @param stdClass $sourceObject Object to cast from.
* @param string|object $destinationClass Name of the class or class instance to cast to.
* @param array $ctorArgs Arguments to use for constructing the destination class instance.
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
*
* @return object
*
......
......@@ -33,8 +33,8 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
protected $lastInsertId;
/**
* @param string $serverName
* @param array $connectionOptions
* @param string $serverName
* @param mixed[] $connectionOptions
*
* @throws SQLSrvException
*/
......
......@@ -63,21 +63,21 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
* References to the variables bound as statement parameters.
*
* @var array
* @var mixed
*/
private $variables = [];
/**
* Bound parameter types.
*
* @var array
* @var int[]
*/
private $types = [];
/**
* Translations.
*
* @var array
* @var int[]
*/
private static $fetchMap = [
FetchMode::MIXED => SQLSRV_FETCH_BOTH,
......@@ -271,8 +271,8 @@ class SQLSrvStatement implements IteratorAggregate, Statement
$params[$column - 1] = [
&$variable,
SQLSRV_PARAM_IN,
sqlsrv_phptype_stream(SQLSRV_ENC_BINARY),
sqlsrv_sqltype_varbinary('max'),
SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY),
SQLSRV_SQLTYPE_VARBINARY('max'),
];
break;
......@@ -280,7 +280,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
$params[$column - 1] = [
&$variable,
SQLSRV_PARAM_IN,
sqlsrv_phptype_string(SQLSRV_ENC_BINARY),
SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_BINARY),
];
break;
......
......@@ -72,9 +72,7 @@ interface Statement extends ResultStatement
/**
* Fetches extended error information associated with the last operation on the statement handle.
*
* @see Doctrine_Adapter_Interface::errorInfo()
*
* @return array The error info array.
* @return mixed[] The error info array.
*/
public function errorInfo();
......@@ -87,8 +85,8 @@ interface Statement extends ResultStatement
* if any, of their associated parameter markers or pass an array of input-only
* parameter values.
*
* @param array|null $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
* @param mixed[]|null $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
*
* @return bool TRUE on success or FALSE on failure.
*/
......
......@@ -28,7 +28,7 @@ final class DriverManager
* To add your own driver use the 'driverClass' parameter to
* {@link DriverManager::getConnection()}.
*
* @var array
* @var string[]
*/
private static $_driverMap = [
'pdo_mysql' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
......@@ -46,6 +46,8 @@ final class DriverManager
/**
* List of URL schemes from a database URL and their mappings to driver.
*
* @var string[]
*/
private static $driverSchemeAliases = [
'db2' => 'ibm_db2',
......@@ -113,7 +115,7 @@ final class DriverManager
* <b>driverClass</b>:
* The driver class to use.
*
* @param array $params The parameters.
* @param mixed[] $params The parameters.
* @param Configuration|null $config The configuration to use.
* @param EventManager|null $eventManager The event manager to use.
*
......@@ -185,7 +187,7 @@ final class DriverManager
/**
* Returns the list of supported drivers.
*
* @return array
* @return string[]
*/
public static function getAvailableDrivers() : array
{
......@@ -195,7 +197,7 @@ final class DriverManager
/**
* Checks the list of parameters.
*
* @param array $params The list of parameters.
* @param mixed[] $params The list of parameters.
*
* @throws DBALException
*/
......@@ -235,10 +237,10 @@ final class DriverManager
* Extracts parts from a database URL, if present, and returns an
* updated list of parameters.
*
* @param array $params The list of parameters.
* @param mixed[] $params The list of parameters.
*
* @return array A modified list of parameters with info from a database
* URL extracted into indidivual parameter parts.
* @return mixed[] A modified list of parameters with info from a database
* URL extracted into indidivual parameter parts.
*
* @throws DBALException
*/
......@@ -291,10 +293,10 @@ final class DriverManager
*
* @see parseDatabaseUrlScheme
*
* @param array $url The URL parts to evaluate.
* @param array $params The connection parameters to resolve.
* @param mixed[] $url The URL parts to evaluate.
* @param mixed[] $params The connection parameters to resolve.
*
* @return array The resolved connection parameters.
* @return mixed[] The resolved connection parameters.
*/
private static function parseDatabaseUrlPath(array $url, array $params) : array
{
......@@ -320,10 +322,10 @@ final class DriverManager
/**
* Parses the query part of the given connection URL and resolves the given connection parameters.
*
* @param array $url The connection URL parts to evaluate.
* @param array $params The connection parameters to resolve.
* @param mixed[] $url The connection URL parts to evaluate.
* @param mixed[] $params The connection parameters to resolve.
*
* @return array The resolved connection parameters.
* @return mixed[] The resolved connection parameters.
*/
private static function parseDatabaseUrlQuery(array $url, array $params) : array
{
......@@ -345,10 +347,10 @@ final class DriverManager
*
* @see normalizeDatabaseUrlPath
*
* @param array $url The regular connection URL parts to evaluate.
* @param array $params The connection parameters to resolve.
* @param mixed[] $url The regular connection URL parts to evaluate.
* @param mixed[] $params The connection parameters to resolve.
*
* @return array The resolved connection parameters.
* @return mixed[] The resolved connection parameters.
*/
private static function parseRegularDatabaseUrlPath(array $url, array $params) : array
{
......@@ -364,10 +366,10 @@ final class DriverManager
*
* @see normalizeDatabaseUrlPath
*
* @param array $url The SQLite connection URL parts to evaluate.
* @param array $params The connection parameters to resolve.
* @param mixed[] $url The SQLite connection URL parts to evaluate.
* @param mixed[] $params The connection parameters to resolve.
*
* @return array The resolved connection parameters.
* @return mixed[] The resolved connection parameters.
*/
private static function parseSqliteDatabaseUrlPath(array $url, array $params) : array
{
......@@ -385,12 +387,12 @@ final class DriverManager
/**
* Parses the scheme part from given connection URL and resolves the given connection parameters.
*
* @param array $url The connection URL parts to evaluate.
* @param array $params The connection parameters to resolve.
* @param mixed[] $url The connection URL parts to evaluate.
* @param mixed[] $params The connection parameters to resolve.
*
* @return array The resolved connection parameters.
* @return mixed[] The resolved connection parameters.
*
* @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
{
......
......@@ -25,7 +25,7 @@ use function implode;
*/
class OracleSessionInit implements EventSubscriber
{
/** @var array */
/** @var string[] */
protected $_defaultSessionVars = [
'NLS_TIME_FORMAT' => 'HH24:MI:SS',
'NLS_DATE_FORMAT' => 'YYYY-MM-DD HH24:MI:SS',
......@@ -35,7 +35,7 @@ class OracleSessionInit implements EventSubscriber
];
/**
* @param array $oracleSessionVars
* @param string[] $oracleSessionVars
*/
public function __construct(array $oracleSessionVars = [])
{
......
......@@ -24,7 +24,7 @@ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs
/** @var AbstractPlatform */
private $_platform;
/** @var array */
/** @var string[] */
private $_sql = [];
public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatform $platform)
......@@ -59,7 +59,7 @@ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs
}
/**
* @param string|array $sql
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs
*/
......@@ -75,7 +75,7 @@ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs
}
/**
* @return array
* @return string[]
*/
public function getSql()
{
......
......@@ -24,7 +24,7 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
/** @var AbstractPlatform */
private $_platform;
/** @var array */
/** @var string[] */
private $_sql = [];
public function __construct(ColumnDiff $columnDiff, TableDiff $tableDiff, AbstractPlatform $platform)
......@@ -59,7 +59,7 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
}
/**
* @param string|array $sql
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
*/
......@@ -75,7 +75,7 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
}
/**
* @return array
* @return string[]
*/
public function getSql()
{
......
......@@ -20,7 +20,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs
/** @var AbstractPlatform */
private $_platform;
/** @var array */
/** @var string[] */
private $_sql = [];
public function __construct(TableDiff $tableDiff, AbstractPlatform $platform)
......@@ -46,7 +46,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs
}
/**
* @param string|array $sql
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableEventArgs
*/
......@@ -62,7 +62,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs
}
/**
* @return array
* @return string[]
*/
public function getSql()
{
......
......@@ -24,7 +24,7 @@ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs
/** @var AbstractPlatform */
private $_platform;
/** @var array */
/** @var string[] */
private $_sql = [];
public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatform $platform)
......@@ -59,7 +59,7 @@ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs
}
/**
* @param string|array $sql
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs
*/
......@@ -75,7 +75,7 @@ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs
}
/**
* @return array
* @return string[]
*/
public function getSql()
{
......
......@@ -27,7 +27,7 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
/** @var AbstractPlatform */
private $_platform;
/** @var array */
/** @var string[] */
private $_sql = [];
/**
......@@ -74,7 +74,7 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
}
/**
* @param string|array $sql
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs
*/
......@@ -90,7 +90,7 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
}
/**
* @return array
* @return string[]
*/
public function getSql()
{
......
......@@ -19,7 +19,7 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
/**
* Raw column data as fetched from the database.
*
* @var array
* @var mixed[]
*/
private $_tableColumn;
......@@ -33,9 +33,9 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
private $_connection;
/**
* @param array $tableColumn
* @param string $table
* @param string $database
* @param mixed[] $tableColumn
* @param string $table
* @param string $database
*/
public function __construct(array $tableColumn, $table, $database, Connection $connection)
{
......@@ -67,7 +67,7 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
}
/**
* @return array
* @return mixed[]
*/
public function getTableColumn()
{
......
......@@ -24,7 +24,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
/** @var AbstractPlatform */
private $_platform;
/** @var array */
/** @var string[] */
private $_sql = [];
public function __construct(Column $column, Table $table, AbstractPlatform $platform)
......@@ -59,7 +59,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
}
/**
* @param string|array $sql
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs
*/
......@@ -75,7 +75,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
}
/**
* @return array
* @return string[]
*/
public function getSql()
{
......
......@@ -3,6 +3,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 is_array;
......@@ -17,21 +18,21 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
/** @var Table */
private $_table;
/** @var array */
/** @var Column[] */
private $_columns;
/** @var array */
/** @var mixed[] */
private $_options;
/** @var AbstractPlatform */
private $_platform;
/** @var array */
/** @var string[] */
private $_sql = [];
/**
* @param array $columns
* @param array $options
* @param Column[] $columns
* @param mixed[] $options
*/
public function __construct(Table $table, array $columns, array $options, AbstractPlatform $platform)
{
......@@ -50,7 +51,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
}
/**
* @return array
* @return Column[]
*/
public function getColumns()
{
......@@ -58,7 +59,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
}
/**
* @return array
* @return mixed[]
*/
public function getOptions()
{
......@@ -74,7 +75,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
}
/**
* @param string|array $sql
* @param string|string[] $sql
*
* @return \Doctrine\DBAL\Event\SchemaCreateTableEventArgs
*/
......@@ -90,7 +91,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
}
/**
* @return array
* @return string[]
*/
public function getSql()
{
......
......@@ -19,7 +19,7 @@ class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
/**
* Raw index data as fetched from the database.
*
* @var array
* @var mixed[]
*/
private $_tableIndex;
......@@ -30,8 +30,8 @@ class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
private $_connection;
/**
* @param array $tableIndex
* @param string $table
* @param mixed[] $tableIndex
* @param string $table
*/
public function __construct(array $tableIndex, $table, Connection $connection)
{
......@@ -61,7 +61,7 @@ class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
}
/**
* @return array
* @return mixed[]
*/
public function getTableIndex()
{
......
......@@ -56,7 +56,7 @@ class TableGenerator
/** @var string */
private $generatorTableName;
/** @var array */
/** @var mixed[][] */
private $sequences = [];
/**
......
......@@ -14,7 +14,7 @@ class DebugStack implements SQLLogger
/**
* Executed SQL queries.
*
* @var array
* @var mixed[][]
*/
public $queries = [];
......
......@@ -12,9 +12,9 @@ interface SQLLogger
/**
* Logs a SQL statement somewhere.
*
* @param string $sql The SQL to be executed.
* @param array|null $params The SQL parameters.
* @param array|null $types The SQL parameter types.
* @param string $sql The SQL to be executed.
* @param mixed[]|null $params The SQL parameters.
* @param int[]|string[]|null $types The SQL parameter types.
*
* @return void
*/
......
......@@ -618,8 +618,8 @@ class DB2Platform extends AbstractPlatform
*
* @param Table $table The table to gather the SQL for.
* @param ColumnDiff $columnDiff The column diff to evaluate.
* @param array $sql The sequence of table alteration statements to fill.
* @param array $queryParts The sequence of column alteration clauses to fill.
* @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(Table $table, ColumnDiff $columnDiff, array &$sql, array &$queryParts)
{
......@@ -649,7 +649,7 @@ class DB2Platform extends AbstractPlatform
*
* @param ColumnDiff $columnDiff The column diff to evaluate.
*
* @return array
* @return string[]
*/
private function getAlterColumnClausesSQL(ColumnDiff $columnDiff)
{
......
......@@ -19,7 +19,6 @@ use function is_array;
use function is_bool;
use function is_numeric;
use function is_string;
use function join;
use function sprintf;
use function trim;
......@@ -51,7 +50,7 @@ class DrizzlePlatform extends AbstractPlatform
{
$args = func_get_args();
return 'CONCAT(' . join(', ', (array) $args) . ')';
return 'CONCAT(' . implode(', ', (array) $args) . ')';
}
/**
......@@ -237,7 +236,7 @@ class DrizzlePlatform extends AbstractPlatform
/**
* Build SQL for table options
*
* @param array $options
* @param mixed[] $options
*
* @return string
*/
......@@ -286,7 +285,7 @@ class DrizzlePlatform extends AbstractPlatform
/**
* Build SQL for partition options.
*
* @param array $options
* @param mixed[] $options
*
* @return string
*/
......
......@@ -13,7 +13,7 @@ use function strtoupper;
*/
abstract class KeywordList
{
/** @var array|null */
/** @var string[]|null */
private $keywords = null;
/**
......@@ -43,7 +43,7 @@ abstract class KeywordList
/**
* Returns the list of keywords.
*
* @return array
* @return string[]
*/
abstract protected function getKeywords();
......
......@@ -17,7 +17,7 @@ class ReservedKeywordsValidator implements Visitor
/** @var KeywordList[] */
private $keywordLists = [];
/** @var array */
/** @var string[] */
private $violations = [];
/**
......@@ -29,7 +29,7 @@ class ReservedKeywordsValidator implements Visitor
}
/**
* @return array
* @return string[]
*/
public function getViolations()
{
......@@ -39,7 +39,7 @@ class ReservedKeywordsValidator implements Visitor
/**
* @param string $word
*
* @return array
* @return string[]
*/
private function isReservedWord($word)
{
......@@ -60,8 +60,8 @@ class ReservedKeywordsValidator implements Visitor
}
/**
* @param string $asset
* @param array $violatedPlatforms
* @param string $asset
* @param string[] $violatedPlatforms
*
* @return void
*/
......
......@@ -22,7 +22,6 @@ use function implode;
use function in_array;
use function is_numeric;
use function is_string;
use function join;
use function sprintf;
use function str_replace;
use function strtoupper;
......@@ -107,9 +106,7 @@ class MySqlPlatform extends AbstractPlatform
*/
public function getConcatExpression()
{
$args = func_get_args();
return 'CONCAT(' . join(', ', (array) $args) . ')';
return sprintf('CONCAT(%s)', implode(', ', func_get_args()));
}
/**
......@@ -194,11 +191,11 @@ class MySqlPlatform extends AbstractPlatform
'FROM information_schema.key_column_usage k /*!50116 ' .
'INNER JOIN information_schema.referential_constraints c ON ' .
' c.constraint_name = k.constraint_name AND ' .
" c.table_name = $table */ WHERE k.table_name = $table";
' c.table_name = ' . $table . ' */ WHERE k.table_name = ' . $table;
$databaseNameSql = $database ?? 'DATABASE()';
$sql .= " AND k.table_schema = $databaseNameSql /*!50116 AND c.constraint_schema = $databaseNameSql */";
$sql .= ' AND k.table_schema = ' . $databaseNameSql . ' /*!50116 AND c.constraint_schema = ' . $databaseNameSql . ' */';
$sql .= ' AND k.`REFERENCED_COLUMN_NAME` is not NULL';
return $sql;
......@@ -244,9 +241,7 @@ class MySqlPlatform extends AbstractPlatform
* MEDIUMTEXT : 2 ^ 24 - 1 = 16777215
* LONGTEXT : 2 ^ 32 - 1 = 4294967295
*
* @param array $field
*
* @return string
* {@inheritDoc}
*/
public function getClobTypeDeclarationSQL(array $field)
{
......@@ -470,7 +465,7 @@ class MySqlPlatform extends AbstractPlatform
/**
* Build SQL for table options
*
* @param array $options
* @param mixed[] $options
*
* @return string
*/
......@@ -526,7 +521,7 @@ class MySqlPlatform extends AbstractPlatform
/**
* Build SQL for partition options.
*
* @param array $options
* @param mixed[] $options
*
* @return string
*/
......@@ -724,7 +719,7 @@ class MySqlPlatform extends AbstractPlatform
/**
* @param TableDiff $diff The table diff to gather the SQL for.
*
* @return array
* @return string[]
*/
private function getPreAlterTableAlterIndexForeignKeySQL(TableDiff $diff)
{
......@@ -764,7 +759,7 @@ class MySqlPlatform extends AbstractPlatform
/**
* @param TableDiff $diff The table diff to gather the SQL for.
*
* @return array
* @return string[]
*/
protected function getPreAlterTableRenameIndexForeignKeySQL(TableDiff $diff)
{
......@@ -790,7 +785,7 @@ class MySqlPlatform extends AbstractPlatform
*
* @param TableDiff $diff The table diff to evaluate.
*
* @return array
* @return ForeignKeyConstraint[]
*/
private function getRemainingForeignKeyConstraintsRequiringRenamedIndexes(TableDiff $diff)
{
......@@ -832,7 +827,7 @@ class MySqlPlatform extends AbstractPlatform
/**
* @param TableDiff $diff The table diff to gather the SQL for.
*
* @return array
* @return string[]
*/
protected function getPostAlterTableRenameIndexForeignKeySQL(TableDiff $diff)
{
......@@ -912,7 +907,7 @@ class MySqlPlatform extends AbstractPlatform
/**
* Get unsigned declaration for a column.
*
* @param array $columnDef
* @param mixed[] $columnDef
*
* @return string
*/
......@@ -1097,9 +1092,7 @@ class MySqlPlatform extends AbstractPlatform
* MEDIUMBLOB : 2 ^ 24 - 1 = 16777215
* LONGBLOB : 2 ^ 32 - 1 = 4294967295
*
* @param array $field
*
* @return string
* {@inheritDoc}
*/
public function getBlobTypeDeclarationSQL(array $field)
{
......
......@@ -54,10 +54,10 @@ class OraclePlatform extends AbstractPlatform
public function getSubstringExpression($value, $position, $length = null)
{
if ($length !== null) {
return "SUBSTR($value, $position, $length)";
return sprintf('SUBSTR(%s, %d, %d)', $value, $position, $length);
}
return "SUBSTR($value, $position)";
return sprintf('SUBSTR(%s, %d)', $value, $position);
}
/**
......@@ -478,7 +478,7 @@ class OraclePlatform extends AbstractPlatform
* @param string $table
* @param int $start
*
* @return array
* @return string[]
*/
public function getCreateAutoincrementSql($name, $table, $start = 1)
{
......@@ -542,7 +542,7 @@ END;';
*
* @param string $table The table name to drop the autoincrement for.
*
* @return array
* @return string[]
*/
public function getDropAutoincrementSql($table)
{
......@@ -657,20 +657,30 @@ END;';
$database = $this->quoteStringLiteral($database->getName());
$tabColumnsTableName = 'all_tab_columns';
$colCommentsTableName = 'all_col_comments';
$tabColumnsOwnerCondition = 'AND c.owner = ' . $database;
$colCommentsOwnerCondition = 'AND d.OWNER = c.OWNER';
$tabColumnsOwnerCondition = ' AND c.owner = ' . $database;
$colCommentsOwnerCondition = ' AND d.OWNER = c.OWNER';
}
return "SELECT c.*,
(
SELECT d.comments
FROM $colCommentsTableName d
WHERE d.TABLE_NAME = c.TABLE_NAME " . $colCommentsOwnerCondition . "
AND d.COLUMN_NAME = c.COLUMN_NAME
) AS comments
FROM $tabColumnsTableName c
WHERE c.table_name = " . $table . " $tabColumnsOwnerCondition
ORDER BY c.column_id";
return sprintf(
<<<'SQL'
SELECT c.*,
(
SELECT d.comments
FROM %s d
WHERE d.TABLE_NAME = c.TABLE_NAME%s
AND d.COLUMN_NAME = c.COLUMN_NAME
) AS comments
FROM %s c
WHERE c.table_name = %s%s
ORDER BY c.column_id
SQL
,
$colCommentsTableName,
$colCommentsOwnerCondition,
$tabColumnsTableName,
$table,
$tabColumnsOwnerCondition
);
}
/**
......@@ -767,7 +777,9 @@ END;';
}
$fields[] = $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
if (! $comment = $this->getColumnComment($column)) {
$comment = $this->getColumnComment($column);
if (! $comment) {
continue;
}
......
......@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\Types\Type;
use function sprintf;
/**
* Provides the behavior, features and SQL dialect of the PostgreSQL 9.2 database platform.
......@@ -62,8 +63,9 @@ class PostgreSQL92Platform extends PostgreSQL91Platform
*/
public function getCloseActiveDatabaseConnectionsSQL($database)
{
$database = $this->quoteStringLiteral($database);
return "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = $database";
return sprintf(
'SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = %s',
$this->quoteStringLiteral($database)
);
}
}
......@@ -27,6 +27,7 @@ use function is_array;
use function is_bool;
use function is_numeric;
use function is_string;
use function sprintf;
use function str_replace;
use function strpos;
use function strtolower;
......@@ -42,7 +43,7 @@ class PostgreSqlPlatform extends AbstractPlatform
/** @var bool */
private $useBooleanTrueFalseStrings = true;
/** @var array PostgreSQL booleans literals */
/** @var string[][] PostgreSQL booleans literals */
private $booleanLiterals = [
'true' => [
't',
......@@ -316,17 +317,23 @@ class PostgreSqlPlatform extends AbstractPlatform
$table = new Identifier($table);
$table = $this->quoteStringLiteral($table->getName());
return "SELECT
quote_ident(relname) as relname
FROM
pg_class
WHERE oid IN (
SELECT indexrelid
FROM pg_index, pg_class
WHERE pg_class.relname = $table
AND pg_class.oid = pg_index.indrelid
AND (indisunique = 't' OR indisprimary = 't')
)";
return sprintf(
<<<'SQL'
SELECT
quote_ident(relname) as relname
FROM
pg_class
WHERE oid IN (
SELECT indexrelid
FROM pg_index, pg_class
WHERE pg_class.relname = %s
AND pg_class.oid = pg_index.indrelid
AND (indisunique = 't' OR indisprimary = 't')
)
SQL
,
$table
);
}
/**
......@@ -366,7 +373,14 @@ class PostgreSqlPlatform extends AbstractPlatform
$table = new Identifier($table);
$table = $this->quoteStringLiteral($table->getName());
return $whereClause . "$classAlias.relname = " . $table . " AND $namespaceAlias.nspname = $schema";
return $whereClause . sprintf(
'%s.relname = %s AND %s.nspname = %s',
$classAlias,
$table,
$namespaceAlias,
$schema
);
}
/**
......@@ -425,7 +439,7 @@ class PostgreSqlPlatform extends AbstractPlatform
*/
public function getDisallowDatabaseConnectionsSQL($database)
{
return "UPDATE pg_database SET datallowconn = 'false' WHERE datname = '$database'";
return "UPDATE pg_database SET datallowconn = 'false' WHERE datname = '" . $database . "'";
}
/**
......@@ -439,9 +453,8 @@ class PostgreSqlPlatform extends AbstractPlatform
*/
public function getCloseActiveDatabaseConnectionsSQL($database)
{
$database = $this->quoteStringLiteral($database);
return "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = $database";
return 'SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = '
. $this->quoteStringLiteral($database);
}
/**
......@@ -562,7 +575,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . $query;
} else {
// Drop autoincrement, but do NOT drop the sequence. It might be re-used by other tables or have
$query = 'ALTER ' . $oldColumnName . ' ' . 'DROP DEFAULT';
$query = 'ALTER ' . $oldColumnName . ' DROP DEFAULT';
$sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . $query;
}
}
......@@ -676,8 +689,12 @@ class PostgreSqlPlatform extends AbstractPlatform
$columnName = new Identifier($columnName);
$comment = $comment === null ? 'NULL' : $this->quoteStringLiteral($comment);
return 'COMMENT ON COLUMN ' . $tableName->getQuotedName($this) . '.' . $columnName->getQuotedName($this) .
" IS $comment";
return sprintf(
'COMMENT ON COLUMN %s.%s IS %s',
$tableName->getQuotedName($this),
$columnName->getQuotedName($this),
$comment
);
}
/**
......@@ -1201,6 +1218,9 @@ class PostgreSqlPlatform extends AbstractPlatform
return parent::getDefaultValueDeclarationSQL($field);
}
/**
* @param mixed[] $field
*/
private function isSerialField(array $field) : bool
{
return $field['autoincrement'] ?? false === true && isset($field['type'])
......
......@@ -225,10 +225,20 @@ class SQLServerPlatform extends AbstractPlatform
$table = $table->getQuotedName($this);
}
return "IF EXISTS (SELECT * FROM sysobjects WHERE name = '$index')
ALTER TABLE " . $table . ' DROP CONSTRAINT ' . $index . '
ELSE
DROP INDEX ' . $index . ' ON ' . $table;
return sprintf(
<<<SQL
IF EXISTS (SELECT * FROM sysobjects WHERE name = '%s')
ALTER TABLE %s DROP CONSTRAINT %s
ELSE
DROP INDEX %s ON %s
SQL
,
$index,
$table,
$index,
$index,
$table
);
}
/**
......@@ -356,8 +366,8 @@ class SQLServerPlatform extends AbstractPlatform
/**
* Returns the SQL snippet for declaring a default constraint.
*
* @param string $table Name of the table to return the default constraint declaration for.
* @param array $column Column definition.
* @param string $table Name of the table to return the default constraint declaration for.
* @param mixed[] $column Column definition.
*
* @return string
*
......@@ -513,8 +523,6 @@ class SQLServerPlatform extends AbstractPlatform
$comment
);
}
} else {
// todo: Original comment cannot be determined. What to do? Add, update, drop or skip?
}
// Do not add query part if only comment has changed.
......@@ -995,7 +1003,7 @@ class SQLServerPlatform extends AbstractPlatform
$table = $this->quoteStringLiteral($table);
}
return "({$tableColumn} = {$table} AND {$schemaColumn} = {$schema})";
return sprintf('(%s = %s AND %s = %s)', $tableColumn, $table, $schemaColumn, $schema);
}
/**
......@@ -1067,7 +1075,7 @@ class SQLServerPlatform extends AbstractPlatform
, reverse(stuff(reverse(@c), 1, patindex(@pat, reverse(@c)) - 1, null)) as trim_trailing
, reverse(stuff(reverse(stuff(@c, 1, patindex(@pat, @c) - 1, null)), 1, patindex(@pat, reverse(stuff(@c, 1, patindex(@pat, @c) - 1, null))) - 1, null)) as trim_both;
*/
$pattern = "'%[^' + $char + ']%'";
$pattern = "'%[^' + " . $char . " + ']%'";
if ($pos === TrimMode::LEADING) {
return 'stuff(' . $str . ', 1, patindex(' . $pattern . ', ' . $str . ') - 1, null)';
......
......@@ -423,9 +423,11 @@ class SqlitePlatform extends AbstractPlatform
public function getListTableConstraintsSQL($table)
{
$table = str_replace('.', '__', $table);
$table = $this->quoteStringLiteral($table);
return "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = $table AND sql NOT NULL ORDER BY name";
return sprintf(
"SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = %s AND sql NOT NULL ORDER BY name",
$this->quoteStringLiteral($table)
);
}
/**
......@@ -434,9 +436,8 @@ class SqlitePlatform extends AbstractPlatform
public function getListTableColumnsSQL($table, $currentDatabase = null)
{
$table = str_replace('.', '__', $table);
$table = $this->quoteStringLiteral($table);
return "PRAGMA table_info($table)";
return sprintf('PRAGMA table_info(%s)', $this->quoteStringLiteral($table));
}
/**
......@@ -445,9 +446,8 @@ class SqlitePlatform extends AbstractPlatform
public function getListTableIndexesSQL($table, $currentDatabase = null)
{
$table = str_replace('.', '__', $table);
$table = $this->quoteStringLiteral($table);
return "PRAGMA index_list($table)";
return sprintf('PRAGMA index_list(%s)', $this->quoteStringLiteral($table));
}
/**
......@@ -797,9 +797,8 @@ class SqlitePlatform extends AbstractPlatform
public function getListTableForeignKeysSQL($table, $database = null)
{
$table = str_replace('.', '__', $table);
$table = $this->quoteStringLiteral($table);
return "PRAGMA foreign_key_list($table)";
return sprintf('PRAGMA foreign_key_list(%s)', $this->quoteStringLiteral($table));
}
/**
......@@ -998,7 +997,7 @@ class SqlitePlatform extends AbstractPlatform
}
/**
* @return array
* @return string[]
*/
private function getColumnNamesInAlteredTable(TableDiff $diff)
{
......@@ -1097,7 +1096,7 @@ class SqlitePlatform extends AbstractPlatform
}
/**
* @return array
* @return ForeignKeyConstraint[]
*/
private function getForeignKeysInAlteredTable(TableDiff $diff)
{
......@@ -1149,7 +1148,7 @@ class SqlitePlatform extends AbstractPlatform
}
/**
* @return array
* @return Index[]
*/
private function getPrimaryIndexInAlteredTable(TableDiff $diff)
{
......
......@@ -181,7 +181,7 @@ class Statement implements IteratorAggregate, \Doctrine\DBAL\Driver\Statement
* @param int $iterateRow
* @param bool $fixCase
*
* @return array
* @return mixed
*/
protected function fixRow($row, $iterateRow, $fixCase)
{
......
......@@ -33,13 +33,13 @@ class CompositeExpression implements Countable
/**
* Each expression part of the composite expression.
*
* @var array
* @var self[]|string[]
*/
private $parts = [];
/**
* @param string $type Instance type of composite expression.
* @param array $parts Composition of expressions to be joined on composite expression.
* @param string $type Instance type of composite expression.
* @param self[]|string[] $parts Composition of expressions to be joined on composite expression.
*/
public function __construct($type, array $parts = [])
{
......@@ -51,7 +51,7 @@ class CompositeExpression implements Countable
/**
* Adds multiple parts to composite expression.
*
* @param array $parts
* @param self[]|string[] $parts
*
* @return \Doctrine\DBAL\Query\Expression\CompositeExpression
*/
......
......@@ -262,8 +262,8 @@ class ExpressionBuilder
/**
* Creates a IN () comparison expression with the given arguments.
*
* @param string $x The field in string format to be inspected by IN() comparison.
* @param string|array $y The placeholder or the array of values to be used by IN() comparison.
* @param string $x The field in string format to be inspected by IN() comparison.
* @param string|string[] $y The placeholder or the array of values to be used by IN() comparison.
*
* @return string
*/
......@@ -275,8 +275,8 @@ class ExpressionBuilder
/**
* Creates a NOT IN () comparison expression with the given arguments.
*
* @param string $x The field in string format to be inspected by NOT IN() comparison.
* @param string|array $y The placeholder or the array of values to be used by NOT IN() comparison.
* @param string $x The field in string format to be inspected by NOT IN() comparison.
* @param string|string[] $y The placeholder or the array of values to be used by NOT IN() comparison.
*
* @return string
*/
......
......@@ -54,7 +54,11 @@ class QueryBuilder
*/
private $connection;
/** @var array The array of SQL parts collected. */
/**
* The array of SQL parts collected.
*
* @var mixed[]
*/
private $sqlParts = [
'select' => [],
'from' => [],
......@@ -77,14 +81,14 @@ class QueryBuilder
/**
* The query parameters.
*
* @var array
* @var mixed[]
*/
private $params = [];
/**
* The parameter type map of this query.
*
* @var array
* @var int[]|string[]
*/
private $paramTypes = [];
......@@ -285,8 +289,8 @@ class QueryBuilder
* ));
* </code>
*
* @param array $params The query parameters to set.
* @param array $types The query parameters types to set.
* @param mixed[] $params The query parameters to set.
* @param int[]|string[] $types The query parameters types to set.
*
* @return $this This QueryBuilder instance.
*/
......@@ -301,7 +305,7 @@ class QueryBuilder
/**
* Gets all defined query parameters for the query being constructed indexed by parameter index or name.
*
* @return array The currently defined query parameters indexed by parameter index or name.
* @return mixed[] The currently defined query parameters indexed by parameter index or name.
*/
public function getParameters()
{
......@@ -323,7 +327,7 @@ class QueryBuilder
/**
* Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
*
* @return array The currently defined query parameter types indexed by parameter index or name.
* @return int[]|string[] The currently defined query parameter types indexed by parameter index or name.
*/
public function getParameterTypes()
{
......@@ -582,9 +586,7 @@ class QueryBuilder
return $this;
}
return $this->add('from', [
'table' => $insert,
]);
return $this->add('from', ['table' => $insert]);
}
/**
......@@ -934,7 +936,7 @@ class QueryBuilder
* );
* </code>
*
* @param array $values The values to specify for the insert query indexed by column names.
* @param mixed[] $values The values to specify for the insert query indexed by column names.
*
* @return $this This QueryBuilder instance.
*/
......@@ -1048,7 +1050,7 @@ class QueryBuilder
/**
* Gets all query parts.
*
* @return array
* @return mixed[]
*/
public function getQueryParts()
{
......@@ -1058,7 +1060,7 @@ class QueryBuilder
/**
* Resets SQL parts.
*
* @param array|null $queryPartNames
* @param string[]|null $queryPartNames
*
* @return $this This QueryBuilder instance.
*/
......@@ -1147,7 +1149,7 @@ class QueryBuilder
}
/**
* @param array $knownAliases
* @param string[] $knownAliases
*
* @throws QueryException
*/
......@@ -1285,8 +1287,8 @@ class QueryBuilder
}
/**
* @param string $fromAlias
* @param array $knownAliases
* @param string $fromAlias
* @param string[] $knownAliases
*
* @return string
*
......
......@@ -8,8 +8,8 @@ use function implode;
class QueryException extends DBALException
{
/**
* @param string $alias
* @param array $registeredAliases
* @param string $alias
* @param string[] $registeredAliases
*
* @return \Doctrine\DBAL\Query\QueryException
*/
......@@ -21,8 +21,8 @@ class QueryException extends DBALException
}
/**
* @param string $alias
* @param array $registeredAliases
* @param string $alias
* @param string[] $registeredAliases
*
* @return \Doctrine\DBAL\Query\QueryException
*/
......
......@@ -43,7 +43,7 @@ class SQLParserUtils
* @param string $statement
* @param bool $isPositional
*
* @return array
* @return int[]
*/
public static function getPlaceholderPositions($statement, $isPositional = true)
{
......@@ -56,7 +56,7 @@ class SQLParserUtils
$paramMap = [];
foreach (self::getUnquotedStatementFragments($statement) as $fragment) {
preg_match_all("/$token/", $fragment[0], $matches, PREG_OFFSET_CAPTURE);
preg_match_all('/' . $token . '/', $fragment[0], $matches, PREG_OFFSET_CAPTURE);
foreach ($matches[0] as $placeholder) {
if ($isPositional) {
$paramMap[] = $placeholder[1] + $fragment[1];
......@@ -73,11 +73,11 @@ class SQLParserUtils
/**
* For a positional query this method can rewrite the sql statement with regard to array parameters.
*
* @param string $query The SQL query to execute.
* @param array $params The parameters to bind to the query.
* @param array $types The types the previous parameters are in.
* @param string $query The SQL query to execute.
* @param mixed[] $params The parameters to bind to the query.
* @param int[]|string[] $types The types the previous parameters are in.
*
* @return array
* @return mixed[]
*
* @throws SQLParserUtilsException
*/
......@@ -197,7 +197,7 @@ class SQLParserUtils
*
* @param string $statement
*
* @return array
* @return mixed[][]
*/
private static function getUnquotedStatementFragments($statement)
{
......@@ -205,14 +205,14 @@ class SQLParserUtils
self::ESCAPED_DOUBLE_QUOTED_TEXT . '|' .
self::ESCAPED_BACKTICK_QUOTED_TEXT . '|' .
self::ESCAPED_BRACKET_QUOTED_TEXT;
preg_match_all("/([^'\"`\[]+)(?:$literal)?/s", $statement, $fragments, PREG_OFFSET_CAPTURE);
preg_match_all('/([^\'"`\[]+)(?:' . $literal . ')?/s', $statement, $fragments, PREG_OFFSET_CAPTURE);
return $fragments[1];
}
/**
* @param string $paramName The name of the parameter (without a colon in front)
* @param array $paramsOrTypes A hash of parameters or types
* @param mixed $paramsOrTypes A hash of parameters or types
* @param bool $isParam
* @param mixed $defaultValue An optional default value. If omitted, an exception is thrown
*
......
......@@ -195,9 +195,9 @@ abstract class AbstractAsset
* however building idents automatically for foreign keys, composite keys or such can easily create
* very long names.
*
* @param array $columnNames
* @param string $prefix
* @param int $maxSize
* @param string[] $columnNames
* @param string $prefix
* @param int $maxSize
*
* @return string
*/
......
......@@ -90,7 +90,7 @@ abstract class AbstractSchemaManager
/**
* Lists the available databases for this connection.
*
* @return array
* @return string[]
*/
public function listDatabases()
{
......@@ -104,7 +104,7 @@ abstract class AbstractSchemaManager
/**
* Returns a list of all namespaces in the current database.
*
* @return array
* @return string[]
*/
public function listNamespaceNames()
{
......@@ -183,7 +183,7 @@ abstract class AbstractSchemaManager
/**
* Returns true if all the given tables exist.
*
* @param array $tableNames
* @param string[] $tableNames
*
* @return bool
*/
......@@ -197,7 +197,7 @@ abstract class AbstractSchemaManager
/**
* Returns a list of all tables in the current database.
*
* @return array
* @return string[]
*/
public function listTableNames()
{
......@@ -213,9 +213,9 @@ abstract class AbstractSchemaManager
* Filters asset names if they are configured to return only a subset of all
* the found elements.
*
* @param array $assetNames
* @param mixed[] $assetNames
*
* @return array
* @return mixed[]
*/
protected function filterAssetNames($assetNames)
{
......@@ -621,15 +621,17 @@ abstract class AbstractSchemaManager
*/
/**
* @param array $databases
* @param mixed[] $databases
*
* @return array
* @return string[]
*/
protected function _getPortableDatabasesList($databases)
{
$list = [];
foreach ($databases as $value) {
if (! $value = $this->_getPortableDatabaseDefinition($value)) {
$value = $this->_getPortableDatabaseDefinition($value);
if (! $value) {
continue;
}
......@@ -642,9 +644,9 @@ abstract class AbstractSchemaManager
/**
* Converts a list of namespace names from the native DBMS data definition to a portable Doctrine definition.
*
* @param array $namespaces The list of namespace names in the native DBMS data definition.
* @param mixed[][] $namespaces The list of namespace names in the native DBMS data definition.
*
* @return array
* @return string[]
*/
protected function getPortableNamespacesList(array $namespaces)
{
......@@ -658,7 +660,7 @@ abstract class AbstractSchemaManager
}
/**
* @param array $database
* @param mixed $database
*
* @return mixed
*/
......@@ -670,7 +672,7 @@ abstract class AbstractSchemaManager
/**
* Converts a namespace definition from the native DBMS data definition to a portable Doctrine definition.
*
* @param array $namespace The native DBMS namespace definition.
* @param mixed[] $namespace The native DBMS namespace definition.
*
* @return mixed
*/
......@@ -680,15 +682,17 @@ abstract class AbstractSchemaManager
}
/**
* @param array $functions
* @param mixed[][] $functions
*
* @return array
* @return mixed[][]
*/
protected function _getPortableFunctionsList($functions)
{
$list = [];
foreach ($functions as $value) {
if (! $value = $this->_getPortableFunctionDefinition($value)) {
$value = $this->_getPortableFunctionDefinition($value);
if (! $value) {
continue;
}
......@@ -699,7 +703,7 @@ abstract class AbstractSchemaManager
}
/**
* @param array $function
* @param mixed[] $function
*
* @return mixed
*/
......@@ -709,15 +713,17 @@ abstract class AbstractSchemaManager
}
/**
* @param array $triggers
* @param mixed[][] $triggers
*
* @return array
* @return mixed[][]
*/
protected function _getPortableTriggersList($triggers)
{
$list = [];
foreach ($triggers as $value) {
if (! $value = $this->_getPortableTriggerDefinition($value)) {
$value = $this->_getPortableTriggerDefinition($value);
if (! $value) {
continue;
}
......@@ -728,7 +734,7 @@ abstract class AbstractSchemaManager
}
/**
* @param array $trigger
* @param mixed[] $trigger
*
* @return mixed
*/
......@@ -738,15 +744,17 @@ abstract class AbstractSchemaManager
}
/**
* @param array $sequences
* @param mixed[][] $sequences
*
* @return array
* @return Sequence[]
*/
protected function _getPortableSequencesList($sequences)
{
$list = [];
foreach ($sequences as $value) {
if (! $value = $this->_getPortableSequenceDefinition($value)) {
$value = $this->_getPortableSequenceDefinition($value);
if (! $value) {
continue;
}
......@@ -757,7 +765,7 @@ abstract class AbstractSchemaManager
}
/**
* @param array $sequence
* @param mixed[] $sequence
*
* @return Sequence
*
......@@ -773,11 +781,11 @@ abstract class AbstractSchemaManager
*
* The name of the created column instance however is kept in its case.
*
* @param string $table The name of the table.
* @param string $database
* @param array $tableColumns
* @param string $table The name of the table.
* @param string $database
* @param mixed[][] $tableColumns
*
* @return array
* @return Column[]
*/
protected function _getPortableTableColumnList($table, $database, $tableColumns)
{
......@@ -814,7 +822,7 @@ abstract class AbstractSchemaManager
/**
* Gets Table Column Definition.
*
* @param array $tableColumn
* @param mixed[] $tableColumn
*
* @return Column
*/
......@@ -823,10 +831,10 @@ abstract class AbstractSchemaManager
/**
* Aggregates and groups the index results according to the required data result.
*
* @param array $tableIndexRows
* @param mixed[][] $tableIndexRows
* @param string|null $tableName
*
* @return array
* @return Index[]
*/
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null)
{
......@@ -882,15 +890,17 @@ abstract class AbstractSchemaManager
}
/**
* @param array $tables
* @param mixed[][] $tables
*
* @return array
* @return string[]
*/
protected function _getPortableTablesList($tables)
{
$list = [];
foreach ($tables as $value) {
if (! $value = $this->_getPortableTableDefinition($value)) {
$value = $this->_getPortableTableDefinition($value);
if (! $value) {
continue;
}
......@@ -901,9 +911,9 @@ abstract class AbstractSchemaManager
}
/**
* @param array $table
* @param mixed $table
*
* @return array
* @return string
*/
protected function _getPortableTableDefinition($table)
{
......@@ -911,15 +921,17 @@ abstract class AbstractSchemaManager
}
/**
* @param array $users
* @param mixed[][] $users
*
* @return array
* @return string[][]
*/
protected function _getPortableUsersList($users)
{
$list = [];
foreach ($users as $value) {
if (! $value = $this->_getPortableUserDefinition($value)) {
$value = $this->_getPortableUserDefinition($value);
if (! $value) {
continue;
}
......@@ -930,9 +942,9 @@ abstract class AbstractSchemaManager
}
/**
* @param array $user
* @param mixed[] $user
*
* @return mixed
* @return mixed[]
*/
protected function _getPortableUserDefinition($user)
{
......@@ -940,15 +952,17 @@ abstract class AbstractSchemaManager
}
/**
* @param array $views
* @param mixed[][] $views
*
* @return array
* @return View[]
*/
protected function _getPortableViewsList($views)
{
$list = [];
foreach ($views as $value) {
if (! $view = $this->_getPortableViewDefinition($value)) {
$view = $this->_getPortableViewDefinition($value);
if (! $view) {
continue;
}
......@@ -960,9 +974,9 @@ abstract class AbstractSchemaManager
}
/**
* @param array $view
* @param mixed[] $view
*
* @return mixed
* @return View|false
*/
protected function _getPortableViewDefinition($view)
{
......@@ -970,15 +984,17 @@ abstract class AbstractSchemaManager
}
/**
* @param array $tableForeignKeys
* @param mixed[][] $tableForeignKeys
*
* @return array
* @return ForeignKeyConstraint[]
*/
protected function _getPortableTableForeignKeysList($tableForeignKeys)
{
$list = [];
foreach ($tableForeignKeys as $value) {
if (! $value = $this->_getPortableTableForeignKeyDefinition($value)) {
$value = $this->_getPortableTableForeignKeyDefinition($value);
if (! $value) {
continue;
}
......@@ -989,9 +1005,9 @@ abstract class AbstractSchemaManager
}
/**
* @param array $tableForeignKey
* @param mixed $tableForeignKey
*
* @return mixed
* @return ForeignKeyConstraint
*/
protected function _getPortableTableForeignKeyDefinition($tableForeignKey)
{
......@@ -999,7 +1015,7 @@ abstract class AbstractSchemaManager
}
/**
* @param array|string $sql
* @param string[]|string $sql
*
* @return void
*/
......@@ -1071,7 +1087,7 @@ abstract class AbstractSchemaManager
* For databases that don't support subschema/namespaces this method
* returns the name of the currently connected database.
*
* @return array
* @return string[]
*/
public function getSchemaSearchPaths()
{
......
......@@ -44,7 +44,7 @@ class Column extends AbstractAsset
/** @var bool */
protected $_autoincrement = false;
/** @var array */
/** @var mixed[] */
protected $_platformOptions = [];
/** @var string|null */
......@@ -53,14 +53,14 @@ class Column extends AbstractAsset
/** @var string|null */
protected $_comment = null;
/** @var array */
/** @var mixed[] */
protected $_customSchemaOptions = [];
/**
* Creates a new Column.
*
* @param string $columnName
* @param array $options
* @param string $columnName
* @param mixed[] $options
*/
public function __construct($columnName, Type $type, array $options = [])
{
......@@ -70,7 +70,7 @@ class Column extends AbstractAsset
}
/**
* @param array $options
* @param mixed[] $options
*
* @return Column
*/
......@@ -201,7 +201,7 @@ class Column extends AbstractAsset
}
/**
* @param array $platformOptions
* @param mixed[] $platformOptions
*
* @return Column
*/
......@@ -302,7 +302,7 @@ class Column extends AbstractAsset
}
/**
* @return array
* @return mixed[]
*/
public function getPlatformOptions()
{
......@@ -411,7 +411,7 @@ class Column extends AbstractAsset
}
/**
* @param array $customSchemaOptions
* @param mixed[] $customSchemaOptions
*
* @return Column
*/
......@@ -423,7 +423,7 @@ class Column extends AbstractAsset
}
/**
* @return array
* @return mixed[]
*/
public function getCustomSchemaOptions()
{
......@@ -431,7 +431,7 @@ class Column extends AbstractAsset
}
/**
* @return array
* @return mixed[]
*/
public function toArray()
{
......
......@@ -17,7 +17,7 @@ class ColumnDiff
/** @var Column */
public $column;
/** @var array */
/** @var string[] */
public $changedProperties = [];
/** @var Column */
......
......@@ -410,7 +410,7 @@ class Comparator
* If there are differences this method returns $field2, otherwise the
* boolean false.
*
* @return array
* @return string[]
*/
public function diffColumn(Column $column1, Column $column2)
{
......
......@@ -25,7 +25,7 @@ interface Constraint
* Returns the names of the referencing table columns
* the constraint is associated with.
*
* @return array
* @return string[]
*/
public function getColumns();
......@@ -39,7 +39,7 @@ interface Constraint
*
* @param AbstractPlatform $platform The platform to use for quotation.
*
* @return array
* @return string[]
*/
public function getQuotedColumns(AbstractPlatform $platform);
}
......@@ -49,17 +49,21 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
*/
protected $_foreignColumnNames;
/** @var array Options associated with the foreign key constraint. */
/**
* Options associated with the foreign key constraint.
*
* @var mixed[]
*/
protected $_options;
/**
* Initializes the foreign key constraint.
*
* @param array $localColumnNames Names of the referencing table columns.
* @param string[] $localColumnNames Names of the referencing table columns.
* @param Table|string $foreignTableName Referenced table.
* @param array $foreignColumnNames Names of the referenced table columns.
* @param string[] $foreignColumnNames Names of the referenced table columns.
* @param string|null $name Name of the foreign key constraint.
* @param array $options Options associated with the foreign key constraint.
* @param mixed[] $options Options associated with the foreign key constraint.
*/
public function __construct(array $localColumnNames, $foreignTableName, array $foreignColumnNames, $name = null, array $options = [])
{
......@@ -119,7 +123,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
* Returns the names of the referencing table columns
* the foreign key constraint is associated with.
*
* @return array
* @return string[]
*/
public function getLocalColumns()
{
......@@ -136,7 +140,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
*
* @param AbstractPlatform $platform The platform to use for quotation.
*
* @return array
* @return string[]
*/
public function getQuotedLocalColumns(AbstractPlatform $platform)
{
......@@ -152,7 +156,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/**
* Returns unquoted representation of local table column names for comparison with other FK
*
* @return array
* @return string[]
*/
public function getUnquotedLocalColumns()
{
......@@ -162,7 +166,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/**
* Returns unquoted representation of foreign table column names for comparison with other FK
*
* @return array
* @return string[]
*/
public function getUnquotedForeignColumns()
{
......@@ -191,7 +195,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
*
* @param AbstractPlatform $platform The platform to use for quotation.
*
* @return array
* @return string[]
*/
public function getQuotedColumns(AbstractPlatform $platform)
{
......@@ -242,7 +246,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
* Returns the names of the referenced table columns
* the foreign key constraint is associated with.
*
* @return array
* @return string[]
*/
public function getForeignColumns()
{
......@@ -259,7 +263,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
*
* @param AbstractPlatform $platform The platform to use for quotation.
*
* @return array
* @return string[]
*/
public function getQuotedForeignColumns(AbstractPlatform $platform)
{
......@@ -300,7 +304,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
/**
* Returns the options associated with the foreign key constraint.
*
* @return array
* @return mixed[]
*/
public function getOptions()
{
......
......@@ -31,7 +31,7 @@ class Index extends AbstractAsset implements Constraint
* Platform specific flags for indexes.
* array($flagName => true)
*
* @var array
* @var true[]
*/
protected $_flags = [];
......@@ -39,7 +39,7 @@ class Index extends AbstractAsset implements Constraint
* Platform specific options
*
* @todo $_flags should eventually be refactored into options
* @var array
* @var mixed[]
*/
private $options = [];
......@@ -49,7 +49,7 @@ class Index extends AbstractAsset implements Constraint
* @param bool $isUnique
* @param bool $isPrimary
* @param string[] $flags
* @param array $options
* @param mixed[] $options
*/
public function __construct($indexName, array $columns, $isUnique = false, $isPrimary = false, array $flags = [], array $options = [])
{
......@@ -157,7 +157,7 @@ class Index extends AbstractAsset implements Constraint
/**
* Checks if this index exactly spans the given column names in the correct order.
*
* @param array $columnNames
* @param string[] $columnNames
*
* @return bool
*/
......@@ -304,7 +304,7 @@ class Index extends AbstractAsset implements Constraint
}
/**
* @return array
* @return mixed[]
*/
public function getOptions()
{
......
......@@ -14,10 +14,11 @@ use function array_map;
use function array_shift;
use function assert;
use function explode;
use function implode;
use function in_array;
use function join;
use function preg_match;
use function preg_replace;
use function sprintf;
use function str_replace;
use function stripos;
use function strlen;
......@@ -30,13 +31,13 @@ use function trim;
*/
class PostgreSqlSchemaManager extends AbstractSchemaManager
{
/** @var array */
/** @var string[] */
private $existingSchemaPaths;
/**
* Gets all the existing schema names.
*
* @return array
* @return string[]
*/
public function getSchemaNames()
{
......@@ -50,7 +51,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
*
* This is a PostgreSQL only function.
*
* @return array
* @return string[]
*/
public function getSchemaSearchPaths()
{
......@@ -69,7 +70,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
*
* This is a PostgreSQL only function.
*
* @return array
* @return string[]
*/
public function getExistingSchemaSearchPaths()
{
......@@ -213,9 +214,11 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$buffer = [];
foreach ($tableIndexes as $row) {
$colNumbers = array_map('intval', explode(' ', $row['indkey']));
$colNumbersSql = 'IN (' . join(' ,', $colNumbers) . ' )';
$columnNameSql = "SELECT attnum, attname FROM pg_attribute
WHERE attrelid={$row['indrelid']} AND attnum $colNumbersSql ORDER BY attnum ASC;";
$columnNameSql = sprintf(
'SELECT attnum, attname FROM pg_attribute WHERE attrelid=%d AND attnum IN (%s) ORDER BY attnum ASC',
$row['indrelid'],
implode(' ,', $colNumbers)
);
$stmt = $this->_conn->executeQuery($columnNameSql);
$indexColumns = $stmt->fetchAll();
......
......@@ -254,7 +254,13 @@ class SQLServerSchemaManager extends AbstractSchemaManager
foreach ($tableDiff->removedColumns as $col) {
$columnConstraintSql = $this->getColumnConstraintSQL($tableDiff->name, $col->getName());
foreach ($this->_conn->fetchAll($columnConstraintSql) as $constraint) {
$this->_conn->exec("ALTER TABLE $tableDiff->name DROP CONSTRAINT " . $constraint['Name']);
$this->_conn->exec(
sprintf(
'ALTER TABLE %s DROP CONSTRAINT %s',
$tableDiff->name,
$constraint['Name']
)
);
}
}
}
......
......@@ -42,7 +42,7 @@ class Schema extends AbstractAsset
/**
* The namespaces in this schema.
*
* @var array
* @var string[]
*/
private $namespaces = [];
......@@ -58,7 +58,7 @@ class Schema extends AbstractAsset
/**
* @param Table[] $tables
* @param Sequence[] $sequences
* @param array $namespaces
* @param string[] $namespaces
*/
public function __construct(
array $tables = [],
......@@ -139,7 +139,7 @@ class Schema extends AbstractAsset
/**
* Returns the namespaces of this schema.
*
* @return array A list of namespace names.
* @return string[] A list of namespace names.
*/
public function getNamespaces()
{
......@@ -236,7 +236,7 @@ class Schema extends AbstractAsset
/**
* Gets all table names, prefixed with a schema name, even the default one if present.
*
* @return array
* @return string[]
*/
public function getTableNames()
{
......@@ -389,7 +389,7 @@ class Schema extends AbstractAsset
/**
* Returns an array of necessary SQL queries to create the schema on the given platform.
*
* @return array
* @return string[]
*/
public function toSql(AbstractPlatform $platform)
{
......@@ -402,7 +402,7 @@ class Schema extends AbstractAsset
/**
* Return an array of necessary SQL queries to drop the schema on the given platform.
*
* @return array
* @return string[]
*/
public function toDropSql(AbstractPlatform $platform)
{
......@@ -413,7 +413,7 @@ class Schema extends AbstractAsset
}
/**
* @return array
* @return string[]
*/
public function getMigrateToSql(Schema $toSchema, AbstractPlatform $platform)
{
......@@ -424,7 +424,7 @@ class Schema extends AbstractAsset
}
/**
* @return array
* @return string[]
*/
public function getMigrateFromSql(Schema $fromSchema, AbstractPlatform $platform)
{
......
......@@ -18,7 +18,7 @@ class SchemaConfig
/** @var string */
protected $name;
/** @var array */
/** @var mixed[] */
protected $defaultTableOptions = [];
/**
......@@ -83,7 +83,7 @@ class SchemaConfig
* Gets the default options that are passed to Table instances created with
* Schema#createTable().
*
* @return array
* @return mixed[]
*/
public function getDefaultTableOptions()
{
......@@ -91,7 +91,7 @@ class SchemaConfig
}
/**
* @param array $defaultTableOptions
* @param mixed[] $defaultTableOptions
*
* @return void
*/
......
......@@ -86,7 +86,7 @@ class SchemaDiff
*
* This way it is ensured that assets are deleted which might not be relevant to the metadata schema at all.
*
* @return array
* @return string[]
*/
public function toSaveSql(AbstractPlatform $platform)
{
......@@ -94,7 +94,7 @@ class SchemaDiff
}
/**
* @return array
* @return string[]
*/
public function toSql(AbstractPlatform $platform)
{
......@@ -104,7 +104,7 @@ class SchemaDiff
/**
* @param bool $saveMode
*
* @return array
* @return string[]
*/
protected function _toSql(AbstractPlatform $platform, $saveMode = false)
{
......
......@@ -37,7 +37,10 @@ class SchemaException extends DBALException
*/
public static function indexNameInvalid($indexName)
{
return new self("Invalid index-name $indexName given, has to be [a-zA-Z0-9_]", self::INDEX_INVALID_NAME);
return new self(
sprintf('Invalid index-name %s given, has to be [a-zA-Z0-9_]', $indexName),
self::INDEX_INVALID_NAME
);
}
/**
......@@ -48,7 +51,10 @@ class SchemaException extends DBALException
*/
public static function indexDoesNotExist($indexName, $table)
{
return new self("Index '$indexName' does not exist on table '$table'.", self::INDEX_DOESNT_EXIST);
return new self(
sprintf("Index '%s' does not exist on table '%s'.", $indexName, $table),
self::INDEX_DOESNT_EXIST
);
}
/**
......@@ -59,7 +65,10 @@ class SchemaException extends DBALException
*/
public static function indexAlreadyExists($indexName, $table)
{
return new self("An index with name '$indexName' was already defined on table '$table'.", self::INDEX_ALREADY_EXISTS);
return new self(
sprintf("An index with name '%s' was already defined on table '%s'.", $indexName, $table),
self::INDEX_ALREADY_EXISTS
);
}
/**
......@@ -70,7 +79,10 @@ class SchemaException extends DBALException
*/
public static function columnDoesNotExist($columnName, $table)
{
return new self("There is no column with name '$columnName' on table '$table'.", self::COLUMN_DOESNT_EXIST);
return new self(
sprintf("There is no column with name '%s' on table '%s'.", $columnName, $table),
self::COLUMN_DOESNT_EXIST
);
}
/**
......@@ -138,7 +150,10 @@ class SchemaException extends DBALException
*/
public static function foreignKeyDoesNotExist($fkName, $table)
{
return new self("There exists no foreign key with the name '$fkName' on table '$table'.", self::FOREIGNKEY_DOESNT_EXIST);
return new self(
sprintf("There exists no foreign key with the name '%s' on table '%s'.", $fkName, $table),
self::FOREIGNKEY_DOESNT_EXIST
);
}
/**
......@@ -161,6 +176,8 @@ class SchemaException extends DBALException
*/
public static function alterTableChangeNotSupported($changeName)
{
return new self("Alter table change not supported, given '$changeName'");
return new self(
sprintf("Alter table change not supported, given '%s'", $changeName)
);
}
}
......@@ -117,7 +117,12 @@ class SqliteSchemaManager extends AbstractSchemaManager
$tableForeignKeys = $this->_conn->fetchAll($sql);
if (! empty($tableForeignKeys)) {
$createSql = $this->_conn->fetchAll("SELECT sql FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE type = 'table' AND name = '$table'");
$createSql = $this->_conn->fetchAll(
sprintf(
"SELECT sql FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE type = 'table' AND name = '%s'",
$table
)
);
$createSql = $createSql[0]['sql'] ?? '';
if (preg_match_all(
......@@ -169,7 +174,9 @@ class SqliteSchemaManager extends AbstractSchemaManager
$indexBuffer = [];
// fetch primary
$stmt = $this->_conn->executeQuery("PRAGMA TABLE_INFO ('$tableName')");
$stmt = $this->_conn->executeQuery(
sprintf("PRAGMA TABLE_INFO ('%s')", $tableName)
);
$indexArray = $stmt->fetchAll(FetchMode::ASSOCIATIVE);
usort($indexArray, static function ($a, $b) {
......@@ -205,7 +212,9 @@ class SqliteSchemaManager extends AbstractSchemaManager
$idx['primary'] = false;
$idx['non_unique'] = $tableIndex['unique']?false:true;
$stmt = $this->_conn->executeQuery("PRAGMA INDEX_INFO ('{$keyName}')");
$stmt = $this->_conn->executeQuery(
sprintf("PRAGMA INDEX_INFO ('%s')", $keyName)
);
$indexArray = $stmt->fetchAll(FetchMode::ASSOCIATIVE);
foreach ($indexArray as $indexColumnRow) {
......@@ -263,7 +272,12 @@ class SqliteSchemaManager extends AbstractSchemaManager
}
// inspect column collation and comments
$createSql = $this->_conn->fetchAll("SELECT sql FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE type = 'table' AND name = '$table'");
$createSql = $this->_conn->fetchAll(
sprintf(
"SELECT sql FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE type = 'table' AND name = '%s'",
$table
)
);
$createSql = $createSql[0]['sql'] ?? '';
foreach ($list as $columnName => $column) {
......
......@@ -19,7 +19,7 @@ abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
}
/**
* @param array $sql
* @param string[] $sql
*/
protected function processSqlSafely(array $sql)
{
......@@ -32,7 +32,7 @@ abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
}
/**
* @param array $sql
* @param string[] $sql
*/
protected function processSql(array $sql)
{
......
......@@ -13,39 +13,39 @@ interface SchemaSynchronizer
/**
* Gets the SQL statements that can be executed to create the schema.
*
* @return array
* @return string[]
*/
function getCreateSchema(Schema $createSchema);
public function getCreateSchema(Schema $createSchema);
/**
* Gets the SQL Statements to update given schema with the underlying db.
*
* @param bool $noDrops
*
* @return array
* @return string[]
*/
function getUpdateSchema(Schema $toSchema, $noDrops = false);
public function getUpdateSchema(Schema $toSchema, $noDrops = false);
/**
* Gets the SQL Statements to drop the given schema from underlying db.
*
* @return array
* @return string[]
*/
function getDropSchema(Schema $dropSchema);
public function getDropSchema(Schema $dropSchema);
/**
* Gets the SQL statements to drop all schema assets from underlying db.
*
* @return array
* @return string[]
*/
function getDropAllSchema();
public function getDropAllSchema();
/**
* Creates the Schema.
*
* @return void
*/
function createSchema(Schema $createSchema);
public function createSchema(Schema $createSchema);
/**
* Updates the Schema to new schema version.
......@@ -54,19 +54,19 @@ interface SchemaSynchronizer
*
* @return void
*/
function updateSchema(Schema $toSchema, $noDrops = false);
public function updateSchema(Schema $toSchema, $noDrops = false);
/**
* Drops the given database schema from the underlying db.
*
* @return void
*/
function dropSchema(Schema $dropSchema);
public function dropSchema(Schema $dropSchema);
/**
* Drops all assets from the underlying db.
*
* @return void
*/
function dropAllSchema();
public function dropAllSchema();
}
......@@ -40,7 +40,7 @@ class Table extends AbstractAsset
/** @var ForeignKeyConstraint[] */
protected $_fkConstraints = [];
/** @var array */
/** @var mixed[] */
protected $_options = [];
/** @var SchemaConfig|null */
......@@ -52,7 +52,7 @@ class Table extends AbstractAsset
* @param Index[] $indexes
* @param ForeignKeyConstraint[] $fkConstraints
* @param int $idGeneratorType
* @param array $options
* @param mixed[] $options
*
* @throws DBALException
*/
......@@ -102,7 +102,7 @@ class Table extends AbstractAsset
/**
* Sets the Primary Key.
*
* @param array $columns
* @param mixed[][] $columns
* @param string|bool $indexName
*
* @return self
......@@ -120,10 +120,10 @@ class Table extends AbstractAsset
}
/**
* @param array $columnNames
* @param mixed[][] $columnNames
* @param string|null $indexName
* @param array $flags
* @param array $options
* @param string[] $flags
* @param mixed[] $options
*
* @return self
*/
......@@ -170,9 +170,9 @@ class Table extends AbstractAsset
}
/**
* @param array $columnNames
* @param mixed[][] $columnNames
* @param string|null $indexName
* @param array $options
* @param mixed[] $options
*
* @return self
*/
......@@ -198,7 +198,7 @@ class Table extends AbstractAsset
*
* @return self This table instance.
*
* @throws SchemaException if no index exists for the given current name
* @throws SchemaException If no index exists for the given current name
* or if an index with the given new name already exists on this table.
*/
public function renameIndex($oldIndexName, $newIndexName = null)
......@@ -238,7 +238,7 @@ class Table extends AbstractAsset
/**
* Checks if an index begins in the order of the given columns.
*
* @param array $columnsNames
* @param mixed[][] $columnsNames
*
* @return bool
*/
......@@ -255,12 +255,12 @@ class Table extends AbstractAsset
}
/**
* @param array $columnNames
* @param string $indexName
* @param bool $isUnique
* @param bool $isPrimary
* @param array $flags
* @param array $options
* @param mixed[][] $columnNames
* @param string $indexName
* @param bool $isUnique
* @param bool $isPrimary
* @param string[] $flags
* @param mixed[] $options
*
* @return Index
*
......@@ -286,9 +286,9 @@ class Table extends AbstractAsset
}
/**
* @param string $columnName
* @param string $typeName
* @param array $options
* @param string $columnName
* @param string $typeName
* @param mixed[] $options
*
* @return Column
*/
......@@ -321,8 +321,8 @@ class Table extends AbstractAsset
/**
* Change Column Details.
*
* @param string $columnName
* @param array $options
* @param string $columnName
* @param mixed[] $options
*
* @return self
*/
......@@ -355,9 +355,9 @@ class Table extends AbstractAsset
* Name is inferred from the local columns.
*
* @param Table|string $foreignTable Table schema instance or table name
* @param array $localColumnNames
* @param array $foreignColumnNames
* @param array $options
* @param string[] $localColumnNames
* @param string[] $foreignColumnNames
* @param mixed[] $options
* @param string|null $constraintName
*
* @return self
......@@ -377,9 +377,9 @@ class Table extends AbstractAsset
* @deprecated Use {@link addForeignKeyConstraint}
*
* @param Table|string $foreignTable Table schema instance or table name
* @param array $localColumnNames
* @param array $foreignColumnNames
* @param array $options
* @param string[] $localColumnNames
* @param string[] $foreignColumnNames
* @param mixed[] $options
*
* @return self
*/
......@@ -395,9 +395,9 @@ class Table extends AbstractAsset
*
* @param string $name
* @param Table|string $foreignTable Table schema instance or table name
* @param array $localColumnNames
* @param array $foreignColumnNames
* @param array $options
* @param string[] $localColumnNames
* @param string[] $foreignColumnNames
* @param mixed[] $options
*
* @return self
*
......@@ -626,7 +626,7 @@ class Table extends AbstractAsset
/**
* Returns only columns that have specified names
*
* @param array $columnNames
* @param string[] $columnNames
*
* @return Column[]
*/
......@@ -687,7 +687,7 @@ class Table extends AbstractAsset
/**
* Returns the primary key columns.
*
* @return array
* @return string[]
*
* @throws DBALException
*/
......@@ -781,7 +781,7 @@ class Table extends AbstractAsset
}
/**
* @return array
* @return mixed[]
*/
public function getOptions()
{
......
......@@ -10,16 +10,16 @@ use function array_merge;
class CreateSchemaSqlCollector extends AbstractVisitor
{
/** @var array */
/** @var string[] */
private $createNamespaceQueries = [];
/** @var array */
/** @var string[] */
private $createTableQueries = [];
/** @var array */
/** @var string[] */
private $createSequenceQueries = [];
/** @var array */
/** @var string[] */
private $createFkConstraintQueries = [];
/** @var AbstractPlatform */
......@@ -84,7 +84,7 @@ class CreateSchemaSqlCollector extends AbstractVisitor
/**
* Gets all queries collected so far.
*
* @return array
* @return string[]
*/
public function getQueries()
{
......
......@@ -74,7 +74,7 @@ class DropSchemaSqlCollector extends AbstractVisitor
}
/**
* @return array
* @return string[]
*/
public function getQueries()
{
......
......@@ -96,8 +96,8 @@ class Graphviz extends AbstractVisitor
}
/**
* @param string $name
* @param array $options
* @param string $name
* @param string[] $options
*
* @return string
*/
......@@ -113,9 +113,9 @@ class Graphviz extends AbstractVisitor
}
/**
* @param string $node1
* @param string $node2
* @param array $options
* @param string $node1
* @param string $node2
* @param string[] $options
*
* @return string
*/
......
......@@ -17,25 +17,25 @@ interface SchemaDiffVisitor
/**
* Visit an orphaned foreign key whose table was deleted.
*/
function visitOrphanedForeignKey(ForeignKeyConstraint $foreignKey);
public function visitOrphanedForeignKey(ForeignKeyConstraint $foreignKey);
/**
* Visit a sequence that has changed.
*/
function visitChangedSequence(Sequence $sequence);
public function visitChangedSequence(Sequence $sequence);
/**
* Visit a sequence that has been removed.
*/
function visitRemovedSequence(Sequence $sequence);
public function visitRemovedSequence(Sequence $sequence);
function visitNewSequence(Sequence $sequence);
public function visitNewSequence(Sequence $sequence);
function visitNewTable(Table $table);
public function visitNewTable(Table $table);
function visitNewTableForeignKey(Table $table, ForeignKeyConstraint $foreignKey);
public function visitNewTableForeignKey(Table $table, ForeignKeyConstraint $foreignKey);
function visitRemovedTable(Table $table);
public function visitRemovedTable(Table $table);
function visitChangedTable(TableDiff $tableDiff);
public function visitChangedTable(TableDiff $tableDiff);
}
......@@ -60,7 +60,7 @@ class PoolingShardConnection extends Connection
private $connectionParameters = [];
/**
* @param array $params
* {@inheritDoc}
*
* @throws InvalidArgumentException
*/
......
......@@ -69,11 +69,7 @@ class PoolingShardManager implements ShardManager
}
/**
* @param string $sql
* @param array $params
* @param array $types
*
* @return array
* {@inheritDoc}
*
* @throws RuntimeException
*/
......
......@@ -153,7 +153,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
}
/**
* @return array
* @return Schema[]
*/
private function partitionSchema(Schema $schema)
{
......@@ -199,7 +199,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
* perform the given operation on the underlying schema synchronizer given
* the different partitioned schema instances.
*
* @return array
* @return string[]
*/
private function work(Schema $schema, Closure $operation)
{
......
......@@ -33,7 +33,7 @@ use function in_array;
*/
class MultiTenantVisitor implements Visitor
{
/** @var array */
/** @var string[] */
private $excludedTables = [];
/** @var string */
......@@ -51,7 +51,7 @@ class MultiTenantVisitor implements Visitor
private $distributionName;
/**
* @param array $excludedTables
* @param string[] $excludedTables
* @param string $tenantColumnName
* @param string|null $distributionName
*/
......
......@@ -17,5 +17,5 @@ interface ShardChoser
*
* @return string|int
*/
function pickShard($distributionValue, PoolingShardConnection $conn);
public function pickShard($distributionValue, PoolingShardConnection $conn);
}
......@@ -28,7 +28,7 @@ interface ShardManager
*
* @return void
*/
function selectGlobal();
public function selectGlobal();
/**
* Selects the shard against which the queries after this statement will be issued.
......@@ -39,14 +39,14 @@ interface ShardManager
*
* @throws ShardingException If no value is passed as shard identifier.
*/
function selectShard($distributionValue);
public function selectShard($distributionValue);
/**
* Gets the distribution value currently used for sharding.
*
* @return string|null
*/
function getCurrentDistributionValue();
public function getCurrentDistributionValue();
/**
* Gets information about the amount of shards and other details.
......@@ -54,9 +54,9 @@ interface ShardManager
* Format is implementation specific, each shard is one element and has an
* 'id' attribute at least.
*
* @return array
* @return mixed[][]
*/
function getShards();
public function getShards();
/**
* Queries all shards in undefined order and return the results appended to
......@@ -64,11 +64,11 @@ interface ShardManager
*
* Using {@link \Doctrine\DBAL\Connection::fetchAll} to retrieve rows internally.
*
* @param string $sql
* @param array $params
* @param array $types
* @param string $sql
* @param mixed[] $params
* @param int[]|string[] $types
*
* @return array
* @return mixed[]
*/
function queryAll($sql, array $params, array $types);
public function queryAll($sql, array $params, array $types);
}
......@@ -27,14 +27,14 @@ class Statement implements IteratorAggregate, DriverStatement
/**
* The bound parameters.
*
* @var array
* @var mixed[]
*/
protected $params = [];
/**
* The parameter types.
*
* @var array
* @var int[]|string[]
*/
protected $types = [];
......@@ -132,7 +132,7 @@ class Statement implements IteratorAggregate, DriverStatement
/**
* Executes the statement with the currently bound parameters.
*
* @param array|null $params
* @param mixed[]|null $params
*
* @return bool TRUE on success, FALSE on failure.
*
......@@ -203,9 +203,7 @@ class Statement implements IteratorAggregate, DriverStatement
}
/**
* Fetches extended error information associated with the last operation on the statement.
*
* @return array
* {@inheritDoc}
*/
public function errorInfo()
{
......@@ -257,11 +255,7 @@ class Statement implements IteratorAggregate, DriverStatement
}
/**
* Returns a single column from the next row of a result set.
*
* @param int $columnIndex
*
* @return mixed A single column from the next row of a result set or FALSE if there are no more rows.
* {@inheritDoc}
*/
public function fetchColumn($columnIndex = 0)
{
......
......@@ -56,8 +56,10 @@ EOT
{
$conn = $this->getHelper('db')->getConnection();
if (($fileNames = $input->getArgument('file')) === null) {
return;
$fileNames = $input->getArgument('file');
if ($fileNames === null) {
return null;
}
foreach ((array) $fileNames as $fileName) {
......@@ -123,5 +125,7 @@ EOT
$stmt->closeCursor();
}
}
return null;
}
}
......@@ -16,7 +16,7 @@ use function implode;
class ReservedWordsCommand extends Command
{
/** @var array */
/** @var string[] */
private $keywordListClasses = [
'mysql' => 'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords',
'mysql57' => 'Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords',
......
......@@ -47,7 +47,9 @@ EOT
{
$conn = $this->getHelper('db')->getConnection();
if (($sql = $input->getArgument('sql')) === null) {
$sql = $input->getArgument('sql');
if ($sql === null) {
throw new RuntimeException("Argument 'SQL' is required in order to execute this command correctly.");
}
......
......@@ -45,14 +45,14 @@ abstract class Type
/**
* Map of already instantiated type objects. One instance per type (flyweight).
*
* @var array
* @var self[]
*/
private static $_typeObjects = [];
/**
* The map of supported doctrine mapping types.
*
* @var array
* @var string[]
*/
private static $_typesMap = [
self::TARRAY => ArrayType::class,
......@@ -132,7 +132,7 @@ abstract class Type
/**
* Gets the SQL declaration snippet for a field of this type.
*
* @param array $fieldDeclaration The field declaration.
* @param mixed[] $fieldDeclaration The field declaration.
* @param AbstractPlatform $platform The currently used database platform.
*
* @return string
......@@ -241,7 +241,7 @@ abstract class Type
* Gets the types array map which holds all registered types and the corresponding
* type class
*
* @return array
* @return string[]
*/
public static function getTypesMap()
{
......@@ -303,7 +303,7 @@ abstract class Type
/**
* Gets an array of database types that map to this Doctrine type.
*
* @return array
* @return string[]
*/
public function getMappedDatabaseTypes(AbstractPlatform $platform)
{
......
......@@ -24,7 +24,7 @@ interface VersionAwarePlatformDriver
*
* @return AbstractPlatform
*
* @throws DBALException if the given version string could not be evaluated.
* @throws DBALException If the given version string could not be evaluated.
*/
public function createDatabasePlatformForVersion($version);
}
......@@ -37,8 +37,25 @@
<exclude-pattern>tests/Doctrine/Tests/DBAL/Tools/TestAsset/*</exclude-pattern>
</rule>
<!-- see https://github.com/squizlabs/PHP_CodeSniffer/issues/2099 -->
<rule ref="Squiz.Commenting.FunctionComment.InvalidNoReturn">
<exclude-pattern>lib/Doctrine/DBAL/Platforms/AbstractPlatform.php</exclude-pattern>
<exclude-pattern>lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php</exclude-pattern>
</rule>
<!-- some statement classes close cursor using an empty while-loop -->
<rule ref="Generic.CodeAnalysis.EmptyStatement.DetectedWhile">
<exclude-pattern>lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php</exclude-pattern>
</rule>
<!-- sqlsrv functions are documented in upper case but reflected in lower case -->
<rule ref="Squiz.PHP.LowercasePHPFunctions.CallUppercase">
<exclude-pattern>lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php</exclude-pattern>
</rule>
<!-- see https://github.com/squizlabs/PHP_CodeSniffer/issues/2165 -->
<rule ref="Squiz.Arrays.ArrayDeclaration.SpaceBeforeComma">
<exclude-pattern>tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php</exclude-pattern>
</rule>
</ruleset>
......@@ -781,42 +781,51 @@ EOD;
return [
[
null,
"SELECT c.*,
(
SELECT d.comments
FROM user_col_comments d
WHERE d.TABLE_NAME = c.TABLE_NAME
AND d.COLUMN_NAME = c.COLUMN_NAME
) AS comments
FROM user_tab_columns c
WHERE c.table_name = 'test'
ORDER BY c.column_id",
<<<'SQL'
SELECT c.*,
(
SELECT d.comments
FROM user_col_comments d
WHERE d.TABLE_NAME = c.TABLE_NAME
AND d.COLUMN_NAME = c.COLUMN_NAME
) AS comments
FROM user_tab_columns c
WHERE c.table_name = 'test'
ORDER BY c.column_id
SQL
,
],
[
'/',
"SELECT c.*,
(
SELECT d.comments
FROM user_col_comments d
WHERE d.TABLE_NAME = c.TABLE_NAME
AND d.COLUMN_NAME = c.COLUMN_NAME
) AS comments
FROM user_tab_columns c
WHERE c.table_name = 'test'
ORDER BY c.column_id",
<<<'SQL'
SELECT c.*,
(
SELECT d.comments
FROM user_col_comments d
WHERE d.TABLE_NAME = c.TABLE_NAME
AND d.COLUMN_NAME = c.COLUMN_NAME
) AS comments
FROM user_tab_columns c
WHERE c.table_name = 'test'
ORDER BY c.column_id
SQL
,
],
[
'scott',
"SELECT c.*,
(
SELECT d.comments
FROM all_col_comments d
WHERE d.TABLE_NAME = c.TABLE_NAME AND d.OWNER = c.OWNER
AND d.COLUMN_NAME = c.COLUMN_NAME
) AS comments
FROM all_tab_columns c
WHERE c.table_name = 'test' AND c.owner = 'SCOTT'
ORDER BY c.column_id",
<<<'SQL'
SELECT c.*,
(
SELECT d.comments
FROM all_col_comments d
WHERE d.TABLE_NAME = c.TABLE_NAME AND d.OWNER = c.OWNER
AND d.COLUMN_NAME = c.COLUMN_NAME
) AS comments
FROM all_tab_columns c
WHERE c.table_name = 'test' AND c.owner = 'SCOTT'
ORDER BY c.column_id
SQL
,
],
];
}
......
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