Commit cd3bebc0 authored by Alessandro Minoccheri's avatar Alessandro Minoccheri

fixed all array declarations inside Driver dir

parent 7bac6913
......@@ -32,7 +32,7 @@ class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
$conn = new Connection(
$this->constructPdoDsn($params),
......
......@@ -37,7 +37,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
*
* @throws \Doctrine\DBAL\Driver\IBMDB2\DB2Exception
*/
public function __construct(array $params, $username, $password, $driverOptions = array())
public function __construct(array $params, $username, $password, $driverOptions = [])
{
$isPersistent = (isset($params['persistent']) && $params['persistent'] == true);
......@@ -173,9 +173,9 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
*/
public function errorInfo()
{
return array(
return [
0 => db2_conn_errormsg($this->_conn),
1 => $this->errorCode(),
);
];
}
}
......@@ -32,7 +32,7 @@ class DB2Driver extends AbstractDB2Driver
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
if ( ! isset($params['protocol'])) {
$params['protocol'] = 'TCPIP';
......
......@@ -31,7 +31,7 @@ class DB2Statement implements \IteratorAggregate, Statement
/**
* @var array
*/
private $_bindParam = array();
private $_bindParam = [];
/**
* @var string Name of the default class to instantiate when fetch mode is \PDO::FETCH_CLASS.
......@@ -41,7 +41,7 @@ class DB2Statement implements \IteratorAggregate, Statement
/**
* @var string Constructor arguments for the default class to instantiate when fetch mode is \PDO::FETCH_CLASS.
*/
private $defaultFetchClassCtorArgs = array();
private $defaultFetchClassCtorArgs = [];
/**
* @var integer
......@@ -60,10 +60,10 @@ class DB2Statement implements \IteratorAggregate, Statement
*
* @var array
*/
static private $_typeMap = array(
static private $_typeMap = [
\PDO::PARAM_INT => DB2_LONG,
\PDO::PARAM_STR => DB2_CHAR,
);
];
/**
* @param resource $stmt
......@@ -110,7 +110,7 @@ class DB2Statement implements \IteratorAggregate, Statement
return false;
}
$this->_bindParam = array();
$this->_bindParam = [];
if (!db2_free_result($this->_stmt)) {
return false;
......@@ -146,10 +146,10 @@ class DB2Statement implements \IteratorAggregate, Statement
*/
public function errorInfo()
{
return array(
return [
db2_stmt_errormsg(),
db2_stmt_error(),
);
];
}
/**
......@@ -164,7 +164,7 @@ class DB2Statement implements \IteratorAggregate, Statement
if ($params === null) {
ksort($this->_bindParam);
$params = array();
$params = [];
foreach ($this->_bindParam as $column => $value) {
$params[] = $value;
......@@ -228,7 +228,7 @@ class DB2Statement implements \IteratorAggregate, Statement
if (func_num_args() >= 2) {
$args = func_get_args();
$className = $args[1];
$ctorArgs = isset($args[2]) ? $args[2] : array();
$ctorArgs = isset($args[2]) ? $args[2] : [];
}
$result = db2_fetch_object($this->_stmt);
......@@ -252,11 +252,11 @@ class DB2Statement implements \IteratorAggregate, Statement
*/
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{
$rows = array();
$rows = [];
switch ($fetchMode) {
case \PDO::FETCH_CLASS:
while ($row = call_user_func_array(array($this, 'fetch'), func_get_args())) {
while ($row = call_user_func_array([$this, 'fetch'], func_get_args())) {
$rows[] = $row;
}
break;
......@@ -293,7 +293,7 @@ class DB2Statement implements \IteratorAggregate, Statement
*/
public function rowCount()
{
return (@db2_num_rows($this->_stmt))?:0;
return (@db2_num_rows($this->_stmt)) ? : 0;
}
/**
......@@ -307,7 +307,7 @@ class DB2Statement implements \IteratorAggregate, Statement
*
* @throws DB2Exception
*/
private function castObject(\stdClass $sourceObject, $destinationClass, array $ctorArgs = array())
private function castObject(\stdClass $sourceObject, $destinationClass, array $ctorArgs = [])
{
if ( ! is_string($destinationClass)) {
if ( ! is_object($destinationClass)) {
......
......@@ -30,7 +30,7 @@ class Driver extends AbstractMySQLDriver
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
try {
return new MysqliConnection($params, $username, $password, $driverOptions);
......
......@@ -47,7 +47,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
*
* @throws \Doctrine\DBAL\Driver\Mysqli\MysqliException
*/
public function __construct(array $params, $username, $password, array $driverOptions = array())
public function __construct(array $params, $username, $password, array $driverOptions = [])
{
$port = isset($params['port']) ? $params['port'] : ini_get('mysqli.default_port');
......@@ -211,15 +211,15 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
* @throws MysqliException When one of of the options is not supported.
* @throws MysqliException When applying doesn't work - e.g. due to incorrect value.
*/
private function setDriverOptions(array $driverOptions = array())
private function setDriverOptions(array $driverOptions = [])
{
$supportedDriverOptions = array(
$supportedDriverOptions = [
\MYSQLI_OPT_CONNECT_TIMEOUT,
\MYSQLI_OPT_LOCAL_INFILE,
\MYSQLI_INIT_COMMAND,
\MYSQLI_READ_DEFAULT_FILE,
\MYSQLI_READ_DEFAULT_GROUP,
);
];
if (defined('MYSQLI_SERVER_PUBLIC_KEY')) {
$supportedDriverOptions[] = \MYSQLI_SERVER_PUBLIC_KEY;
......
......@@ -30,13 +30,13 @@ class MysqliStatement implements \IteratorAggregate, Statement
/**
* @var array
*/
protected static $_paramTypeMap = array(
protected static $_paramTypeMap = [
PDO::PARAM_STR => 's',
PDO::PARAM_BOOL => 'i',
PDO::PARAM_NULL => 's',
PDO::PARAM_INT => 'i',
PDO::PARAM_LOB => 's' // TODO Support LOB bigger then max package size.
);
];
/**
* @var \mysqli
......@@ -73,7 +73,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
*
* @var array
*/
protected $_values = array();
protected $_values = [];
/**
* @var integer
......@@ -162,7 +162,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
}
} else {
if (!call_user_func_array(array($this->_stmt, 'bind_param'), array($this->types) + $this->_bindedValues)) {
if (!call_user_func_array([$this->_stmt, 'bind_param'], [$this->types] + $this->_bindedValues)) {
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
}
}
......@@ -175,7 +175,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
if (null === $this->_columnNames) {
$meta = $this->_stmt->result_metadata();
if (false !== $meta) {
$columnNames = array();
$columnNames = [];
foreach ($meta->fetch_fields() as $col) {
$columnNames[] = $col->name;
}
......@@ -206,12 +206,12 @@ class MysqliStatement implements \IteratorAggregate, Statement
// to the length of the ones fetched during the previous execution.
$this->_rowBindedValues = array_fill(0, count($this->_columnNames), null);
$refs = array();
$refs = [];
foreach ($this->_rowBindedValues as $key => &$value) {
$refs[$key] =& $value;
}
if (!call_user_func_array(array($this->_stmt, 'bind_result'), $refs)) {
if (!call_user_func_array([$this->_stmt, 'bind_result'], $refs)) {
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
}
}
......@@ -230,7 +230,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
*/
private function _bindValues($values)
{
$params = array();
$params = [];
$types = str_repeat('s', count($values));
$params[0] = $types;
......@@ -238,7 +238,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
$params[] =& $v;
}
return call_user_func_array(array($this->_stmt, 'bind_param'), $params);
return call_user_func_array([$this->_stmt, 'bind_param'], $params);
}
/**
......@@ -249,7 +249,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
$ret = $this->_stmt->fetch();
if (true === $ret) {
$values = array();
$values = [];
foreach ($this->_rowBindedValues as $v) {
$values[] = $v;
}
......@@ -317,7 +317,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
{
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;
$rows = array();
$rows = [];
if (PDO::FETCH_COLUMN == $fetchMode) {
while (($row = $this->fetchColumn()) !== false) {
$rows[] = $row;
......
......@@ -33,7 +33,7 @@ class Driver extends AbstractOracleDriver
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
try {
return new OCI8Connection(
......
......@@ -54,12 +54,12 @@ class OCI8Statement implements \IteratorAggregate, Statement
/**
* @var array
*/
protected static $fetchModeMap = array(
protected static $fetchModeMap = [
PDO::FETCH_BOTH => OCI_BOTH,
PDO::FETCH_ASSOC => OCI_ASSOC,
PDO::FETCH_NUM => OCI_NUM,
PDO::FETCH_COLUMN => OCI_NUM,
);
];
/**
* @var integer
......@@ -69,7 +69,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
/**
* @var array
*/
protected $_paramMap = array();
protected $_paramMap = [];
/**
* Holds references to bound parameter values.
......@@ -78,7 +78,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
*
* @var array
*/
private $boundValues = array();
private $boundValues = [];
/**
* Indicates whether the statement is in the state when fetching results is possible
......@@ -126,7 +126,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
static public function convertPositionalToNamedPlaceholders($statement)
{
$fragmentOffset = $tokenOffset = 0;
$fragments = $paramMap = array();
$fragments = $paramMap = [];
$currentLiteralDelimiter = null;
do {
......@@ -154,7 +154,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
$fragments[] = substr($statement, $fragmentOffset);
$statement = implode('', $fragments);
return array($statement, $paramMap);
return [$statement, $paramMap];
}
/**
......@@ -409,7 +409,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
{
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;
$result = array();
$result = [];
if (PDO::FETCH_OBJ == $fetchMode) {
while ($row = $this->fetch($fetchMode)) {
......@@ -436,7 +436,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
// do not try fetching from the statement if it's not expected to contain result
// in order to prevent exceptional situation
if (!$this->result) {
return array();
return [];
}
oci_fetch_all($this->_sth, $result, 0, -1,
......
......@@ -41,7 +41,7 @@ class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
{
try {
parent::__construct($dsn, $user, $password, $options);
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Doctrine\DBAL\Driver\PDOStatement', array()));
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, ['Doctrine\DBAL\Driver\PDOStatement', []]);
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (\PDOException $exception) {
throw new PDOException($exception);
......@@ -71,7 +71,7 @@ class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*/
public function prepare($prepareString, $driverOptions = array())
public function prepare($prepareString, $driverOptions = [])
{
try {
return parent::prepare($prepareString, $driverOptions);
......
......@@ -37,7 +37,7 @@ class Driver extends AbstractDB2Driver
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
$conn = new PDOConnection(
$this->_constructPdoDsn($params),
......
......@@ -34,7 +34,7 @@ class Driver extends AbstractMySQLDriver
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
try {
$conn = new PDOConnection(
......
......@@ -36,7 +36,7 @@ class Driver extends AbstractOracleDriver
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
try {
return new PDOConnection(
......
......@@ -35,7 +35,7 @@ class Driver extends AbstractPostgreSQLDriver
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
try {
$pdo = new PDOConnection(
......
......@@ -34,16 +34,16 @@ class Driver extends AbstractSQLiteDriver
/**
* @var array
*/
protected $_userDefinedFunctions = array(
'sqrt' => array('callback' => array('Doctrine\DBAL\Platforms\SqlitePlatform', 'udfSqrt'), 'numArgs' => 1),
'mod' => array('callback' => array('Doctrine\DBAL\Platforms\SqlitePlatform', 'udfMod'), 'numArgs' => 2),
'locate' => array('callback' => array('Doctrine\DBAL\Platforms\SqlitePlatform', 'udfLocate'), 'numArgs' => -1),
);
protected $_userDefinedFunctions = [
'sqrt' => ['callback' => ['Doctrine\DBAL\Platforms\SqlitePlatform', 'udfSqrt'], 'numArgs' => 1],
'mod' => ['callback' => ['Doctrine\DBAL\Platforms\SqlitePlatform', 'udfMod'], 'numArgs' => 2],
'locate' => ['callback' => ['Doctrine\DBAL\Platforms\SqlitePlatform', 'udfLocate'], 'numArgs' => -1],
];
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
if (isset($driverOptions['userDefinedFunctions'])) {
$this->_userDefinedFunctions = array_merge(
......
......@@ -34,7 +34,7 @@ class Connection extends PDOConnection implements \Doctrine\DBAL\Driver\Connecti
public function __construct($dsn, $user = null, $password = null, array $options = null)
{
parent::__construct($dsn, $user, $password, $options);
$this->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array(Statement::class, array()));
$this->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [Statement::class, []]);
}
/**
......@@ -47,7 +47,7 @@ class Connection extends PDOConnection implements \Doctrine\DBAL\Driver\Connecti
}
$stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?');
$stmt->execute(array($name));
$stmt->execute([$name]);
return $stmt->fetchColumn();
}
......
......@@ -31,7 +31,7 @@ class Driver extends AbstractSQLServerDriver
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
return new Connection(
$this->_constructPdoDsn($params),
......
......@@ -36,7 +36,7 @@ class Driver extends AbstractSQLAnywhereDriver
*
* @throws \Doctrine\DBAL\DBALException if there was a problem establishing the connection.
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
try {
return new SQLAnywhereConnection(
......@@ -79,7 +79,7 @@ class Driver extends AbstractSQLAnywhereDriver
*
* @return string
*/
private function buildDsn($host, $port, $server, $dbname, $username = null, $password = null, array $driverOptions = array())
private function buildDsn($host, $port, $server, $dbname, $username = null, $password = null, array $driverOptions = [])
{
$host = $host ?: 'localhost';
$port = $port ?: 2638;
......
......@@ -45,7 +45,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/**
* @var string Constructor arguments for the default class to instantiate when fetch mode is \PDO::FETCH_CLASS.
*/
private $defaultFetchClassCtorArgs = array();
private $defaultFetchClassCtorArgs = [];
/**
* @var int Default fetch mode to use.
......@@ -213,7 +213,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
if (func_num_args() >= 2) {
$args = func_get_args();
$className = $args[1];
$ctorArgs = isset($args[2]) ? $args[2] : array();
$ctorArgs = isset($args[2]) ? $args[2] : [];
}
$result = sasql_fetch_object($this->result);
......@@ -237,11 +237,11 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*/
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{
$rows = array();
$rows = [];
switch ($fetchMode) {
case PDO::FETCH_CLASS:
while ($row = call_user_func_array(array($this, 'fetch'), func_get_args())) {
while ($row = call_user_func_array([$this, 'fetch'], func_get_args())) {
$rows[] = $row;
}
break;
......@@ -310,7 +310,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*
* @throws SQLAnywhereException
*/
private function castObject(\stdClass $sourceObject, $destinationClass, array $ctorArgs = array())
private function castObject(\stdClass $sourceObject, $destinationClass, array $ctorArgs = [])
{
if ( ! is_string($destinationClass)) {
if ( ! is_object($destinationClass)) {
......
......@@ -29,7 +29,7 @@ class Driver extends AbstractSQLServerDriver
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
if (!isset($params['host'])) {
throw new SQLSrvException("Missing 'host' in configuration for sqlsrv driver.");
......
......@@ -134,7 +134,7 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
{
if ($name !== null) {
$stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?');
$stmt->execute(array($name));
$stmt->execute([$name]);
return $stmt->fetchColumn();
}
......
......@@ -57,25 +57,25 @@ class SQLSrvStatement implements IteratorAggregate, Statement
*
* @var array
*/
private $variables = array();
private $variables = [];
/**
* Bound parameter types.
*
* @var array
*/
private $types = array();
private $types = [];
/**
* Translations.
*
* @var array
*/
private static $fetchMap = array(
private static $fetchMap = [
PDO::FETCH_BOTH => SQLSRV_FETCH_BOTH,
PDO::FETCH_ASSOC => SQLSRV_FETCH_ASSOC,
PDO::FETCH_NUM => SQLSRV_FETCH_NUMERIC,
);
];
/**
* The name of the default class to instantiate when fetch mode is \PDO::FETCH_CLASS.
......@@ -89,7 +89,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
*
* @var string
*/
private $defaultFetchClassCtorArgs = array();
private $defaultFetchClassCtorArgs = [];
/**
* The fetch style.
......@@ -254,16 +254,16 @@ class SQLSrvStatement implements IteratorAggregate, Statement
*/
private function prepare()
{
$params = array();
$params = [];
foreach ($this->variables as $column => &$variable) {
if (PDO::PARAM_LOB === $this->types[$column]) {
$params[$column - 1] = array(
$params[$column - 1] = [
&$variable,
SQLSRV_PARAM_IN,
SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY),
SQLSRV_SQLTYPE_VARBINARY('max'),
);
];
} else {
$params[$column - 1] =& $variable;
}
......@@ -320,13 +320,13 @@ class SQLSrvStatement implements IteratorAggregate, Statement
return sqlsrv_fetch_array($this->stmt, self::$fetchMap[$fetchMode]) ?: false;
}
if (in_array($fetchMode, array(PDO::FETCH_OBJ, PDO::FETCH_CLASS), true)) {
if (in_array($fetchMode, [PDO::FETCH_OBJ, PDO::FETCH_CLASS], true)) {
$className = $this->defaultFetchClass;
$ctorArgs = $this->defaultFetchClassCtorArgs;
if (count($args) >= 2) {
$className = $args[1];
$ctorArgs = isset($args[2]) ? $args[2] : array();
$ctorArgs = isset($args[2]) ? $args[2] : [];
}
return sqlsrv_fetch_object($this->stmt, $className, $ctorArgs) ?: false;
......@@ -340,11 +340,11 @@ class SQLSrvStatement implements IteratorAggregate, Statement
*/
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{
$rows = array();
$rows = [];
switch ($fetchMode) {
case PDO::FETCH_CLASS:
while ($row = call_user_func_array(array($this, 'fetch'), func_get_args())) {
while ($row = call_user_func_array([$this, 'fetch'], func_get_args())) {
$rows[] = $row;
}
break;
......
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