Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/php-short-array-syntax'
Browse files Browse the repository at this point in the history
  • Loading branch information
Maks3w committed Jun 5, 2015
2 parents debea31 + 4a92e53 commit ffd15a5
Show file tree
Hide file tree
Showing 201 changed files with 2,269 additions and 2,268 deletions.
1 change: 1 addition & 0 deletions .php_cs
Expand Up @@ -32,6 +32,7 @@ $config->fixers(
'object_operator',
'php_closing_tag',
'remove_lines_between_uses',
'short_array_syntax',
'short_tag',
'standardize_not_equal',
'trailing_spaces',
Expand Down
12 changes: 6 additions & 6 deletions src/Adapter/Adapter.php
Expand Up @@ -70,7 +70,7 @@ class Adapter implements AdapterInterface, Profiler\ProfilerAwareInterface
public function __construct($driver, Platform\PlatformInterface $platform = null, ResultSet\ResultSetInterface $queryResultPrototype = null, Profiler\ProfilerInterface $profiler = null)
{
// first argument can be an array of parameters
$parameters = array();
$parameters = [];

if (is_array($driver)) {
$parameters = $driver;
Expand Down Expand Up @@ -166,7 +166,7 @@ public function getCurrentSchema()
*/
public function query($sql, $parametersOrQueryMode = self::QUERY_MODE_PREPARE, ResultSet\ResultSetInterface $resultPrototype = null)
{
if (is_string($parametersOrQueryMode) && in_array($parametersOrQueryMode, array(self::QUERY_MODE_PREPARE, self::QUERY_MODE_EXECUTE))) {
if (is_string($parametersOrQueryMode) && in_array($parametersOrQueryMode, [self::QUERY_MODE_PREPARE, self::QUERY_MODE_EXECUTE])) {
$mode = $parametersOrQueryMode;
$parameters = null;
} elseif (is_array($parametersOrQueryMode) || $parametersOrQueryMode instanceof ParameterContainer) {
Expand Down Expand Up @@ -210,15 +210,15 @@ public function createStatement($initialSql = null, $initialParameters = null)
{
$statement = $this->driver->createStatement($initialSql);
if ($initialParameters === null || !$initialParameters instanceof ParameterContainer && is_array($initialParameters)) {
$initialParameters = new ParameterContainer((is_array($initialParameters) ? $initialParameters : array()));
$initialParameters = new ParameterContainer((is_array($initialParameters) ? $initialParameters : []));
}
$statement->setParameterContainer($initialParameters);
return $statement;
}

public function getHelpers(/* $functions */)
{
$functions = array();
$functions = [];
$platform = $this->platform;
foreach (func_get_args() as $arg) {
switch ($arg) {
Expand Down Expand Up @@ -270,7 +270,7 @@ protected function createDriver($parameters)
throw new Exception\InvalidArgumentException(__FUNCTION__ . ' expects a "driver" to be a string or instance of DriverInterface');
}

$options = array();
$options = [];
if (isset($parameters['options'])) {
$options = (array) $parameters['options'];
unset($parameters['options']);
Expand Down Expand Up @@ -322,7 +322,7 @@ protected function createPlatform($parameters)
}

// currently only supported by the IbmDb2 & Oracle concrete implementations
$options = (isset($parameters['platform_options'])) ? $parameters['platform_options'] : array();
$options = (isset($parameters['platform_options'])) ? $parameters['platform_options'] : [];

switch ($platformName) {
case 'Mysql':
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/AdapterAbstractServiceFactory.php
Expand Up @@ -73,23 +73,23 @@ protected function getConfig(ServiceLocatorInterface $services)
}

if (!$services->has('Config')) {
$this->config = array();
$this->config = [];
return $this->config;
}

$config = $services->get('Config');
if (!isset($config['db'])
|| !is_array($config['db'])
) {
$this->config = array();
$this->config = [];
return $this->config;
}

$config = $config['db'];
if (!isset($config['adapters'])
|| !is_array($config['adapters'])
) {
$this->config = array();
$this->config = [];
return $this->config;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Driver/AbstractConnection.php
Expand Up @@ -17,7 +17,7 @@ abstract class AbstractConnection implements ConnectionInterface, ProfilerAwareI
/**
* @var array
*/
protected $connectionParameters = array();
protected $connectionParameters = [];

/**
* @var string|null
Expand Down
10 changes: 5 additions & 5 deletions src/Adapter/Driver/IbmDb2/Connection.php
Expand Up @@ -116,11 +116,11 @@ public function connect()
return;
};

$database = $findParameterValue(array('database', 'db'));
$username = $findParameterValue(array('username', 'uid', 'UID'));
$password = $findParameterValue(array('password', 'pwd', 'PWD'));
$isPersistent = $findParameterValue(array('persistent', 'PERSISTENT', 'Persistent'));
$options = (isset($p['driver_options']) ? $p['driver_options'] : array());
$database = $findParameterValue(['database', 'db']);
$username = $findParameterValue(['username', 'uid', 'UID']);
$password = $findParameterValue(['password', 'pwd', 'PWD']);
$isPersistent = $findParameterValue(['persistent', 'PERSISTENT', 'Persistent']);
$options = (isset($p['driver_options']) ? $p['driver_options'] : []);
$connect = ((bool) $isPersistent) ? 'db2_pconnect' : 'db2_connect';

$this->resource = $connect($database, $username, $password, $options);
Expand Down
8 changes: 4 additions & 4 deletions src/Adapter/Driver/Mysqli/Connection.php
Expand Up @@ -104,10 +104,10 @@ public function connect()
return;
};

$hostname = $findParameterValue(array('hostname', 'host'));
$username = $findParameterValue(array('username', 'user'));
$password = $findParameterValue(array('password', 'passwd', 'pw'));
$database = $findParameterValue(array('database', 'dbname', 'db', 'schema'));
$hostname = $findParameterValue(['hostname', 'host']);
$username = $findParameterValue(['username', 'user']);
$password = $findParameterValue(['password', 'passwd', 'pw']);
$database = $findParameterValue(['database', 'dbname', 'db', 'schema']);
$port = (isset($p['port'])) ? (int) $p['port'] : null;
$socket = (isset($p['socket'])) ? $p['socket'] : null;

Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/Driver/Mysqli/Mysqli.php
Expand Up @@ -39,9 +39,9 @@ class Mysqli implements DriverInterface, Profiler\ProfilerAwareInterface
/**
* @var array
*/
protected $options = array(
protected $options = [
'buffer_results' => false
);
];

/**
* Constructor
Expand All @@ -51,7 +51,7 @@ class Mysqli implements DriverInterface, Profiler\ProfilerAwareInterface
* @param null|Result $resultPrototype
* @param array $options
*/
public function __construct($connection, Statement $statementPrototype = null, Result $resultPrototype = null, array $options = array())
public function __construct($connection, Statement $statementPrototype = null, Result $resultPrototype = null, array $options = [])
{
if (!$connection instanceof Connection) {
$connection = new Connection($connection);
Expand Down
8 changes: 4 additions & 4 deletions src/Adapter/Driver/Mysqli/Result.php
Expand Up @@ -59,7 +59,7 @@ class Result implements
*
* @var array
*/
protected $statementBindValues = array('keys' => null, 'values' => array());
protected $statementBindValues = ['keys' => null, 'values' => []];

/**
* @var mixed
Expand Down Expand Up @@ -189,17 +189,17 @@ protected function loadDataFromMysqliStatement()
{
// build the default reference based bind structure, if it does not already exist
if ($this->statementBindValues['keys'] === null) {
$this->statementBindValues['keys'] = array();
$this->statementBindValues['keys'] = [];
$resultResource = $this->resource->result_metadata();
foreach ($resultResource->fetch_fields() as $col) {
$this->statementBindValues['keys'][] = $col->name;
}
$this->statementBindValues['values'] = array_fill(0, count($this->statementBindValues['keys']), null);
$refs = array();
$refs = [];
foreach ($this->statementBindValues['values'] as $i => &$f) {
$refs[$i] = &$f;
}
call_user_func_array(array($this->resource, 'bind_result'), $this->statementBindValues['values']);
call_user_func_array([$this->resource, 'bind_result'], $this->statementBindValues['values']);
}

if (($r = $this->resource->fetch()) === null) {
Expand Down
4 changes: 2 additions & 2 deletions src/Adapter/Driver/Mysqli/Statement.php
Expand Up @@ -283,7 +283,7 @@ protected function bindParametersFromContainer()
{
$parameters = $this->parameterContainer->getNamedArray();
$type = '';
$args = array();
$args = [];

foreach ($parameters as $name => &$value) {
if ($this->parameterContainer->offsetHasErrata($name)) {
Expand All @@ -309,7 +309,7 @@ protected function bindParametersFromContainer()

if ($args) {
array_unshift($args, $type);
call_user_func_array(array($this->resource, 'bind_param'), $args);
call_user_func_array([$this->resource, 'bind_param'], $args);
}
}
}
14 changes: 7 additions & 7 deletions src/Adapter/Driver/Oci8/Connection.php
Expand Up @@ -104,15 +104,15 @@ public function connect()
};

// http://www.php.net/manual/en/function.oci-connect.php
$username = $findParameterValue(array('username'));
$password = $findParameterValue(array('password'));
$connectionString = $findParameterValue(array('connection_string', 'connectionstring', 'connection', 'hostname', 'instance'));
$characterSet = $findParameterValue(array('character_set', 'charset', 'encoding'));
$sessionMode = $findParameterValue(array('session_mode'));
$username = $findParameterValue(['username']);
$password = $findParameterValue(['password']);
$connectionString = $findParameterValue(['connection_string', 'connectionstring', 'connection', 'hostname', 'instance']);
$characterSet = $findParameterValue(['character_set', 'charset', 'encoding']);
$sessionMode = $findParameterValue(['session_mode']);

// connection modifiers
$isUnique = $findParameterValue(array('unique'));
$isPersistent = $findParameterValue(array('persistent'));
$isUnique = $findParameterValue(['unique']);
$isPersistent = $findParameterValue(['persistent']);

if ($isUnique == true) {
$this->resource = oci_new_connect($username, $password, $connectionString, $characterSet, $sessionMode);
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Driver/Oci8/Result.php
Expand Up @@ -52,7 +52,7 @@ class Result implements Iterator, ResultInterface
*
* @var array
*/
protected $statementBindValues = array('keys' => null, 'values' => array());
protected $statementBindValues = ['keys' => null, 'values' => []];

/**
* @var mixed
Expand Down
8 changes: 4 additions & 4 deletions src/Adapter/Driver/Pdo/Connection.php
Expand Up @@ -77,7 +77,7 @@ public function setConnectionParameters(array $connectionParameters)
$this->driverName = strtolower($connectionParameters['pdodriver']);
} elseif (isset($connectionParameters['driver'])) {
$this->driverName = strtolower(substr(
str_replace(array('-', '_', ' '), '', $connectionParameters['driver']),
str_replace(['-', '_', ' '], '', $connectionParameters['driver']),
3
));
}
Expand Down Expand Up @@ -160,7 +160,7 @@ public function connect()
}

$dsn = $username = $password = $hostname = $database = null;
$options = array();
$options = [];
foreach ($this->connectionParameters as $key => $value) {
switch (strtolower($key)) {
case 'dsn':
Expand All @@ -169,7 +169,7 @@ public function connect()
case 'driver':
$value = strtolower((string) $value);
if (strpos($value, 'pdo') === 0) {
$pdoDriver = str_replace(array('-', '_', ' '), '', $value);
$pdoDriver = str_replace(['-', '_', ' '], '', $value);
$pdoDriver = substr($pdoDriver, 3) ?: '';
$pdoDriver = strtolower($pdoDriver);
}
Expand Down Expand Up @@ -211,7 +211,7 @@ public function connect()
}

if (!isset($dsn) && isset($pdoDriver)) {
$dsn = array();
$dsn = [];
switch ($pdoDriver) {
case 'sqlite':
$dsn[] = $database;
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Driver/Pdo/Pdo.php
Expand Up @@ -41,7 +41,7 @@ class Pdo implements DriverInterface, DriverFeatureInterface, Profiler\ProfilerA
/**
* @var array
*/
protected $features = array();
protected $features = [];

/**
* @param array|Connection|\PDO $connection
Expand Down
12 changes: 6 additions & 6 deletions src/Adapter/Driver/Pgsql/Connection.php
Expand Up @@ -261,14 +261,14 @@ private function getConnectionString()
return;
};

$connectionParameters = array(
'host' => $findParameterValue(array('hostname', 'host')),
'user' => $findParameterValue(array('username', 'user')),
'password' => $findParameterValue(array('password', 'passwd', 'pw')),
'dbname' => $findParameterValue(array('database', 'dbname', 'db', 'schema')),
$connectionParameters = [
'host' => $findParameterValue(['hostname', 'host']),
'user' => $findParameterValue(['username', 'user']),
'password' => $findParameterValue(['password', 'passwd', 'pw']),
'dbname' => $findParameterValue(['database', 'dbname', 'db', 'schema']),
'port' => isset($p['port']) ? (int) $p['port'] : null,
'socket' => isset($p['socket']) ? $p['socket'] : null,
);
];

return urldecode(http_build_query(array_filter($connectionParameters), null, ' '));
}
Expand Down
4 changes: 2 additions & 2 deletions src/Adapter/Driver/Pgsql/Pgsql.php
Expand Up @@ -38,9 +38,9 @@ class Pgsql implements DriverInterface, Profiler\ProfilerAwareInterface
/**
* @var array
*/
protected $options = array(
protected $options = [
'buffer_results' => false
);
];

/**
* Constructor
Expand Down
4 changes: 2 additions & 2 deletions src/Adapter/Driver/Sqlsrv/Connection.php
Expand Up @@ -94,9 +94,9 @@ public function connect()
}

$serverName = '.';
$params = array(
$params = [
'ReturnDatesAsStrings' => true
);
];
foreach ($this->connectionParameters as $key => $value) {
switch (strtolower($key)) {
case 'hostname':
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Driver/Sqlsrv/Exception/ErrorException.php
Expand Up @@ -18,7 +18,7 @@ class ErrorException extends Exception\ErrorException implements ExceptionInterf
*
* @var array
*/
protected $errors = array();
protected $errors = [];

/**
* Construct
Expand Down
10 changes: 5 additions & 5 deletions src/Adapter/Driver/Sqlsrv/Statement.php
Expand Up @@ -45,7 +45,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface
/**
* @var array
*/
protected $parameterReferences = array();
protected $parameterReferences = [];

/**
* @var ParameterContainer
Expand All @@ -66,12 +66,12 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface
/**
* @var array
*/
protected $prepareParams = array();
protected $prepareParams = [];

/**
* @var array
*/
protected $prepareOptions = array();
protected $prepareOptions = [];

/**
* Set driver
Expand Down Expand Up @@ -196,7 +196,7 @@ public function getSql()
* @throws Exception\RuntimeException
* @return Statement
*/
public function prepare($sql = null, array $options = array())
public function prepare($sql = null, array $options = [])
{
if ($this->isPrepared) {
throw new Exception\RuntimeException('Already prepared');
Expand All @@ -207,7 +207,7 @@ public function prepare($sql = null, array $options = array())
$pRef = &$this->parameterReferences;
for ($position = 0, $count = substr_count($sql, '?'); $position < $count; $position++) {
if (!isset($this->prepareParams[$position])) {
$pRef[$position] = array('', SQLSRV_PARAM_IN, null, null);
$pRef[$position] = ['', SQLSRV_PARAM_IN, null, null];
} else {
$pRef[$position] = &$this->prepareParams[$position];
}
Expand Down

0 comments on commit ffd15a5

Please sign in to comment.