Skip to content

Commit

Permalink
Merge pull request #2789 from AlessandroMinoccheri/fix_array_short_de…
Browse files Browse the repository at this point in the history
…clarations

Use short array declarations
  • Loading branch information
Ocramius authored Aug 3, 2017
2 parents 49d44a7 + 80f42dc commit 4f7c1b7
Show file tree
Hide file tree
Showing 87 changed files with 500 additions and 499 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Cache/ArrayStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
*/
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{
$rows = array();
$rows = [];
while ($row = $this->fetch($fetchMode)) {
$rows[] = $row;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function closeCursor()
if ($this->emptied && $this->data !== null) {
$data = $this->resultCache->fetch($this->cacheKey);
if ( ! $data) {
$data = array();
$data = [];
}
$data[$this->realKey] = $this->data;

Expand Down Expand Up @@ -150,7 +150,7 @@ public function getIterator()
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{
if ($this->data === null) {
$this->data = array();
$this->data = [];
}

$row = $this->statement->fetch(PDO::FETCH_ASSOC);
Expand Down Expand Up @@ -181,7 +181,7 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
*/
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{
$rows = array();
$rows = [];
while ($row = $this->fetch($fetchMode)) {
$rows[] = $row;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Configuration
*
* @var array
*/
protected $_attributes = array();
protected $_attributes = [];

/**
* Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
Expand Down
44 changes: 22 additions & 22 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Connection implements DriverConnection
*
* @var array
*/
private $_params = array();
private $_params = [];

/**
* The DatabasePlatform object that provides information about the
Expand Down Expand Up @@ -357,7 +357,7 @@ public function connect()
}

$driverOptions = isset($this->_params['driverOptions']) ?
$this->_params['driverOptions'] : array();
$this->_params['driverOptions'] : [];
$user = isset($this->_params['user']) ? $this->_params['user'] : null;
$password = isset($this->_params['password']) ?
$this->_params['password'] : null;
Expand Down Expand Up @@ -552,7 +552,7 @@ public function setFetchMode($fetchMode)
*
* @throws \Doctrine\DBAL\DBALException
*/
public function fetchAssoc($statement, array $params = array(), array $types = array())
public function fetchAssoc($statement, array $params = [], array $types = [])
{
return $this->executeQuery($statement, $params, $types)->fetch(PDO::FETCH_ASSOC);
}
Expand All @@ -567,7 +567,7 @@ public function fetchAssoc($statement, array $params = array(), array $types = a
*
* @return array|bool False is returned if no rows are found.
*/
public function fetchArray($statement, array $params = array(), array $types = array())
public function fetchArray($statement, array $params = [], array $types = [])
{
return $this->executeQuery($statement, $params, $types)->fetch(PDO::FETCH_NUM);
}
Expand All @@ -585,7 +585,7 @@ public function fetchArray($statement, array $params = array(), array $types = a
*
* @throws \Doctrine\DBAL\DBALException
*/
public function fetchColumn($statement, array $params = array(), $column = 0, array $types = array())
public function fetchColumn($statement, array $params = [], $column = 0, array $types = [])
{
return $this->executeQuery($statement, $params, $types)->fetchColumn($column);
}
Expand Down Expand Up @@ -654,7 +654,7 @@ private function gatherConditions(array $identifiers)
* @throws \Doctrine\DBAL\DBALException
* @throws InvalidArgumentException
*/
public function delete($tableExpression, array $identifier, array $types = array())
public function delete($tableExpression, array $identifier, array $types = [])
{
if (empty($identifier)) {
throw InvalidArgumentException::fromEmptyCriteria();
Expand Down Expand Up @@ -723,11 +723,11 @@ public function getTransactionIsolation()
*
* @throws \Doctrine\DBAL\DBALException
*/
public function update($tableExpression, array $data, array $identifier, array $types = array())
public function update($tableExpression, array $data, array $identifier, array $types = [])
{
$setColumns = array();
$setValues = array();
$set = array();
$setColumns = [];
$setValues = [];
$set = [];

foreach ($data as $columnName => $value) {
$setColumns[] = $columnName;
Expand Down Expand Up @@ -762,15 +762,15 @@ public function update($tableExpression, array $data, array $identifier, array $
*
* @throws \Doctrine\DBAL\DBALException
*/
public function insert($tableExpression, array $data, array $types = array())
public function insert($tableExpression, array $data, array $types = [])
{
if (empty($data)) {
return $this->executeUpdate('INSERT INTO ' . $tableExpression . ' ()' . ' VALUES ()');
}

$columns = array();
$values = array();
$set = array();
$columns = [];
$values = [];
$set = [];

foreach ($data as $columnName => $value) {
$columns[] = $columnName;
Expand All @@ -796,7 +796,7 @@ public function insert($tableExpression, array $data, array $types = array())
*/
private function extractTypeValues(array $columnList, array $types)
{
$typeValues = array();
$typeValues = [];

foreach ($columnList as $columnIndex => $columnName) {
$typeValues[] = isset($types[$columnName])
Expand Down Expand Up @@ -852,7 +852,7 @@ public function quote($input, $type = null)
*
* @return array
*/
public function fetchAll($sql, array $params = array(), $types = array())
public function fetchAll($sql, array $params = [], $types = [])
{
return $this->executeQuery($sql, $params, $types)->fetchAll();
}
Expand Down Expand Up @@ -894,7 +894,7 @@ public function prepare($statement)
*
* @throws \Doctrine\DBAL\DBALException
*/
public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null)
public function executeQuery($query, array $params = [], $types = [], QueryCacheProfile $qcp = null)
{
if ($qcp !== null) {
return $this->executeCacheQuery($query, $params, $types, $qcp);
Expand Down Expand Up @@ -961,7 +961,7 @@ public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qc
if (isset($data[$realKey])) {
$stmt = new ArrayStatement($data[$realKey]);
} elseif (array_key_exists($realKey, $data)) {
$stmt = new ArrayStatement(array());
$stmt = new ArrayStatement([]);
}
}

Expand All @@ -988,7 +988,7 @@ public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qc
*/
public function project($query, array $params, Closure $function)
{
$result = array();
$result = [];
$stmt = $this->executeQuery($query, $params);

while ($row = $stmt->fetch()) {
Expand Down Expand Up @@ -1047,7 +1047,7 @@ public function query()
*
* @throws \Doctrine\DBAL\DBALException
*/
public function executeUpdate($query, array $params = array(), array $types = array())
public function executeUpdate($query, array $params = [], array $types = [])
{
$this->connect();

Expand Down Expand Up @@ -1588,7 +1588,7 @@ private function getBindingInfo($value, $type)
$bindingType = $type; // PDO::PARAM_* constants
}

return array($value, $bindingType);
return [$value, $bindingType];
}

/**
Expand All @@ -1604,7 +1604,7 @@ private function getBindingInfo($value, $type)
*/
public function resolveParams(array $params, array $types)
{
$resolvedParams = array();
$resolvedParams = [];

// Check whether parameters are positional or named. Mixing is not allowed, just like in PDO.
if (is_int(key($params))) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public function close()
parent::close();

$this->_conn = null;
$this->connections = array('master' => null, 'slave' => null);
$this->connections = ['master' => null, 'slave' => null];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/DBALException.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static function unknownDriver($unknownDriverName, array $knownDrivers)
*
* @return \Doctrine\DBAL\DBALException
*/
public static function driverExceptionDuringQuery(Driver $driver, \Exception $driverEx, $sql, array $params = array())
public static function driverExceptionDuringQuery(Driver $driver, \Exception $driverEx, $sql, array $params = [])
{
$msg = "An exception occurred while executing '".$sql."'";
if ($params) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface Driver
*
* @return \Doctrine\DBAL\Driver\Connection The database connection.
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array());
public function connect(array $params, $username = null, $password = null, array $driverOptions = []);

/**
* Gets the DatabasePlatform instance that provides all the metadata about
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/DriverManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private static function parseDatabaseUrlQuery(array $url, array $params): array
return $params;
}

$query = array();
$query = [];

parse_str($url['query'], $query); // simply ingest query as extra params, e.g. charset or sslmode

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ public function postConnect(ConnectionEventArgs $args)
*/
public function getSubscribedEvents()
{
return array(Events::postConnect);
return [Events::postConnect];
}
}
10 changes: 5 additions & 5 deletions lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ class OracleSessionInit implements EventSubscriber
/**
* @var array
*/
protected $_defaultSessionVars = array(
protected $_defaultSessionVars = [
'NLS_TIME_FORMAT' => "HH24:MI:SS",
'NLS_DATE_FORMAT' => "YYYY-MM-DD HH24:MI:SS",
'NLS_TIMESTAMP_FORMAT' => "YYYY-MM-DD HH24:MI:SS",
'NLS_TIMESTAMP_TZ_FORMAT' => "YYYY-MM-DD HH24:MI:SS TZH:TZM",
'NLS_NUMERIC_CHARACTERS' => ".,",
);
];

/**
* @param array $oracleSessionVars
*/
public function __construct(array $oracleSessionVars = array())
public function __construct(array $oracleSessionVars = [])
{
$this->_defaultSessionVars = array_merge($this->_defaultSessionVars, $oracleSessionVars);
}
Expand All @@ -67,7 +67,7 @@ public function postConnect(ConnectionEventArgs $args)
{
if (count($this->_defaultSessionVars)) {
array_change_key_case($this->_defaultSessionVars, \CASE_UPPER);
$vars = array();
$vars = [];
foreach ($this->_defaultSessionVars as $option => $value) {
if ($option === 'CURRENT_SCHEMA') {
$vars[] = $option . " = " . $value;
Expand All @@ -85,6 +85,6 @@ public function postConnect(ConnectionEventArgs $args)
*/
public function getSubscribedEvents()
{
return array(Events::postConnect);
return [Events::postConnect];
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ public function postConnect(ConnectionEventArgs $args)
*/
public function getSubscribedEvents()
{
return array(Events::postConnect);
return [Events::postConnect];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs
/**
* @var array
*/
private $_sql = array();
private $_sql = [];

/**
* @param \Doctrine\DBAL\Schema\Column $column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
/**
* @var array
*/
private $_sql = array();
private $_sql = [];

/**
* @param \Doctrine\DBAL\Schema\ColumnDiff $columnDiff
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs
/**
* @var array
*/
private $_sql = array();
private $_sql = [];

/**
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs
/**
* @var array
*/
private $_sql = array();
private $_sql = [];

/**
* @param \Doctrine\DBAL\Schema\Column $column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
/**
* @var array
*/
private $_sql = array();
private $_sql = [];

/**
* @param string $oldColumnName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
/**
* @var array
*/
private $_sql = array();
private $_sql = [];

/**
* @param \Doctrine\DBAL\Schema\Column $column
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
/**
* @var array
*/
private $_sql = array();
private $_sql = [];

/**
* @param \Doctrine\DBAL\Schema\Table $table
Expand Down
Loading

0 comments on commit 4f7c1b7

Please sign in to comment.