diff --git a/.php_cs b/.php_cs index 6b3d68bc49..8f4dd5aac9 100644 --- a/.php_cs +++ b/.php_cs @@ -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', diff --git a/src/Adapter/Adapter.php b/src/Adapter/Adapter.php index 3771b94c8e..ad6f9b1dc5 100644 --- a/src/Adapter/Adapter.php +++ b/src/Adapter/Adapter.php @@ -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; @@ -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) { @@ -210,7 +210,7 @@ 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; @@ -218,7 +218,7 @@ public function createStatement($initialSql = null, $initialParameters = null) public function getHelpers(/* $functions */) { - $functions = array(); + $functions = []; $platform = $this->platform; foreach (func_get_args() as $arg) { switch ($arg) { @@ -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']); @@ -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': diff --git a/src/Adapter/AdapterAbstractServiceFactory.php b/src/Adapter/AdapterAbstractServiceFactory.php index b40865e7ac..7b90b14603 100644 --- a/src/Adapter/AdapterAbstractServiceFactory.php +++ b/src/Adapter/AdapterAbstractServiceFactory.php @@ -73,7 +73,7 @@ protected function getConfig(ServiceLocatorInterface $services) } if (!$services->has('Config')) { - $this->config = array(); + $this->config = []; return $this->config; } @@ -81,7 +81,7 @@ protected function getConfig(ServiceLocatorInterface $services) if (!isset($config['db']) || !is_array($config['db']) ) { - $this->config = array(); + $this->config = []; return $this->config; } @@ -89,7 +89,7 @@ protected function getConfig(ServiceLocatorInterface $services) if (!isset($config['adapters']) || !is_array($config['adapters']) ) { - $this->config = array(); + $this->config = []; return $this->config; } diff --git a/src/Adapter/Driver/AbstractConnection.php b/src/Adapter/Driver/AbstractConnection.php index 09cb075d50..8439fc121d 100644 --- a/src/Adapter/Driver/AbstractConnection.php +++ b/src/Adapter/Driver/AbstractConnection.php @@ -17,7 +17,7 @@ abstract class AbstractConnection implements ConnectionInterface, ProfilerAwareI /** * @var array */ - protected $connectionParameters = array(); + protected $connectionParameters = []; /** * @var string|null diff --git a/src/Adapter/Driver/IbmDb2/Connection.php b/src/Adapter/Driver/IbmDb2/Connection.php index 3d474c9b7c..0065bc5655 100644 --- a/src/Adapter/Driver/IbmDb2/Connection.php +++ b/src/Adapter/Driver/IbmDb2/Connection.php @@ -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); diff --git a/src/Adapter/Driver/Mysqli/Connection.php b/src/Adapter/Driver/Mysqli/Connection.php index b855ee1249..d7a5282b0d 100644 --- a/src/Adapter/Driver/Mysqli/Connection.php +++ b/src/Adapter/Driver/Mysqli/Connection.php @@ -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; diff --git a/src/Adapter/Driver/Mysqli/Mysqli.php b/src/Adapter/Driver/Mysqli/Mysqli.php index 4fcc55842a..b7bbc62665 100644 --- a/src/Adapter/Driver/Mysqli/Mysqli.php +++ b/src/Adapter/Driver/Mysqli/Mysqli.php @@ -39,9 +39,9 @@ class Mysqli implements DriverInterface, Profiler\ProfilerAwareInterface /** * @var array */ - protected $options = array( + protected $options = [ 'buffer_results' => false - ); + ]; /** * Constructor @@ -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); diff --git a/src/Adapter/Driver/Mysqli/Result.php b/src/Adapter/Driver/Mysqli/Result.php index d4af5c5c0c..372b7a4d1e 100644 --- a/src/Adapter/Driver/Mysqli/Result.php +++ b/src/Adapter/Driver/Mysqli/Result.php @@ -59,7 +59,7 @@ class Result implements * * @var array */ - protected $statementBindValues = array('keys' => null, 'values' => array()); + protected $statementBindValues = ['keys' => null, 'values' => []]; /** * @var mixed @@ -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) { diff --git a/src/Adapter/Driver/Mysqli/Statement.php b/src/Adapter/Driver/Mysqli/Statement.php index 361ec3f508..7c174256ab 100644 --- a/src/Adapter/Driver/Mysqli/Statement.php +++ b/src/Adapter/Driver/Mysqli/Statement.php @@ -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)) { @@ -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); } } } diff --git a/src/Adapter/Driver/Oci8/Connection.php b/src/Adapter/Driver/Oci8/Connection.php index 4a231917be..8dbd489a18 100644 --- a/src/Adapter/Driver/Oci8/Connection.php +++ b/src/Adapter/Driver/Oci8/Connection.php @@ -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); diff --git a/src/Adapter/Driver/Oci8/Result.php b/src/Adapter/Driver/Oci8/Result.php index 03111b9d47..fd621a4caf 100644 --- a/src/Adapter/Driver/Oci8/Result.php +++ b/src/Adapter/Driver/Oci8/Result.php @@ -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 diff --git a/src/Adapter/Driver/Pdo/Connection.php b/src/Adapter/Driver/Pdo/Connection.php index 6e5f22cf5f..fb4c7a406b 100644 --- a/src/Adapter/Driver/Pdo/Connection.php +++ b/src/Adapter/Driver/Pdo/Connection.php @@ -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 )); } @@ -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': @@ -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); } @@ -211,7 +211,7 @@ public function connect() } if (!isset($dsn) && isset($pdoDriver)) { - $dsn = array(); + $dsn = []; switch ($pdoDriver) { case 'sqlite': $dsn[] = $database; diff --git a/src/Adapter/Driver/Pdo/Pdo.php b/src/Adapter/Driver/Pdo/Pdo.php index c70afa8da6..d40cbdafd2 100644 --- a/src/Adapter/Driver/Pdo/Pdo.php +++ b/src/Adapter/Driver/Pdo/Pdo.php @@ -41,7 +41,7 @@ class Pdo implements DriverInterface, DriverFeatureInterface, Profiler\ProfilerA /** * @var array */ - protected $features = array(); + protected $features = []; /** * @param array|Connection|\PDO $connection diff --git a/src/Adapter/Driver/Pgsql/Connection.php b/src/Adapter/Driver/Pgsql/Connection.php index ea2025a7c8..0f423dc3b0 100644 --- a/src/Adapter/Driver/Pgsql/Connection.php +++ b/src/Adapter/Driver/Pgsql/Connection.php @@ -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, ' ')); } diff --git a/src/Adapter/Driver/Pgsql/Pgsql.php b/src/Adapter/Driver/Pgsql/Pgsql.php index b186fe8298..f93df8cfba 100644 --- a/src/Adapter/Driver/Pgsql/Pgsql.php +++ b/src/Adapter/Driver/Pgsql/Pgsql.php @@ -38,9 +38,9 @@ class Pgsql implements DriverInterface, Profiler\ProfilerAwareInterface /** * @var array */ - protected $options = array( + protected $options = [ 'buffer_results' => false - ); + ]; /** * Constructor diff --git a/src/Adapter/Driver/Sqlsrv/Connection.php b/src/Adapter/Driver/Sqlsrv/Connection.php index 7ce54d90be..fc0ee7e361 100644 --- a/src/Adapter/Driver/Sqlsrv/Connection.php +++ b/src/Adapter/Driver/Sqlsrv/Connection.php @@ -94,9 +94,9 @@ public function connect() } $serverName = '.'; - $params = array( + $params = [ 'ReturnDatesAsStrings' => true - ); + ]; foreach ($this->connectionParameters as $key => $value) { switch (strtolower($key)) { case 'hostname': diff --git a/src/Adapter/Driver/Sqlsrv/Exception/ErrorException.php b/src/Adapter/Driver/Sqlsrv/Exception/ErrorException.php index 40b15abec4..41a93903e7 100644 --- a/src/Adapter/Driver/Sqlsrv/Exception/ErrorException.php +++ b/src/Adapter/Driver/Sqlsrv/Exception/ErrorException.php @@ -18,7 +18,7 @@ class ErrorException extends Exception\ErrorException implements ExceptionInterf * * @var array */ - protected $errors = array(); + protected $errors = []; /** * Construct diff --git a/src/Adapter/Driver/Sqlsrv/Statement.php b/src/Adapter/Driver/Sqlsrv/Statement.php index 0a40bc58a9..8e47ac953f 100644 --- a/src/Adapter/Driver/Sqlsrv/Statement.php +++ b/src/Adapter/Driver/Sqlsrv/Statement.php @@ -45,7 +45,7 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface /** * @var array */ - protected $parameterReferences = array(); + protected $parameterReferences = []; /** * @var ParameterContainer @@ -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 @@ -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'); @@ -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]; } diff --git a/src/Adapter/ParameterContainer.php b/src/Adapter/ParameterContainer.php index 9c180b8fb9..dd5694b8f8 100644 --- a/src/Adapter/ParameterContainer.php +++ b/src/Adapter/ParameterContainer.php @@ -28,33 +28,33 @@ class ParameterContainer implements Iterator, ArrayAccess, Countable * * @var array */ - protected $data = array(); + protected $data = []; /** * @var array */ - protected $positions = array(); + protected $positions = []; /** * Errata * * @var array */ - protected $errata = array(); + protected $errata = []; /** * Max length * * @var array */ - protected $maxLength = array(); + protected $maxLength = []; /** * Constructor * * @param array $data */ - public function __construct(array $data = array()) + public function __construct(array $data = []) { if ($data) { $this->setFromArray($data); diff --git a/src/Adapter/Platform/AbstractPlatform.php b/src/Adapter/Platform/AbstractPlatform.php index 44d0d5c71f..48bf33aa3a 100755 --- a/src/Adapter/Platform/AbstractPlatform.php +++ b/src/Adapter/Platform/AbstractPlatform.php @@ -14,7 +14,7 @@ abstract class AbstractPlatform implements PlatformInterface /** * @var string[] */ - protected $quoteIdentifier = array('"', '"'); + protected $quoteIdentifier = ['"', '"']; /** * @var string @@ -29,13 +29,13 @@ abstract class AbstractPlatform implements PlatformInterface /** * {@inheritDoc} */ - public function quoteIdentifierInFragment($identifier, array $safeWords = array()) + public function quoteIdentifierInFragment($identifier, array $safeWords = []) { if (! $this->quoteIdentifiers) { return $identifier; } - $safeWordsInt = array('*' => true, ' ' => true, '.' => true, 'as' => true); + $safeWordsInt = ['*' => true, ' ' => true, '.' => true, 'as' => true]; foreach ($safeWords as $sWord) { $safeWordsInt[strtolower($sWord)] = true; @@ -124,7 +124,7 @@ public function quoteTrustedValue($value) */ public function quoteValueList($valueList) { - return implode(', ', array_map(array($this, 'quoteValue'), (array) $valueList)); + return implode(', ', array_map([$this, 'quoteValue'], (array) $valueList)); } /** diff --git a/src/Adapter/Platform/IbmDb2.php b/src/Adapter/Platform/IbmDb2.php index 4f6ea19e65..6c8b69d4b6 100644 --- a/src/Adapter/Platform/IbmDb2.php +++ b/src/Adapter/Platform/IbmDb2.php @@ -19,7 +19,7 @@ class IbmDb2 extends AbstractPlatform /** * @param array $options */ - public function __construct($options = array()) + public function __construct($options = []) { if (isset($options['quote_identifiers']) && ($options['quote_identifiers'] == false diff --git a/src/Adapter/Platform/Mysql.php b/src/Adapter/Platform/Mysql.php index 42fc769bbe..3809a29c18 100644 --- a/src/Adapter/Platform/Mysql.php +++ b/src/Adapter/Platform/Mysql.php @@ -19,7 +19,7 @@ class Mysql extends AbstractPlatform /** * {@inheritDoc} */ - protected $quoteIdentifier = array('`', '`'); + protected $quoteIdentifier = ['`', '`']; /** * {@inheritDoc} diff --git a/src/Adapter/Platform/Oracle.php b/src/Adapter/Platform/Oracle.php index cb64ab34ed..a589e09822 100644 --- a/src/Adapter/Platform/Oracle.php +++ b/src/Adapter/Platform/Oracle.php @@ -14,7 +14,7 @@ class Oracle extends AbstractPlatform /** * @param array $options */ - public function __construct($options = array()) + public function __construct($options = []) { if (isset($options['quote_identifiers']) && ($options['quote_identifiers'] == false diff --git a/src/Adapter/Platform/PlatformInterface.php b/src/Adapter/Platform/PlatformInterface.php index f0f39f989c..3f2820baba 100644 --- a/src/Adapter/Platform/PlatformInterface.php +++ b/src/Adapter/Platform/PlatformInterface.php @@ -90,5 +90,5 @@ public function getIdentifierSeparator(); * @param array $additionalSafeWords * @return string */ - public function quoteIdentifierInFragment($identifier, array $additionalSafeWords = array()); + public function quoteIdentifierInFragment($identifier, array $additionalSafeWords = []); } diff --git a/src/Adapter/Platform/Postgresql.php b/src/Adapter/Platform/Postgresql.php index 440e9a7844..707d44fa32 100644 --- a/src/Adapter/Platform/Postgresql.php +++ b/src/Adapter/Platform/Postgresql.php @@ -47,7 +47,7 @@ public function setDriver($driver) { if ($driver instanceof Pgsql\Pgsql || ($driver instanceof Pdo\Pdo && $driver->getDatabasePlatformName() == 'Postgresql') - || (is_resource($driver) && (in_array(get_resource_type($driver), array('pgsql link', 'pgsql link persistent')))) + || (is_resource($driver) && (in_array(get_resource_type($driver), ['pgsql link', 'pgsql link persistent']))) || ($driver instanceof \PDO && $driver->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'pgsql') ) { $this->resource = $driver; diff --git a/src/Adapter/Platform/SqlServer.php b/src/Adapter/Platform/SqlServer.php index 5716c06b5b..9fcc59fcec 100644 --- a/src/Adapter/Platform/SqlServer.php +++ b/src/Adapter/Platform/SqlServer.php @@ -18,7 +18,7 @@ class SqlServer extends AbstractPlatform /** * {@inheritDoc} */ - protected $quoteIdentifier = array('[',']'); + protected $quoteIdentifier = ['[',']']; /** * {@inheritDoc} @@ -49,8 +49,8 @@ public function __construct($driver = null) public function setDriver($driver) { // handle Zend\Db drivers - if (($driver instanceof Pdo\Pdo && in_array($driver->getDatabasePlatformName(), array('SqlServer', 'Dblib'))) - || (($driver instanceof \PDO && in_array($driver->getAttribute(\PDO::ATTR_DRIVER_NAME), array('sqlsrv', 'dblib')))) + if (($driver instanceof Pdo\Pdo && in_array($driver->getDatabasePlatformName(), ['SqlServer', 'Dblib'])) + || (($driver instanceof \PDO && in_array($driver->getAttribute(\PDO::ATTR_DRIVER_NAME), ['sqlsrv', 'dblib']))) ) { $this->resource = $driver; return $this; diff --git a/src/Adapter/Platform/Sqlite.php b/src/Adapter/Platform/Sqlite.php index 46fece87ca..2b0e82a5dc 100644 --- a/src/Adapter/Platform/Sqlite.php +++ b/src/Adapter/Platform/Sqlite.php @@ -18,7 +18,7 @@ class Sqlite extends AbstractPlatform /** * {@inheritDoc} */ - protected $quoteIdentifier = array('"','"'); + protected $quoteIdentifier = ['"','"']; /** * {@inheritDoc} diff --git a/src/Adapter/Profiler/Profiler.php b/src/Adapter/Profiler/Profiler.php index ca0cad0577..2754971216 100644 --- a/src/Adapter/Profiler/Profiler.php +++ b/src/Adapter/Profiler/Profiler.php @@ -17,7 +17,7 @@ class Profiler implements ProfilerInterface /** * @var array */ - protected $profiles = array(); + protected $profiles = []; /** * @var null @@ -31,13 +31,13 @@ class Profiler implements ProfilerInterface */ public function profilerStart($target) { - $profileInformation = array( + $profileInformation = [ 'sql' => '', 'parameters' => null, 'start' => microtime(true), 'end' => null, 'elapse' => null - ); + ]; if ($target instanceof StatementContainerInterface) { $profileInformation['sql'] = $target->getSql(); $profileInformation['parameters'] = clone $target->getParameterContainer(); diff --git a/src/Metadata/Object/ColumnObject.php b/src/Metadata/Object/ColumnObject.php index a9b1288c1a..9c51bd345b 100644 --- a/src/Metadata/Object/ColumnObject.php +++ b/src/Metadata/Object/ColumnObject.php @@ -87,7 +87,7 @@ class ColumnObject * * @var array */ - protected $errata = array(); + protected $errata = []; /** * Constructor diff --git a/src/Metadata/Object/ConstraintObject.php b/src/Metadata/Object/ConstraintObject.php index 4c10c296f2..11e09ca49f 100644 --- a/src/Metadata/Object/ConstraintObject.php +++ b/src/Metadata/Object/ConstraintObject.php @@ -41,7 +41,7 @@ class ConstraintObject * * @var string[] */ - protected $columns = array(); + protected $columns = []; /** * diff --git a/src/Metadata/Source/AbstractSource.php b/src/Metadata/Source/AbstractSource.php index 7b57dc29b3..4fc003fefd 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -33,7 +33,7 @@ abstract class AbstractSource implements MetadataInterface * * @var array */ - protected $data = array(); + protected $data = []; /** * Constructor @@ -76,7 +76,7 @@ public function getTableNames($schema = null, $includeViews = false) return array_keys($this->data['table_names'][$schema]); } - $tableNames = array(); + $tableNames = []; foreach ($this->data['table_names'][$schema] as $tableName => $data) { if ('BASE TABLE' == $data['table_type']) { $tableNames[] = $tableName; @@ -98,7 +98,7 @@ public function getTables($schema = null, $includeViews = false) $schema = $this->defaultSchema; } - $tables = array(); + $tables = []; foreach ($this->getTableNames($schema, $includeViews) as $tableName) { $tables[] = $this->getTable($tableName, $schema); } @@ -157,7 +157,7 @@ public function getViewNames($schema = null) $this->loadTableNameData($schema); - $viewNames = array(); + $viewNames = []; foreach ($this->data['table_names'][$schema] as $tableName => $data) { if ('VIEW' == $data['table_type']) { $viewNames[] = $tableName; @@ -178,7 +178,7 @@ public function getViews($schema = null) $schema = $this->defaultSchema; } - $views = array(); + $views = []; foreach ($this->getViewNames($schema) as $tableName) { $views[] = $this->getTable($tableName, $schema); } @@ -244,7 +244,7 @@ public function getColumns($table, $schema = null) $this->loadColumnData($table, $schema); - $columns = array(); + $columns = []; foreach ($this->getColumnNames($table, $schema) as $columnName) { $columns[] = $this->getColumn($columnName, $table, $schema); } @@ -274,12 +274,12 @@ public function getColumn($columnName, $table, $schema = null) $info = $this->data['columns'][$schema][$table][$columnName]; $column = new Object\ColumnObject($columnName, $table, $schema); - $props = array( + $props = [ 'ordinal_position', 'column_default', 'is_nullable', 'data_type', 'character_maximum_length', 'character_octet_length', 'numeric_precision', 'numeric_scale', 'numeric_unsigned', 'erratas' - ); + ]; foreach ($props as $prop) { if (isset($info[$prop])) { $column->{'set' . str_replace('_', '', $prop)}($info[$prop]); @@ -315,7 +315,7 @@ public function getConstraints($table, $schema = null) $this->loadConstraintData($table, $schema); - $constraints = array(); + $constraints = []; foreach (array_keys($this->data['constraints'][$schema][$table]) as $constraintName) { $constraints[] = $this->getConstraint($constraintName, $table, $schema); } @@ -346,7 +346,7 @@ public function getConstraint($constraintName, $table, $schema = null) $info = $this->data['constraints'][$schema][$table][$constraintName]; $constraint = new Object\ConstraintObject($constraintName, $table, $schema); - foreach (array( + foreach ([ 'constraint_type' => 'setType', 'match_option' => 'setMatchOption', 'update_rule' => 'setUpdateRule', @@ -356,7 +356,7 @@ public function getConstraint($constraintName, $table, $schema = null) 'referenced_table_name' => 'setReferencedTableName', 'referenced_columns' => 'setReferencedColumns', 'check_clause' => 'setCheckClause', - ) as $key => $setMethod) { + ] as $key => $setMethod) { if (isset($info[$key])) { $constraint->{$setMethod}($info[$key]); } @@ -382,7 +382,7 @@ public function getConstraintKeys($constraint, $table, $schema = null) $this->loadConstraintReferences($table, $schema); // organize references first - $references = array(); + $references = []; foreach ($this->data['constraint_references'][$schema] as $refKeyInfo) { if ($refKeyInfo['constraint_name'] == $constraint) { $references[$refKeyInfo['constraint_name']] = $refKeyInfo; @@ -391,7 +391,7 @@ public function getConstraintKeys($constraint, $table, $schema = null) $this->loadConstraintDataKeys($schema); - $keys = array(); + $keys = []; foreach ($this->data['constraint_keys'][$schema] as $constraintKeyInfo) { if ($constraintKeyInfo['table_name'] == $table && $constraintKeyInfo['constraint_name'] === $constraint) { $keys[] = $key = new Object\ConstraintKeyObject($constraintKeyInfo['column_name']); @@ -439,7 +439,7 @@ public function getTriggers($schema = null) $schema = $this->defaultSchema; } - $triggers = array(); + $triggers = []; foreach ($this->getTriggerNames($schema) as $triggerName) { $triggers[] = $this->getTrigger($triggerName, $schema); } @@ -499,7 +499,7 @@ protected function prepareDataHierarchy($type) $data = &$this->data; foreach (func_get_args() as $key) { if (!isset($data[$key])) { - $data[$key] = array(); + $data[$key] = []; } $data = &$data[$key]; } diff --git a/src/Metadata/Source/MysqlMetadata.php b/src/Metadata/Source/MysqlMetadata.php index 4c28f3f252..f3d641b9e2 100644 --- a/src/Metadata/Source/MysqlMetadata.php +++ b/src/Metadata/Source/MysqlMetadata.php @@ -23,13 +23,13 @@ protected function loadSchemaData() $p = $this->adapter->getPlatform(); $sql = 'SELECT ' . $p->quoteIdentifier('SCHEMA_NAME') - . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'SCHEMATA')) + . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'SCHEMATA']) . ' WHERE ' . $p->quoteIdentifier('SCHEMA_NAME') . ' != \'INFORMATION_SCHEMA\''; $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $schemas = array(); + $schemas = []; foreach ($results->toArray() as $row) { $schemas[] = $row['SCHEMA_NAME']; } @@ -46,46 +46,46 @@ protected function loadTableNameData($schema) $p = $this->adapter->getPlatform(); - $isColumns = array( - array('T', 'TABLE_NAME'), - array('T', 'TABLE_TYPE'), - array('V', 'VIEW_DEFINITION'), - array('V', 'CHECK_OPTION'), - array('V', 'IS_UPDATABLE'), - ); + $isColumns = [ + ['T', 'TABLE_NAME'], + ['T', 'TABLE_TYPE'], + ['V', 'VIEW_DEFINITION'], + ['V', 'CHECK_OPTION'], + ['V', 'IS_UPDATABLE'], + ]; array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T' + . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TABLES']) . 'T' - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'VIEWS')) . ' V' - . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('V', 'TABLE_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('V', 'TABLE_NAME')) + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'VIEWS']) . ' V' + . ' ON ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['V', 'TABLE_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) + . ' = ' . $p->quoteIdentifierChain(['V', 'TABLE_NAME']) - . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE')) + . ' WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; if ($schema != self::DEFAULT_SCHEMA) { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' != \'INFORMATION_SCHEMA\''; } $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $tables = array(); + $tables = []; foreach ($results->toArray() as $row) { - $tables[$row['TABLE_NAME']] = array( + $tables[$row['TABLE_NAME']] = [ 'table_type' => $row['TABLE_TYPE'], 'view_definition' => $row['VIEW_DEFINITION'], 'check_option' => $row['CHECK_OPTION'], 'is_updatable' => ('YES' == $row['IS_UPDATABLE']), - ); + ]; } $this->data['table_names'][$schema] = $tables; @@ -99,56 +99,56 @@ protected function loadColumnData($table, $schema) $this->prepareDataHierarchy('columns', $schema, $table); $p = $this->adapter->getPlatform(); - $isColumns = array( - array('C', 'ORDINAL_POSITION'), - array('C', 'COLUMN_DEFAULT'), - array('C', 'IS_NULLABLE'), - array('C', 'DATA_TYPE'), - array('C', 'CHARACTER_MAXIMUM_LENGTH'), - array('C', 'CHARACTER_OCTET_LENGTH'), - array('C', 'NUMERIC_PRECISION'), - array('C', 'NUMERIC_SCALE'), - array('C', 'COLUMN_NAME'), - array('C', 'COLUMN_TYPE'), - ); + $isColumns = [ + ['C', 'ORDINAL_POSITION'], + ['C', 'COLUMN_DEFAULT'], + ['C', 'IS_NULLABLE'], + ['C', 'DATA_TYPE'], + ['C', 'CHARACTER_MAXIMUM_LENGTH'], + ['C', 'CHARACTER_OCTET_LENGTH'], + ['C', 'NUMERIC_PRECISION'], + ['C', 'NUMERIC_SCALE'], + ['C', 'COLUMN_NAME'], + ['C', 'COLUMN_TYPE'], + ]; array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T' - . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'COLUMNS')) . 'C' - . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('C', 'TABLE_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('C', 'TABLE_NAME')) - . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE')) + . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TABLES']) . 'T' + . ' INNER JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'COLUMNS']) . 'C' + . ' ON ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['C', 'TABLE_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) + . ' = ' . $p->quoteIdentifierChain(['C', 'TABLE_NAME']) + . ' WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')' - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) . ' = ' . $p->quoteTrustedValue($table); if ($schema != self::DEFAULT_SCHEMA) { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' != \'INFORMATION_SCHEMA\''; } $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $columns = array(); + $columns = []; foreach ($results->toArray() as $row) { - $erratas = array(); - $matches = array(); + $erratas = []; + $matches = []; if (preg_match('/^(?:enum|set)\((.+)\)$/i', $row['COLUMN_TYPE'], $matches)) { $permittedValues = $matches[1]; if (preg_match_all("/\\s*'((?:[^']++|'')*+)'\\s*(?:,|\$)/", $permittedValues, $matches, PREG_PATTERN_ORDER)) { $permittedValues = str_replace("''", "'", $matches[1]); } else { - $permittedValues = array($permittedValues); + $permittedValues = [$permittedValues]; } $erratas['permitted_values'] = $permittedValues; } - $columns[$row['COLUMN_NAME']] = array( + $columns[$row['COLUMN_NAME']] = [ 'ordinal_position' => $row['ORDINAL_POSITION'], 'column_default' => $row['COLUMN_DEFAULT'], 'is_nullable' => ('YES' == $row['IS_NULLABLE']), @@ -159,7 +159,7 @@ protected function loadColumnData($table, $schema) 'numeric_scale' => $row['NUMERIC_SCALE'], 'numeric_unsigned' => (false !== strpos($row['COLUMN_TYPE'], 'unsigned')), 'erratas' => $erratas, - ); + ]; } $this->data['columns'][$schema][$table] = $columns; @@ -173,18 +173,18 @@ protected function loadConstraintData($table, $schema) $this->prepareDataHierarchy('constraints', $schema, $table); - $isColumns = array( - array('T', 'TABLE_NAME'), - array('TC', 'CONSTRAINT_NAME'), - array('TC', 'CONSTRAINT_TYPE'), - array('KCU', 'COLUMN_NAME'), - array('RC', 'MATCH_OPTION'), - array('RC', 'UPDATE_RULE'), - array('RC', 'DELETE_RULE'), - array('KCU', 'REFERENCED_TABLE_SCHEMA'), - array('KCU', 'REFERENCED_TABLE_NAME'), - array('KCU', 'REFERENCED_COLUMN_NAME'), - ); + $isColumns = [ + ['T', 'TABLE_NAME'], + ['TC', 'CONSTRAINT_NAME'], + ['TC', 'CONSTRAINT_TYPE'], + ['KCU', 'COLUMN_NAME'], + ['RC', 'MATCH_OPTION'], + ['RC', 'UPDATE_RULE'], + ['RC', 'DELETE_RULE'], + ['KCU', 'REFERENCED_TABLE_SCHEMA'], + ['KCU', 'REFERENCED_TABLE_NAME'], + ['KCU', 'REFERENCED_COLUMN_NAME'], + ]; $p = $this->adapter->getPlatform(); @@ -193,54 +193,54 @@ protected function loadConstraintData($table, $schema) }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . ' T' - - . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLE_CONSTRAINTS')) . ' TC' - . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('TC', 'TABLE_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('TC', 'TABLE_NAME')) - - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE')) . ' KCU' - . ' ON ' . $p->quoteIdentifierChain(array('TC', 'TABLE_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('TC', 'TABLE_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_NAME')) - . ' AND ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('KCU', 'CONSTRAINT_NAME')) - - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'REFERENTIAL_CONSTRAINTS')) . ' RC' - . ' ON ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_NAME')) - - . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) + . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TABLES']) . ' T' + + . ' INNER JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TABLE_CONSTRAINTS']) . ' TC' + . ' ON ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['TC', 'TABLE_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) + . ' = ' . $p->quoteIdentifierChain(['TC', 'TABLE_NAME']) + + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE']) . ' KCU' + . ' ON ' . $p->quoteIdentifierChain(['TC', 'TABLE_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['KCU', 'TABLE_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['TC', 'TABLE_NAME']) + . ' = ' . $p->quoteIdentifierChain(['KCU', 'TABLE_NAME']) + . ' AND ' . $p->quoteIdentifierChain(['TC', 'CONSTRAINT_NAME']) + . ' = ' . $p->quoteIdentifierChain(['KCU', 'CONSTRAINT_NAME']) + + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'REFERENTIAL_CONSTRAINTS']) . ' RC' + . ' ON ' . $p->quoteIdentifierChain(['TC', 'CONSTRAINT_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['RC', 'CONSTRAINT_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['TC', 'CONSTRAINT_NAME']) + . ' = ' . $p->quoteIdentifierChain(['RC', 'CONSTRAINT_NAME']) + + . ' WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) . ' = ' . $p->quoteTrustedValue($table) - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE')) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; if ($schema != self::DEFAULT_SCHEMA) { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' != \'INFORMATION_SCHEMA\''; } - $sql .= ' ORDER BY CASE ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_TYPE')) + $sql .= ' ORDER BY CASE ' . $p->quoteIdentifierChain(['TC', 'CONSTRAINT_TYPE']) . " WHEN 'PRIMARY KEY' THEN 1" . " WHEN 'UNIQUE' THEN 2" . " WHEN 'FOREIGN KEY' THEN 3" . " ELSE 4 END" - . ', ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME')) - . ', ' . $p->quoteIdentifierChain(array('KCU', 'ORDINAL_POSITION')); + . ', ' . $p->quoteIdentifierChain(['TC', 'CONSTRAINT_NAME']) + . ', ' . $p->quoteIdentifierChain(['KCU', 'ORDINAL_POSITION']); $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); $realName = null; - $constraints = array(); + $constraints = []; foreach ($results->toArray() as $row) { if ($row['CONSTRAINT_NAME'] !== $realName) { $realName = $row['CONSTRAINT_NAME']; @@ -250,16 +250,16 @@ protected function loadConstraintData($table, $schema) } else { $name = '_zf_' . $row['TABLE_NAME'] . '_' . $realName; } - $constraints[$name] = array( + $constraints[$name] = [ 'constraint_name' => $name, 'constraint_type' => $row['CONSTRAINT_TYPE'], 'table_name' => $row['TABLE_NAME'], - 'columns' => array(), - ); + 'columns' => [], + ]; if ($isFK) { $constraints[$name]['referenced_table_schema'] = $row['REFERENCED_TABLE_SCHEMA']; $constraints[$name]['referenced_table_name'] = $row['REFERENCED_TABLE_NAME']; - $constraints[$name]['referenced_columns'] = array(); + $constraints[$name]['referenced_columns'] = []; $constraints[$name]['match_option'] = $row['MATCH_OPTION']; $constraints[$name]['update_rule'] = $row['UPDATE_RULE']; $constraints[$name]['delete_rule'] = $row['DELETE_RULE']; @@ -284,37 +284,37 @@ protected function loadConstraintDataNames($schema) $p = $this->adapter->getPlatform(); - $isColumns = array( - array('TC', 'TABLE_NAME'), - array('TC', 'CONSTRAINT_NAME'), - array('TC', 'CONSTRAINT_TYPE'), - ); + $isColumns = [ + ['TC', 'TABLE_NAME'], + ['TC', 'CONSTRAINT_NAME'], + ['TC', 'CONSTRAINT_TYPE'], + ]; array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T' - . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLE_CONSTRAINTS')) . 'TC' - . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('TC', 'TABLE_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('TC', 'TABLE_NAME')) - . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE')) + . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TABLES']) . 'T' + . ' INNER JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TABLE_CONSTRAINTS']) . 'TC' + . ' ON ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['TC', 'TABLE_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) + . ' = ' . $p->quoteIdentifierChain(['TC', 'TABLE_NAME']) + . ' WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; if ($schema != self::DEFAULT_SCHEMA) { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' != \'INFORMATION_SCHEMA\''; } $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $data = array(); + $data = []; foreach ($results->toArray() as $row) { $data[] = array_change_key_case($row, CASE_LOWER); } @@ -332,40 +332,40 @@ protected function loadConstraintDataKeys($schema) $p = $this->adapter->getPlatform(); - $isColumns = array( - array('T', 'TABLE_NAME'), - array('KCU', 'CONSTRAINT_NAME'), - array('KCU', 'COLUMN_NAME'), - array('KCU', 'ORDINAL_POSITION'), - ); + $isColumns = [ + ['T', 'TABLE_NAME'], + ['KCU', 'CONSTRAINT_NAME'], + ['KCU', 'COLUMN_NAME'], + ['KCU', 'ORDINAL_POSITION'], + ]; array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T' + . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TABLES']) . 'T' - . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE')) . 'KCU' - . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_NAME')) + . ' INNER JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE']) . 'KCU' + . ' ON ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['KCU', 'TABLE_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) + . ' = ' . $p->quoteIdentifierChain(['KCU', 'TABLE_NAME']) - . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE')) + . ' WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; if ($schema != self::DEFAULT_SCHEMA) { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' != \'INFORMATION_SCHEMA\''; } $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $data = array(); + $data = []; foreach ($results->toArray() as $row) { $data[] = array_change_key_case($row, CASE_LOWER); } @@ -379,51 +379,51 @@ protected function loadConstraintReferences($table, $schema) $p = $this->adapter->getPlatform(); - $isColumns = array( - array('RC', 'TABLE_NAME'), - array('RC', 'CONSTRAINT_NAME'), - array('RC', 'UPDATE_RULE'), - array('RC', 'DELETE_RULE'), - array('KCU', 'REFERENCED_TABLE_SCHEMA'), - array('KCU', 'REFERENCED_TABLE_NAME'), - array('KCU', 'REFERENCED_COLUMN_NAME'), - ); + $isColumns = [ + ['RC', 'TABLE_NAME'], + ['RC', 'CONSTRAINT_NAME'], + ['RC', 'UPDATE_RULE'], + ['RC', 'DELETE_RULE'], + ['KCU', 'REFERENCED_TABLE_SCHEMA'], + ['KCU', 'REFERENCED_TABLE_NAME'], + ['KCU', 'REFERENCED_COLUMN_NAME'], + ]; array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); }); $sql = 'SELECT ' . implode(', ', $isColumns) - . 'FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T' - - . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'REFERENTIAL_CONSTRAINTS')) . 'RC' - . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('RC', 'TABLE_NAME')) - - . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE')) . 'KCU' - . ' ON ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('RC', 'TABLE_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_NAME')) - . ' AND ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('KCU', 'CONSTRAINT_NAME')) - - . 'WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE')) + . 'FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TABLES']) . 'T' + + . ' INNER JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'REFERENTIAL_CONSTRAINTS']) . 'RC' + . ' ON ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['RC', 'CONSTRAINT_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) + . ' = ' . $p->quoteIdentifierChain(['RC', 'TABLE_NAME']) + + . ' INNER JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE']) . 'KCU' + . ' ON ' . $p->quoteIdentifierChain(['RC', 'CONSTRAINT_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['KCU', 'TABLE_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['RC', 'TABLE_NAME']) + . ' = ' . $p->quoteIdentifierChain(['KCU', 'TABLE_NAME']) + . ' AND ' . $p->quoteIdentifierChain(['RC', 'CONSTRAINT_NAME']) + . ' = ' . $p->quoteIdentifierChain(['KCU', 'CONSTRAINT_NAME']) + + . 'WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; if ($schema != self::DEFAULT_SCHEMA) { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' != \'INFORMATION_SCHEMA\''; } $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $data = array(); + $data = []; foreach ($results->toArray() as $row) { $data[] = array_change_key_case($row, CASE_LOWER); } @@ -441,7 +441,7 @@ protected function loadTriggerData($schema) $p = $this->adapter->getPlatform(); - $isColumns = array( + $isColumns = [ // 'TRIGGER_CATALOG', // 'TRIGGER_SCHEMA', 'TRIGGER_NAME', @@ -459,14 +459,14 @@ protected function loadTriggerData($schema) 'ACTION_REFERENCE_OLD_ROW', 'ACTION_REFERENCE_NEW_ROW', 'CREATED', - ); + ]; array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifier($c); }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TRIGGERS')) + . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TRIGGERS']) . ' WHERE '; if ($schema != self::DEFAULT_SCHEMA) { @@ -479,7 +479,7 @@ protected function loadTriggerData($schema) $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $data = array(); + $data = []; foreach ($results->toArray() as $row) { $row = array_change_key_case($row, CASE_LOWER); if (null !== $row['created']) { diff --git a/src/Metadata/Source/OracleMetadata.php b/src/Metadata/Source/OracleMetadata.php index 3207dc6cc8..d99f8a8bc4 100644 --- a/src/Metadata/Source/OracleMetadata.php +++ b/src/Metadata/Source/OracleMetadata.php @@ -19,11 +19,11 @@ class OracleMetadata extends AbstractSource /** * @var array */ - protected $constraintTypeMap = array( + protected $constraintTypeMap = [ 'C' => 'CHECK', 'P' => 'PRIMARY KEY', 'R' => 'FOREIGN_KEY' - ); + ]; /** * {@inheritdoc} @@ -35,7 +35,7 @@ protected function loadColumnData($table, $schema) return; } - $isColumns = array( + $isColumns = [ 'COLUMN_ID', 'COLUMN_NAME', 'DATA_DEFAULT', @@ -44,23 +44,23 @@ protected function loadColumnData($table, $schema) 'DATA_LENGTH', 'DATA_PRECISION', 'DATA_SCALE' - ); + ]; $this->prepareDataHierarchy('columns', $schema, $table); - $parameters = array( + $parameters = [ ':ownername' => $schema, ':tablename' => $table - ); + ]; $sql = 'SELECT ' . implode(', ', $isColumns) . ' FROM all_tab_columns' . ' WHERE owner = :ownername AND table_name = :tablename'; $result = $this->adapter->query($sql)->execute($parameters); - $columns = array(); + $columns = []; foreach ($result as $row) { - $columns[$row['COLUMN_NAME']] = array( + $columns[$row['COLUMN_NAME']] = [ 'ordinal_position' => $row['COLUMN_ID'], 'column_default' => $row['DATA_DEFAULT'], 'is_nullable' => ('Y' == $row['NULLABLE']), @@ -70,8 +70,8 @@ protected function loadColumnData($table, $schema) 'numeric_precision' => $row['DATA_PRECISION'], 'numeric_scale' => $row['DATA_SCALE'], 'numeric_unsigned' => false, - 'erratas' => array(), - ); + 'erratas' => [], + ]; } $this->data['columns'][$schema][$table] = $columns; @@ -129,37 +129,37 @@ protected function loadConstraintData($table, $schema) ORDER BY ac.constraint_name; '; - $parameters = array( + $parameters = [ ':schema' => $schema, ':table' => $table - ); + ]; $results = $this->adapter->query($sql)->execute($parameters); $isFK = false; $name = null; - $constraints = array(); + $constraints = []; foreach ($results as $row) { if ($row['CONSTRAINT_NAME'] !== $name) { $name = $row['CONSTRAINT_NAME']; - $constraints[$name] = array( + $constraints[$name] = [ 'constraint_name' => $name, 'constraint_type' => $this->getConstraintType($row['CONSTRAINT_TYPE']), 'table_name' => $row['TABLE_NAME'], - ); + ]; if ('C' == $row['CONSTRAINT_TYPE']) { $constraints[$name]['CHECK_CLAUSE'] = $row['CHECK_CLAUSE']; continue; } - $constraints[$name]['columns'] = array(); + $constraints[$name]['columns'] = []; $isFK = ('R' == $row['CONSTRAINT_TYPE']); if ($isFK) { $constraints[$name]['referenced_table_schema'] = $row['REF_OWNER']; $constraints[$name]['referenced_table_name'] = $row['REF_TABLE']; - $constraints[$name]['referenced_columns'] = array(); + $constraints[$name]['referenced_columns'] = []; $constraints[$name]['match_option'] = 'NONE'; $constraints[$name]['update_rule'] = null; $constraints[$name]['delete_rule'] = $row['DELETE_RULE']; @@ -189,7 +189,7 @@ protected function loadSchemaData() $sql = 'SELECT USERNAME FROM ALL_USERS'; $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $schemas = array(); + $schemas = []; foreach ($results->toArray() as $row) { $schemas[] = $row['USERNAME']; } @@ -208,30 +208,30 @@ protected function loadTableNameData($schema) } $this->prepareDataHierarchy('table_names', $schema); - $tables = array(); + $tables = []; // Tables - $bind = array(':OWNER' => strtoupper($schema)); + $bind = [':OWNER' => strtoupper($schema)]; $result = $this->adapter->query('SELECT TABLE_NAME FROM ALL_TABLES WHERE OWNER=:OWNER')->execute($bind); foreach ($result as $row) { - $tables[$row['TABLE_NAME']] = array( + $tables[$row['TABLE_NAME']] = [ 'table_type' => 'BASE TABLE', 'view_definition' => null, 'check_option' => null, 'is_updatable' => false, - ); + ]; } // Views $result = $this->adapter->query('SELECT VIEW_NAME, TEXT FROM ALL_VIEWS WHERE OWNER=:OWNER', $bind); foreach ($result as $row) { - $tables[$row['VIEW_NAME']] = array( + $tables[$row['VIEW_NAME']] = [ 'table_type' => 'VIEW', 'view_definition' => null, 'check_option' => 'NONE', 'is_updatable' => false, - ); + ]; } $this->data['table_names'][$schema] = $tables; diff --git a/src/Metadata/Source/PostgresqlMetadata.php b/src/Metadata/Source/PostgresqlMetadata.php index ca58ce8d7f..74997677cb 100644 --- a/src/Metadata/Source/PostgresqlMetadata.php +++ b/src/Metadata/Source/PostgresqlMetadata.php @@ -23,14 +23,14 @@ protected function loadSchemaData() $p = $this->adapter->getPlatform(); $sql = 'SELECT ' . $p->quoteIdentifier('schema_name') - . ' FROM ' . $p->quoteIdentifierChain(array('information_schema', 'schemata')) + . ' FROM ' . $p->quoteIdentifierChain(['information_schema', 'schemata']) . ' WHERE ' . $p->quoteIdentifier('schema_name') . ' != \'information_schema\'' . ' AND ' . $p->quoteIdentifier('schema_name') . " NOT LIKE 'pg_%'"; $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $schemas = array(); + $schemas = []; foreach ($results->toArray() as $row) { $schemas[] = $row['schema_name']; } @@ -47,46 +47,46 @@ protected function loadTableNameData($schema) $p = $this->adapter->getPlatform(); - $isColumns = array( - array('t', 'table_name'), - array('t', 'table_type'), - array('v', 'view_definition'), - array('v', 'check_option'), - array('v', 'is_updatable'), - ); + $isColumns = [ + ['t', 'table_name'], + ['t', 'table_type'], + ['v', 'view_definition'], + ['v', 'check_option'], + ['v', 'is_updatable'], + ]; array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('information_schema', 'tables')) . ' t' + . ' FROM ' . $p->quoteIdentifierChain(['information_schema', 'tables']) . ' t' - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('information_schema', 'views')) . ' v' - . ' ON ' . $p->quoteIdentifierChain(array('t', 'table_schema')) - . ' = ' . $p->quoteIdentifierChain(array('v', 'table_schema')) - . ' AND ' . $p->quoteIdentifierChain(array('t', 'table_name')) - . ' = ' . $p->quoteIdentifierChain(array('v', 'table_name')) + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['information_schema', 'views']) . ' v' + . ' ON ' . $p->quoteIdentifierChain(['t', 'table_schema']) + . ' = ' . $p->quoteIdentifierChain(['v', 'table_schema']) + . ' AND ' . $p->quoteIdentifierChain(['t', 'table_name']) + . ' = ' . $p->quoteIdentifierChain(['v', 'table_name']) - . ' WHERE ' . $p->quoteIdentifierChain(array('t', 'table_type')) + . ' WHERE ' . $p->quoteIdentifierChain(['t', 'table_type']) . ' IN (\'BASE TABLE\', \'VIEW\')'; if ($schema != self::DEFAULT_SCHEMA) { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('t', 'table_schema')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['t', 'table_schema']) . ' = ' . $p->quoteTrustedValue($schema); } else { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('t', 'table_schema')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['t', 'table_schema']) . ' != \'information_schema\''; } $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $tables = array(); + $tables = []; foreach ($results->toArray() as $row) { - $tables[$row['table_name']] = array( + $tables[$row['table_name']] = [ 'table_type' => $row['table_type'], 'view_definition' => $row['view_definition'], 'check_option' => $row['check_option'], 'is_updatable' => ('YES' == $row['is_updatable']), - ); + ]; } $this->data['table_names'][$schema] = $tables; @@ -102,7 +102,7 @@ protected function loadColumnData($table, $schema) $platform = $this->adapter->getPlatform(); - $isColumns = array( + $isColumns = [ 'table_name', 'column_name', 'ordinal_position', @@ -113,7 +113,7 @@ protected function loadColumnData($table, $schema) 'character_octet_length', 'numeric_precision', 'numeric_scale', - ); + ]; array_walk($isColumns, function (&$c) use ($platform) { $c = $platform->quoteIdentifier($c); }); @@ -131,9 +131,9 @@ protected function loadColumnData($table, $schema) } $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $columns = array(); + $columns = []; foreach ($results->toArray() as $row) { - $columns[$row['column_name']] = array( + $columns[$row['column_name']] = [ 'ordinal_position' => $row['ordinal_position'], 'column_default' => $row['column_default'], 'is_nullable' => ('YES' == $row['is_nullable']), @@ -143,8 +143,8 @@ protected function loadColumnData($table, $schema) 'numeric_precision' => $row['numeric_precision'], 'numeric_scale' => $row['numeric_scale'], 'numeric_unsigned' => null, - 'erratas' => array(), - ); + 'erratas' => [], + ]; } $this->data['columns'][$schema][$table] = $columns; @@ -158,19 +158,19 @@ protected function loadConstraintData($table, $schema) $this->prepareDataHierarchy('constraints', $schema, $table); - $isColumns = array( - array('t', 'table_name'), - array('tc', 'constraint_name'), - array('tc', 'constraint_type'), - array('kcu', 'column_name'), - array('cc', 'check_clause'), - array('rc', 'match_option'), - array('rc', 'update_rule'), - array('rc', 'delete_rule'), - array('referenced_table_schema' => 'kcu2', 'table_schema'), - array('referenced_table_name' => 'kcu2', 'table_name'), - array('referenced_column_name' => 'kcu2', 'column_name'), - ); + $isColumns = [ + ['t', 'table_name'], + ['tc', 'constraint_name'], + ['tc', 'constraint_type'], + ['kcu', 'column_name'], + ['cc', 'check_clause'], + ['rc', 'match_option'], + ['rc', 'update_rule'], + ['rc', 'delete_rule'], + ['referenced_table_schema' => 'kcu2', 'table_schema'], + ['referenced_table_name' => 'kcu2', 'table_name'], + ['referenced_column_name' => 'kcu2', 'column_name'], + ]; $p = $this->adapter->getPlatform(); @@ -183,86 +183,86 @@ protected function loadConstraintData($table, $schema) }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('information_schema', 'tables')) . ' t' - - . ' INNER JOIN ' . $p->quoteIdentifierChain(array('information_schema', 'table_constraints')) . ' tc' - . ' ON ' . $p->quoteIdentifierChain(array('t', 'table_schema')) - . ' = ' . $p->quoteIdentifierChain(array('tc', 'table_schema')) - . ' AND ' . $p->quoteIdentifierChain(array('t', 'table_name')) - . ' = ' . $p->quoteIdentifierChain(array('tc', 'table_name')) - - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('information_schema', 'key_column_usage')) . ' kcu' - . ' ON ' . $p->quoteIdentifierChain(array('tc', 'table_schema')) - . ' = ' . $p->quoteIdentifierChain(array('kcu', 'table_schema')) - . ' AND ' . $p->quoteIdentifierChain(array('tc', 'table_name')) - . ' = ' . $p->quoteIdentifierChain(array('kcu', 'table_name')) - . ' AND ' . $p->quoteIdentifierChain(array('tc', 'constraint_name')) - . ' = ' . $p->quoteIdentifierChain(array('kcu', 'constraint_name')) - - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('information_schema', 'check_constraints')) . ' cc' - . ' ON ' . $p->quoteIdentifierChain(array('tc', 'constraint_schema')) - . ' = ' . $p->quoteIdentifierChain(array('cc', 'constraint_schema')) - . ' AND ' . $p->quoteIdentifierChain(array('tc', 'constraint_name')) - . ' = ' . $p->quoteIdentifierChain(array('cc', 'constraint_name')) - - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('information_schema', 'referential_constraints')) . ' rc' - . ' ON ' . $p->quoteIdentifierChain(array('tc', 'constraint_schema')) - . ' = ' . $p->quoteIdentifierChain(array('rc', 'constraint_schema')) - . ' AND ' . $p->quoteIdentifierChain(array('tc', 'constraint_name')) - . ' = ' . $p->quoteIdentifierChain(array('rc', 'constraint_name')) - - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('information_schema', 'key_column_usage')) . ' kcu2' - . ' ON ' . $p->quoteIdentifierChain(array('rc', 'unique_constraint_schema')) - . ' = ' . $p->quoteIdentifierChain(array('kcu2', 'constraint_schema')) - . ' AND ' . $p->quoteIdentifierChain(array('rc', 'unique_constraint_name')) - . ' = ' . $p->quoteIdentifierChain(array('kcu2', 'constraint_name')) - . ' AND ' . $p->quoteIdentifierChain(array('kcu', 'position_in_unique_constraint')) - . ' = ' . $p->quoteIdentifierChain(array('kcu2', 'ordinal_position')) - - . ' WHERE ' . $p->quoteIdentifierChain(array('t', 'table_name')) + . ' FROM ' . $p->quoteIdentifierChain(['information_schema', 'tables']) . ' t' + + . ' INNER JOIN ' . $p->quoteIdentifierChain(['information_schema', 'table_constraints']) . ' tc' + . ' ON ' . $p->quoteIdentifierChain(['t', 'table_schema']) + . ' = ' . $p->quoteIdentifierChain(['tc', 'table_schema']) + . ' AND ' . $p->quoteIdentifierChain(['t', 'table_name']) + . ' = ' . $p->quoteIdentifierChain(['tc', 'table_name']) + + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['information_schema', 'key_column_usage']) . ' kcu' + . ' ON ' . $p->quoteIdentifierChain(['tc', 'table_schema']) + . ' = ' . $p->quoteIdentifierChain(['kcu', 'table_schema']) + . ' AND ' . $p->quoteIdentifierChain(['tc', 'table_name']) + . ' = ' . $p->quoteIdentifierChain(['kcu', 'table_name']) + . ' AND ' . $p->quoteIdentifierChain(['tc', 'constraint_name']) + . ' = ' . $p->quoteIdentifierChain(['kcu', 'constraint_name']) + + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['information_schema', 'check_constraints']) . ' cc' + . ' ON ' . $p->quoteIdentifierChain(['tc', 'constraint_schema']) + . ' = ' . $p->quoteIdentifierChain(['cc', 'constraint_schema']) + . ' AND ' . $p->quoteIdentifierChain(['tc', 'constraint_name']) + . ' = ' . $p->quoteIdentifierChain(['cc', 'constraint_name']) + + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['information_schema', 'referential_constraints']) . ' rc' + . ' ON ' . $p->quoteIdentifierChain(['tc', 'constraint_schema']) + . ' = ' . $p->quoteIdentifierChain(['rc', 'constraint_schema']) + . ' AND ' . $p->quoteIdentifierChain(['tc', 'constraint_name']) + . ' = ' . $p->quoteIdentifierChain(['rc', 'constraint_name']) + + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['information_schema', 'key_column_usage']) . ' kcu2' + . ' ON ' . $p->quoteIdentifierChain(['rc', 'unique_constraint_schema']) + . ' = ' . $p->quoteIdentifierChain(['kcu2', 'constraint_schema']) + . ' AND ' . $p->quoteIdentifierChain(['rc', 'unique_constraint_name']) + . ' = ' . $p->quoteIdentifierChain(['kcu2', 'constraint_name']) + . ' AND ' . $p->quoteIdentifierChain(['kcu', 'position_in_unique_constraint']) + . ' = ' . $p->quoteIdentifierChain(['kcu2', 'ordinal_position']) + + . ' WHERE ' . $p->quoteIdentifierChain(['t', 'table_name']) . ' = ' . $p->quoteTrustedValue($table) - . ' AND ' . $p->quoteIdentifierChain(array('t', 'table_type')) + . ' AND ' . $p->quoteIdentifierChain(['t', 'table_type']) . ' IN (\'BASE TABLE\', \'VIEW\')'; if ($schema != self::DEFAULT_SCHEMA) { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('t', 'table_schema')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['t', 'table_schema']) . ' = ' . $p->quoteTrustedValue($schema); } else { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('t', 'table_schema')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['t', 'table_schema']) . ' != \'information_schema\''; } - $sql .= ' ORDER BY CASE ' . $p->quoteIdentifierChain(array('tc', 'constraint_type')) + $sql .= ' ORDER BY CASE ' . $p->quoteIdentifierChain(['tc', 'constraint_type']) . " WHEN 'PRIMARY KEY' THEN 1" . " WHEN 'UNIQUE' THEN 2" . " WHEN 'FOREIGN KEY' THEN 3" . " WHEN 'CHECK' THEN 4" . " ELSE 5 END" - . ', ' . $p->quoteIdentifierChain(array('tc', 'constraint_name')) - . ', ' . $p->quoteIdentifierChain(array('kcu', 'ordinal_position')); + . ', ' . $p->quoteIdentifierChain(['tc', 'constraint_name']) + . ', ' . $p->quoteIdentifierChain(['kcu', 'ordinal_position']); $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); $name = null; - $constraints = array(); + $constraints = []; foreach ($results->toArray() as $row) { if ($row['constraint_name'] !== $name) { $name = $row['constraint_name']; - $constraints[$name] = array( + $constraints[$name] = [ 'constraint_name' => $name, 'constraint_type' => $row['constraint_type'], 'table_name' => $row['table_name'], - ); + ]; if ('CHECK' == $row['constraint_type']) { $constraints[$name]['check_clause'] = $row['check_clause']; continue; } - $constraints[$name]['columns'] = array(); + $constraints[$name]['columns'] = []; $isFK = ('FOREIGN KEY' == $row['constraint_type']); if ($isFK) { $constraints[$name]['referenced_table_schema'] = $row['referenced_table_schema']; $constraints[$name]['referenced_table_name'] = $row['referenced_table_name']; - $constraints[$name]['referenced_columns'] = array(); + $constraints[$name]['referenced_columns'] = []; $constraints[$name]['match_option'] = $row['match_option']; $constraints[$name]['update_rule'] = $row['update_rule']; $constraints[$name]['delete_rule'] = $row['delete_rule']; @@ -287,7 +287,7 @@ protected function loadTriggerData($schema) $p = $this->adapter->getPlatform(); - $isColumns = array( + $isColumns = [ 'trigger_name', 'event_manipulation', 'event_object_catalog', @@ -297,11 +297,11 @@ protected function loadTriggerData($schema) 'action_condition', 'action_statement', 'action_orientation', - array('action_timing' => 'condition_timing'), - array('action_reference_old_table' => 'condition_reference_old_table'), - array('action_reference_new_table' => 'condition_reference_new_table'), + ['action_timing' => 'condition_timing'], + ['action_reference_old_table' => 'condition_reference_old_table'], + ['action_reference_new_table' => 'condition_reference_new_table'], 'created', - ); + ]; array_walk($isColumns, function (&$c) use ($p) { if (is_array($c)) { @@ -316,7 +316,7 @@ protected function loadTriggerData($schema) }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('information_schema', 'triggers')) + . ' FROM ' . $p->quoteIdentifierChain(['information_schema', 'triggers']) . ' WHERE '; if ($schema != self::DEFAULT_SCHEMA) { @@ -329,7 +329,7 @@ protected function loadTriggerData($schema) $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $data = array(); + $data = []; foreach ($results->toArray() as $row) { $row = array_change_key_case($row, CASE_LOWER); $row['action_reference_old_row'] = 'OLD'; diff --git a/src/Metadata/Source/SqlServerMetadata.php b/src/Metadata/Source/SqlServerMetadata.php index 8c1fe7ef0f..1081003288 100644 --- a/src/Metadata/Source/SqlServerMetadata.php +++ b/src/Metadata/Source/SqlServerMetadata.php @@ -23,13 +23,13 @@ protected function loadSchemaData() $p = $this->adapter->getPlatform(); $sql = 'SELECT ' . $p->quoteIdentifier('SCHEMA_NAME') - . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'SCHEMATA')) + . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'SCHEMATA']) . ' WHERE ' . $p->quoteIdentifier('SCHEMA_NAME') . ' != \'INFORMATION_SCHEMA\''; $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $schemas = array(); + $schemas = []; foreach ($results->toArray() as $row) { $schemas[] = $row['SCHEMA_NAME']; } @@ -46,46 +46,46 @@ protected function loadTableNameData($schema) $p = $this->adapter->getPlatform(); - $isColumns = array( - array('T', 'TABLE_NAME'), - array('T', 'TABLE_TYPE'), - array('V', 'VIEW_DEFINITION'), - array('V', 'CHECK_OPTION'), - array('V', 'IS_UPDATABLE'), - ); + $isColumns = [ + ['T', 'TABLE_NAME'], + ['T', 'TABLE_TYPE'], + ['V', 'VIEW_DEFINITION'], + ['V', 'CHECK_OPTION'], + ['V', 'IS_UPDATABLE'], + ]; array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . ' t' + . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TABLES']) . ' t' - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'VIEWS')) . ' v' - . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('V', 'TABLE_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('V', 'TABLE_NAME')) + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'VIEWS']) . ' v' + . ' ON ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['V', 'TABLE_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) + . ' = ' . $p->quoteIdentifierChain(['V', 'TABLE_NAME']) - . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE')) + . ' WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; if ($schema != self::DEFAULT_SCHEMA) { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' != \'INFORMATION_SCHEMA\''; } $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $tables = array(); + $tables = []; foreach ($results->toArray() as $row) { - $tables[$row['TABLE_NAME']] = array( + $tables[$row['TABLE_NAME']] = [ 'table_type' => $row['TABLE_TYPE'], 'view_definition' => $row['VIEW_DEFINITION'], 'check_option' => $row['CHECK_OPTION'], 'is_updatable' => ('YES' == $row['IS_UPDATABLE']), - ); + ]; } $this->data['table_names'][$schema] = $tables; @@ -99,44 +99,44 @@ protected function loadColumnData($table, $schema) $this->prepareDataHierarchy('columns', $schema, $table); $p = $this->adapter->getPlatform(); - $isColumns = array( - array('C', 'ORDINAL_POSITION'), - array('C', 'COLUMN_DEFAULT'), - array('C', 'IS_NULLABLE'), - array('C', 'DATA_TYPE'), - array('C', 'CHARACTER_MAXIMUM_LENGTH'), - array('C', 'CHARACTER_OCTET_LENGTH'), - array('C', 'NUMERIC_PRECISION'), - array('C', 'NUMERIC_SCALE'), - array('C', 'COLUMN_NAME'), - ); + $isColumns = [ + ['C', 'ORDINAL_POSITION'], + ['C', 'COLUMN_DEFAULT'], + ['C', 'IS_NULLABLE'], + ['C', 'DATA_TYPE'], + ['C', 'CHARACTER_MAXIMUM_LENGTH'], + ['C', 'CHARACTER_OCTET_LENGTH'], + ['C', 'NUMERIC_PRECISION'], + ['C', 'NUMERIC_SCALE'], + ['C', 'COLUMN_NAME'], + ]; array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T' - . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'COLUMNS')) . 'C' - . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('C', 'TABLE_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('C', 'TABLE_NAME')) - . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE')) + . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TABLES']) . 'T' + . ' INNER JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'COLUMNS']) . 'C' + . ' ON ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['C', 'TABLE_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) + . ' = ' . $p->quoteIdentifierChain(['C', 'TABLE_NAME']) + . ' WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')' - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) . ' = ' . $p->quoteTrustedValue($table); if ($schema != self::DEFAULT_SCHEMA) { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' != \'INFORMATION_SCHEMA\''; } $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $columns = array(); + $columns = []; foreach ($results->toArray() as $row) { - $columns[$row['COLUMN_NAME']] = array( + $columns[$row['COLUMN_NAME']] = [ 'ordinal_position' => $row['ORDINAL_POSITION'], 'column_default' => $row['COLUMN_DEFAULT'], 'is_nullable' => ('YES' == $row['IS_NULLABLE']), @@ -146,8 +146,8 @@ protected function loadColumnData($table, $schema) 'numeric_precision' => $row['NUMERIC_PRECISION'], 'numeric_scale' => $row['NUMERIC_SCALE'], 'numeric_unsigned' => null, - 'erratas' => array(), - ); + 'erratas' => [], + ]; } $this->data['columns'][$schema][$table] = $columns; @@ -161,19 +161,19 @@ protected function loadConstraintData($table, $schema) $this->prepareDataHierarchy('constraints', $schema, $table); - $isColumns = array( - array('T', 'TABLE_NAME'), - array('TC', 'CONSTRAINT_NAME'), - array('TC', 'CONSTRAINT_TYPE'), - array('KCU', 'COLUMN_NAME'), - array('CC', 'CHECK_CLAUSE'), - array('RC', 'MATCH_OPTION'), - array('RC', 'UPDATE_RULE'), - array('RC', 'DELETE_RULE'), - array('REFERENCED_TABLE_SCHEMA' => 'KCU2', 'TABLE_SCHEMA'), - array('REFERENCED_TABLE_NAME' => 'KCU2', 'TABLE_NAME'), - array('REFERENCED_COLUMN_NAME' => 'KCU2', 'COLUMN_NAME'), - ); + $isColumns = [ + ['T', 'TABLE_NAME'], + ['TC', 'CONSTRAINT_NAME'], + ['TC', 'CONSTRAINT_TYPE'], + ['KCU', 'COLUMN_NAME'], + ['CC', 'CHECK_CLAUSE'], + ['RC', 'MATCH_OPTION'], + ['RC', 'UPDATE_RULE'], + ['RC', 'DELETE_RULE'], + ['REFERENCED_TABLE_SCHEMA' => 'KCU2', 'TABLE_SCHEMA'], + ['REFERENCED_TABLE_NAME' => 'KCU2', 'TABLE_NAME'], + ['REFERENCED_COLUMN_NAME' => 'KCU2', 'COLUMN_NAME'], + ]; $p = $this->adapter->getPlatform(); @@ -186,87 +186,87 @@ protected function loadConstraintData($table, $schema) }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . ' T' - - . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLE_CONSTRAINTS')) . ' TC' - . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('TC', 'TABLE_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('TC', 'TABLE_NAME')) - - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE')) . ' KCU' - . ' ON ' . $p->quoteIdentifierChain(array('TC', 'TABLE_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('TC', 'TABLE_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_NAME')) - . ' AND ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('KCU', 'CONSTRAINT_NAME')) - - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'CHECK_CONSTRAINTS')) . ' CC' - . ' ON ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('CC', 'CONSTRAINT_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('CC', 'CONSTRAINT_NAME')) - - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'REFERENTIAL_CONSTRAINTS')) . ' RC' - . ' ON ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_NAME')) - - . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE')) . ' KCU2' - . ' ON ' . $p->quoteIdentifierChain(array('RC', 'UNIQUE_CONSTRAINT_SCHEMA')) - . ' = ' . $p->quoteIdentifierChain(array('KCU2', 'CONSTRAINT_SCHEMA')) - . ' AND ' . $p->quoteIdentifierChain(array('RC', 'UNIQUE_CONSTRAINT_NAME')) - . ' = ' . $p->quoteIdentifierChain(array('KCU2', 'CONSTRAINT_NAME')) - . ' AND ' . $p->quoteIdentifierChain(array('KCU', 'ORDINAL_POSITION')) - . ' = ' . $p->quoteIdentifierChain(array('KCU2', 'ORDINAL_POSITION')) - - . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) + . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TABLES']) . ' T' + + . ' INNER JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TABLE_CONSTRAINTS']) . ' TC' + . ' ON ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['TC', 'TABLE_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) + . ' = ' . $p->quoteIdentifierChain(['TC', 'TABLE_NAME']) + + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE']) . ' KCU' + . ' ON ' . $p->quoteIdentifierChain(['TC', 'TABLE_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['KCU', 'TABLE_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['TC', 'TABLE_NAME']) + . ' = ' . $p->quoteIdentifierChain(['KCU', 'TABLE_NAME']) + . ' AND ' . $p->quoteIdentifierChain(['TC', 'CONSTRAINT_NAME']) + . ' = ' . $p->quoteIdentifierChain(['KCU', 'CONSTRAINT_NAME']) + + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'CHECK_CONSTRAINTS']) . ' CC' + . ' ON ' . $p->quoteIdentifierChain(['TC', 'CONSTRAINT_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['CC', 'CONSTRAINT_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['TC', 'CONSTRAINT_NAME']) + . ' = ' . $p->quoteIdentifierChain(['CC', 'CONSTRAINT_NAME']) + + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'REFERENTIAL_CONSTRAINTS']) . ' RC' + . ' ON ' . $p->quoteIdentifierChain(['TC', 'CONSTRAINT_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['RC', 'CONSTRAINT_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['TC', 'CONSTRAINT_NAME']) + . ' = ' . $p->quoteIdentifierChain(['RC', 'CONSTRAINT_NAME']) + + . ' LEFT JOIN ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE']) . ' KCU2' + . ' ON ' . $p->quoteIdentifierChain(['RC', 'UNIQUE_CONSTRAINT_SCHEMA']) + . ' = ' . $p->quoteIdentifierChain(['KCU2', 'CONSTRAINT_SCHEMA']) + . ' AND ' . $p->quoteIdentifierChain(['RC', 'UNIQUE_CONSTRAINT_NAME']) + . ' = ' . $p->quoteIdentifierChain(['KCU2', 'CONSTRAINT_NAME']) + . ' AND ' . $p->quoteIdentifierChain(['KCU', 'ORDINAL_POSITION']) + . ' = ' . $p->quoteIdentifierChain(['KCU2', 'ORDINAL_POSITION']) + + . ' WHERE ' . $p->quoteIdentifierChain(['T', 'TABLE_NAME']) . ' = ' . $p->quoteTrustedValue($table) - . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE')) + . ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_TYPE']) . ' IN (\'BASE TABLE\', \'VIEW\')'; if ($schema != self::DEFAULT_SCHEMA) { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' = ' . $p->quoteTrustedValue($schema); } else { - $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) + $sql .= ' AND ' . $p->quoteIdentifierChain(['T', 'TABLE_SCHEMA']) . ' != \'INFORMATION_SCHEMA\''; } - $sql .= ' ORDER BY CASE ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_TYPE')) + $sql .= ' ORDER BY CASE ' . $p->quoteIdentifierChain(['TC', 'CONSTRAINT_TYPE']) . " WHEN 'PRIMARY KEY' THEN 1" . " WHEN 'UNIQUE' THEN 2" . " WHEN 'FOREIGN KEY' THEN 3" . " WHEN 'CHECK' THEN 4" . " ELSE 5 END" - . ', ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME')) - . ', ' . $p->quoteIdentifierChain(array('KCU', 'ORDINAL_POSITION')); + . ', ' . $p->quoteIdentifierChain(['TC', 'CONSTRAINT_NAME']) + . ', ' . $p->quoteIdentifierChain(['KCU', 'ORDINAL_POSITION']); $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); $name = null; - $constraints = array(); + $constraints = []; $isFK = false; foreach ($results->toArray() as $row) { if ($row['CONSTRAINT_NAME'] !== $name) { $name = $row['CONSTRAINT_NAME']; - $constraints[$name] = array( + $constraints[$name] = [ 'constraint_name' => $name, 'constraint_type' => $row['CONSTRAINT_TYPE'], 'table_name' => $row['TABLE_NAME'], - ); + ]; if ('CHECK' == $row['CONSTRAINT_TYPE']) { $constraints[$name]['check_clause'] = $row['CHECK_CLAUSE']; continue; } - $constraints[$name]['columns'] = array(); + $constraints[$name]['columns'] = []; $isFK = ('FOREIGN KEY' == $row['CONSTRAINT_TYPE']); if ($isFK) { $constraints[$name]['referenced_table_schema'] = $row['REFERENCED_TABLE_SCHEMA']; $constraints[$name]['referenced_table_name'] = $row['REFERENCED_TABLE_NAME']; - $constraints[$name]['referenced_columns'] = array(); + $constraints[$name]['referenced_columns'] = []; $constraints[$name]['match_option'] = $row['MATCH_OPTION']; $constraints[$name]['update_rule'] = $row['UPDATE_RULE']; $constraints[$name]['delete_rule'] = $row['DELETE_RULE']; @@ -291,7 +291,7 @@ protected function loadTriggerData($schema) $p = $this->adapter->getPlatform(); - $isColumns = array( + $isColumns = [ 'TRIGGER_NAME', 'EVENT_MANIPULATION', 'EVENT_OBJECT_CATALOG', @@ -307,14 +307,14 @@ protected function loadTriggerData($schema) 'ACTION_REFERENCE_OLD_ROW', 'ACTION_REFERENCE_NEW_ROW', 'CREATED', - ); + ]; array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifier($c); }); $sql = 'SELECT ' . implode(', ', $isColumns) - . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TRIGGERS')) + . ' FROM ' . $p->quoteIdentifierChain(['INFORMATION_SCHEMA', 'TRIGGERS']) . ' WHERE '; if ($schema != self::DEFAULT_SCHEMA) { @@ -327,7 +327,7 @@ protected function loadTriggerData($schema) $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $data = array(); + $data = []; foreach ($results->toArray() as $row) { $row = array_change_key_case($row, CASE_LOWER); if (null !== $row['created']) { diff --git a/src/Metadata/Source/SqliteMetadata.php b/src/Metadata/Source/SqliteMetadata.php index 8006133d63..ee3a6f0880 100644 --- a/src/Metadata/Source/SqliteMetadata.php +++ b/src/Metadata/Source/SqliteMetadata.php @@ -39,26 +39,26 @@ protected function loadTableNameData($schema) $p = $this->adapter->getPlatform(); - $sql = 'SELECT "name", "type", "sql" FROM ' . $p->quoteIdentifierChain(array($schema, 'sqlite_master')) + $sql = 'SELECT "name", "type", "sql" FROM ' . $p->quoteIdentifierChain([$schema, 'sqlite_master']) . ' WHERE "type" IN (\'table\',\'view\') AND "name" NOT LIKE \'sqlite_%\''; $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $tables = array(); + $tables = []; foreach ($results->toArray() as $row) { if ('table' == $row['type']) { - $table = array( + $table = [ 'table_type' => 'BASE TABLE', 'view_definition' => null, // VIEW only 'check_option' => null, // VIEW only 'is_updatable' => null, // VIEW only - ); + ]; } else { - $table = array( + $table = [ 'table_type' => 'VIEW', 'view_definition' => null, 'check_option' => 'NONE', 'is_updatable' => false, - ); + ]; // Parse out extra data if (null !== ($data = $this->parseView($row['sql']))) { @@ -80,10 +80,10 @@ protected function loadColumnData($table, $schema) $results = $this->fetchPragma('table_info', $table, $schema); - $columns = array(); + $columns = []; foreach ($results as $row) { - $columns[$row['name']] = array( + $columns[$row['name']] = [ // cid appears to be zero-based, ordinal position needs to be one-based 'ordinal_position' => $row['cid'] + 1, 'column_default' => $row['dflt_value'], @@ -94,8 +94,8 @@ protected function loadColumnData($table, $schema) 'numeric_precision' => null, 'numeric_scale' => null, 'numeric_unsigned' => null, - 'erratas' => array(), - ); + 'erratas' => [], + ]; // TODO: populate character_ and numeric_values with correct info } @@ -112,7 +112,7 @@ protected function loadConstraintData($table, $schema) $this->prepareDataHierarchy('constraints', $schema, $table); $this->loadColumnData($table, $schema); - $primaryKey = array(); + $primaryKey = []; foreach ($this->data['sqlite_columns'][$schema][$table] as $col) { if ((bool) $col['pk']) { @@ -123,18 +123,18 @@ protected function loadConstraintData($table, $schema) if (empty($primaryKey)) { $primaryKey = null; } - $constraints = array(); + $constraints = []; $indexes = $this->fetchPragma('index_list', $table, $schema); foreach ($indexes as $index) { if (!((bool) $index['unique'])) { continue; } - $constraint = array( + $constraint = [ 'constraint_name' => $index['name'], 'constraint_type' => 'UNIQUE', 'table_name' => $table, - 'columns' => array(), - ); + 'columns' => [], + ]; $info = $this->fetchPragma('index_info', $index['name'], $schema); @@ -150,12 +150,12 @@ protected function loadConstraintData($table, $schema) if (null !== $primaryKey) { $constraintName = '_zf_' . $table . '_PRIMARY'; - $constraints[$constraintName] = array( + $constraints[$constraintName] = [ 'constraint_name' => $constraintName, 'constraint_type' => 'PRIMARY KEY', 'table_name' => $table, 'columns' => $primaryKey, - ); + ]; } $foreignKeys = $this->fetchPragma('foreign_key_list', $table, $schema); @@ -165,19 +165,19 @@ protected function loadConstraintData($table, $schema) if ($id !== $fk['id']) { $id = $fk['id']; $name = '_zf_' . $table . '_FOREIGN_KEY_' . ($id + 1); - $constraints[$name] = array( + $constraints[$name] = [ 'constraint_name' => $name, 'constraint_type' => 'FOREIGN KEY', 'table_name' => $table, - 'columns' => array(), + 'columns' => [], 'referenced_table_schema' => $schema, 'referenced_table_name' => $fk['table'], - 'referenced_columns' => array(), + 'referenced_columns' => [], // TODO: Verify match, on_update, and on_delete values conform to SQL Standard 'match_option' => strtoupper($fk['match']), 'update_rule' => strtoupper($fk['on_update']), 'delete_rule' => strtoupper($fk['on_delete']), - ); + ]; } $constraints[$name]['columns'][] = $fk['from']; $constraints[$name]['referenced_columns'][] = $fk['to']; @@ -197,13 +197,13 @@ protected function loadTriggerData($schema) $p = $this->adapter->getPlatform(); $sql = 'SELECT "name", "tbl_name", "sql" FROM ' - . $p->quoteIdentifierChain(array($schema, 'sqlite_master')) + . $p->quoteIdentifierChain([$schema, 'sqlite_master']) . ' WHERE "type" = \'trigger\''; $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE); - $triggers = array(); + $triggers = []; foreach ($results->toArray() as $row) { - $trigger = array( + $trigger = [ 'trigger_name' => $row['name'], 'event_manipulation' => null, // in $row['sql'] 'event_object_catalog' => null, @@ -219,7 +219,7 @@ protected function loadTriggerData($schema) 'action_reference_old_row' => 'OLD', 'action_reference_new_row' => 'NEW', 'created' => null, - ); + ]; // Parse out extra data if (null !== ($data = $this->parseTrigger($row['sql']))) { @@ -250,7 +250,7 @@ protected function fetchPragma($name, $value = null, $schema = null) if ($results instanceof ResultSetInterface) { return $results->toArray(); } - return array(); + return []; } protected function parseView($sql) @@ -258,24 +258,24 @@ protected function parseView($sql) static $re = null; if (null === $re) { $identifierChain = $this->getIdentifierChainRegularExpression(); - $re = $this->buildRegularExpression(array( + $re = $this->buildRegularExpression([ 'CREATE', - array('TEMP|TEMPORARY'), + ['TEMP|TEMPORARY'], 'VIEW', - array('IF', 'NOT', 'EXISTS'), + ['IF', 'NOT', 'EXISTS'], $identifierChain, 'AS', '(?.+)', - array(';'), - )); + [';'], + ]); } if (!preg_match($re, $sql, $matches)) { return; } - return array( + return [ 'view_definition' => $matches['view_definition'], - ); + ]; } protected function parseTrigger($sql) @@ -285,30 +285,30 @@ protected function parseTrigger($sql) $identifier = $this->getIdentifierRegularExpression(); $identifierList = $this->getIdentifierListRegularExpression(); $identifierChain = $this->getIdentifierChainRegularExpression(); - $re = $this->buildRegularExpression(array( + $re = $this->buildRegularExpression([ 'CREATE', - array('TEMP|TEMPORARY'), + ['TEMP|TEMPORARY'], 'TRIGGER', - array('IF', 'NOT', 'EXISTS'), + ['IF', 'NOT', 'EXISTS'], $identifierChain, - array('(?BEFORE|AFTER|INSTEAD\\s+OF)', ), + ['(?BEFORE|AFTER|INSTEAD\\s+OF)', ], '(?DELETE|INSERT|UPDATE)', - array('OF', '(?' . $identifierList . ')'), + ['OF', '(?' . $identifierList . ')'], 'ON', '(?' . $identifier . ')', - array('FOR', 'EACH', 'ROW'), - array('WHEN', '(?.+)'), + ['FOR', 'EACH', 'ROW'], + ['WHEN', '(?.+)'], '(?BEGIN', '.+', 'END)', - array(';'), - )); + [';'], + ]); } if (!preg_match($re, $sql, $matches)) { return; } - $data = array(); + $data = []; foreach ($matches as $key => $value) { if (is_string($key)) { @@ -354,12 +354,12 @@ protected function getIdentifierRegularExpression() { static $re = null; if (null === $re) { - $re = '(?:' . implode('|', array( + $re = '(?:' . implode('|', [ '"(?:[^"\\\\]++|\\\\.)*+"', '`(?:[^`]++|``)*+`', '\\[[^\\]]+\\]', '[^\\s\\.]+', - )) . ')'; + ]) . ')'; } return $re; diff --git a/src/ResultSet/AbstractResultSet.php b/src/ResultSet/AbstractResultSet.php index f1f904d959..1ba662edf6 100644 --- a/src/ResultSet/AbstractResultSet.php +++ b/src/ResultSet/AbstractResultSet.php @@ -58,7 +58,7 @@ public function initialize($dataSource) { // reset buffering if (is_array($this->buffer)) { - $this->buffer = array(); + $this->buffer = []; } if ($dataSource instanceof ResultInterface) { @@ -102,7 +102,7 @@ public function buffer() if ($this->buffer === -2) { throw new Exception\RuntimeException('Buffering must be enabled before iteration is started'); } elseif ($this->buffer === null) { - $this->buffer = array(); + $this->buffer = []; if ($this->dataSource instanceof ResultInterface) { $this->dataSource->rewind(); } @@ -263,7 +263,7 @@ public function count() */ public function toArray() { - $return = array(); + $return = []; foreach ($this as $row) { if (is_array($row)) { $return[] = $row; diff --git a/src/ResultSet/HydratingResultSet.php b/src/ResultSet/HydratingResultSet.php index 74b9c0b87c..a8e2013976 100644 --- a/src/ResultSet/HydratingResultSet.php +++ b/src/ResultSet/HydratingResultSet.php @@ -117,7 +117,7 @@ public function current() */ public function toArray() { - $return = array(); + $return = []; foreach ($this as $row) { $return[] = $this->getHydrator()->extract($row); } diff --git a/src/ResultSet/ResultSet.php b/src/ResultSet/ResultSet.php index 59bfac9d15..a19fd58373 100644 --- a/src/ResultSet/ResultSet.php +++ b/src/ResultSet/ResultSet.php @@ -21,10 +21,10 @@ class ResultSet extends AbstractResultSet * * @var array */ - protected $allowedReturnTypes = array( + protected $allowedReturnTypes = [ self::TYPE_ARRAYOBJECT, self::TYPE_ARRAY, - ); + ]; /** * @var ArrayObject @@ -46,9 +46,9 @@ class ResultSet extends AbstractResultSet */ public function __construct($returnType = self::TYPE_ARRAYOBJECT, $arrayObjectPrototype = null) { - $this->returnType = (in_array($returnType, array(self::TYPE_ARRAY, self::TYPE_ARRAYOBJECT))) ? $returnType : self::TYPE_ARRAYOBJECT; + $this->returnType = (in_array($returnType, [self::TYPE_ARRAY, self::TYPE_ARRAYOBJECT])) ? $returnType : self::TYPE_ARRAYOBJECT; if ($this->returnType === self::TYPE_ARRAYOBJECT) { - $this->setArrayObjectPrototype(($arrayObjectPrototype) ?: new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS)); + $this->setArrayObjectPrototype(($arrayObjectPrototype) ?: new ArrayObject([], ArrayObject::ARRAY_AS_PROPS)); } } diff --git a/src/RowGateway/AbstractRowGateway.php b/src/RowGateway/AbstractRowGateway.php index 662fb226b0..3c691d88fe 100644 --- a/src/RowGateway/AbstractRowGateway.php +++ b/src/RowGateway/AbstractRowGateway.php @@ -39,7 +39,7 @@ abstract class AbstractRowGateway implements ArrayAccess, Countable, RowGatewayI /** * @var array */ - protected $data = array(); + protected $data = []; /** * @var Sql @@ -65,7 +65,7 @@ public function initialize() } $this->featureSet->setRowGateway($this); - $this->featureSet->apply('preInitialize', array()); + $this->featureSet->apply('preInitialize', []); if (!is_string($this->table) && !$this->table instanceof TableIdentifier) { throw new Exception\RuntimeException('This row object does not have a valid table set.'); @@ -81,7 +81,7 @@ public function initialize() throw new Exception\RuntimeException('This row object does not have a Sql object set.'); } - $this->featureSet->apply('postInitialize', array()); + $this->featureSet->apply('postInitialize', []); $this->isInitialized = true; } @@ -129,7 +129,7 @@ public function save() // UPDATE $data = $this->data; - $where = array(); + $where = []; $isPkModified = false; // primary key is always an array even if its a single column @@ -164,7 +164,7 @@ public function save() $result = $statement->execute(); if (($primaryKeyValue = $result->getGeneratedValue()) && count($this->primaryKeyColumn) == 1) { - $this->primaryKeyData = array($this->primaryKeyColumn[0] => $primaryKeyValue); + $this->primaryKeyData = [$this->primaryKeyColumn[0] => $primaryKeyValue]; } else { // make primary key data available so that $where can be complete $this->processPrimaryKeyData(); @@ -172,7 +172,7 @@ public function save() $rowsAffected = $result->getAffectedRows(); unset($statement, $result); // cleanup - $where = array(); + $where = []; // primary key is always an array even if its a single column foreach ($this->primaryKeyColumn as $pkColumn) { $where[$pkColumn] = $this->primaryKeyData[$pkColumn]; @@ -201,7 +201,7 @@ public function delete() { $this->initialize(); - $where = array(); + $where = []; // primary key is always an array even if its a single column foreach ($this->primaryKeyColumn as $pkColumn) { $where[$pkColumn] = $this->primaryKeyData[$pkColumn]; @@ -349,7 +349,7 @@ public function rowExistsInDatabase() */ protected function processPrimaryKeyData() { - $this->primaryKeyData = array(); + $this->primaryKeyData = []; foreach ($this->primaryKeyColumn as $column) { if (!isset($this->data[$column])) { throw new Exception\RuntimeException('While processing primary key data, a known key ' . $column . ' was not found in the data array'); diff --git a/src/RowGateway/Feature/AbstractFeature.php b/src/RowGateway/Feature/AbstractFeature.php index d53a0ccb26..ff0a8f306b 100644 --- a/src/RowGateway/Feature/AbstractFeature.php +++ b/src/RowGateway/Feature/AbstractFeature.php @@ -22,7 +22,7 @@ abstract class AbstractFeature extends AbstractRowGateway /** * @var array */ - protected $sharedData = array(); + protected $sharedData = []; /** * @return string @@ -53,6 +53,6 @@ public function initialize() */ public function getMagicMethodSpecifications() { - return array(); + return []; } } diff --git a/src/RowGateway/Feature/FeatureSet.php b/src/RowGateway/Feature/FeatureSet.php index 424251c647..ecdbcbc1cb 100644 --- a/src/RowGateway/Feature/FeatureSet.php +++ b/src/RowGateway/Feature/FeatureSet.php @@ -23,17 +23,17 @@ class FeatureSet /** * @var AbstractFeature[] */ - protected $features = array(); + protected $features = []; /** * @var array */ - protected $magicSpecifications = array(); + protected $magicSpecifications = []; /** * @param array $features */ - public function __construct(array $features = array()) + public function __construct(array $features = []) { if ($features) { $this->addFeatures($features); @@ -80,7 +80,7 @@ public function apply($method, $args) { foreach ($this->features as $feature) { if (method_exists($feature, $method)) { - $return = call_user_func_array(array($feature, $method), $args); + $return = call_user_func_array([$feature, $method], $args); if ($return === self::APPLY_HALT) { break; } diff --git a/src/Sql/AbstractExpression.php b/src/Sql/AbstractExpression.php index de207ed5db..db6de79004 100644 --- a/src/Sql/AbstractExpression.php +++ b/src/Sql/AbstractExpression.php @@ -14,12 +14,12 @@ abstract class AbstractExpression implements ExpressionInterface /** * @var string[] */ - protected $allowedTypes = array( + protected $allowedTypes = [ self::TYPE_IDENTIFIER, self::TYPE_LITERAL, self::TYPE_SELECT, self::TYPE_VALUE, - ); + ]; /** * Normalize Argument @@ -85,9 +85,9 @@ private function buildNormalizedArgument($argument, $argumentType) )); } - return array( + return [ $argument, $argumentType, - ); + ]; } } diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index f99b3b9caa..c905997b67 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -22,17 +22,17 @@ abstract class AbstractSql implements SqlInterface * * @var string[]|array[] */ - protected $specifications = array(); + protected $specifications = []; /** * @var string */ - protected $processInfo = array('paramPrefix' => '', 'subselectCount' => 0); + protected $processInfo = ['paramPrefix' => '', 'subselectCount' => 0]; /** * @var array */ - protected $instanceParameterIndex = array(); + protected $instanceParameterIndex = []; /** * {@inheritDoc} @@ -56,8 +56,8 @@ protected function buildSqlString( ) { $this->localizeVariables(); - $sqls = array(); - $parameters = array(); + $sqls = []; + $parameters = []; foreach ($this->specifications as $name => $specification) { $parameters[$name] = $this->{'process' . $name}( @@ -145,7 +145,7 @@ protected function processExpression( // Process values and types (the middle and last position of the // expression data) $values = $part[1]; - $types = isset($part[2]) ? $part[2] : array(); + $types = isset($part[2]) ? $part[2] : []; foreach ($values as $vIndex => $value) { if (!isset($types[$vIndex])) { continue; @@ -222,10 +222,10 @@ protected function createSqlFromSpecificationAndParameters($specifications, $par ); } - $topParameters = array(); + $topParameters = []; foreach ($parameters as $position => $paramsForPosition) { if (isset($paramSpecs[$position]['combinedby'])) { - $multiParamValues = array(); + $multiParamValues = []; foreach ($paramsForPosition as $multiParamsForPosition) { $ppCount = count($multiParamsForPosition); if (!isset($paramSpecs[$position][$ppCount])) { diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index 1b0ed0f4ab..4b5ba30cd6 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -27,14 +27,14 @@ class Combine extends AbstractPreparableSql /** * @var string[] */ - protected $specifications = array( + protected $specifications = [ self::COMBINE => '%1$s (%2$s) ', - ); + ]; /** * @var Select[][] */ - private $combine = array(); + private $combine = []; /** * @param Select|array|null $select @@ -62,7 +62,7 @@ public function combine($select, $type = self::COMBINE_UNION, $modifier = '') if (is_array($select)) { foreach ($select as $combine) { if ($combine instanceof Select) { - $combine = array($combine); + $combine = [$combine]; } $this->combine( @@ -81,11 +81,11 @@ public function combine($select, $type = self::COMBINE_UNION, $modifier = '') )); } - $this->combine[] = array( + $this->combine[] = [ 'select' => $select, 'type' => $type, 'modifier' => $modifier - ); + ]; return $this; } @@ -166,7 +166,7 @@ public function alignColumns() return $this; } - $allColumns = array(); + $allColumns = []; foreach ($this->combine as $combine) { $allColumns = array_merge( $allColumns, @@ -176,7 +176,7 @@ public function alignColumns() foreach ($this->combine as $combine) { $combineColumns = $combine['select']->getRawState(self::COLUMNS); - $aligned = array(); + $aligned = []; foreach ($allColumns as $alias => $column) { $aligned[$alias] = isset($combineColumns[$alias]) ? $combineColumns[$alias] @@ -196,12 +196,12 @@ public function alignColumns() */ public function getRawState($key = null) { - $rawState = array( + $rawState = [ self::COMBINE => $this->combine, self::COLUMNS => $this->combine ? $this->combine[0]['select']->getRawState(self::COLUMNS) - : array(), - ); + : [], + ]; return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } } diff --git a/src/Sql/Ddl/AlterTable.php b/src/Sql/Ddl/AlterTable.php index 467bc2e2e0..4a3b3fe398 100644 --- a/src/Sql/Ddl/AlterTable.php +++ b/src/Sql/Ddl/AlterTable.php @@ -24,60 +24,60 @@ class AlterTable extends AbstractSql implements SqlInterface /** * @var array */ - protected $addColumns = array(); + protected $addColumns = []; /** * @var array */ - protected $addConstraints = array(); + protected $addConstraints = []; /** * @var array */ - protected $changeColumns = array(); + protected $changeColumns = []; /** * @var array */ - protected $dropColumns = array(); + protected $dropColumns = []; /** * @var array */ - protected $dropConstraints = array(); + protected $dropConstraints = []; /** * Specifications for Sql String generation * @var array */ - protected $specifications = array( + protected $specifications = [ self::TABLE => "ALTER TABLE %1\$s\n", - self::ADD_COLUMNS => array( - "%1\$s" => array( - array(1 => "ADD COLUMN %1\$s,\n", 'combinedby' => "") - ) - ), - self::CHANGE_COLUMNS => array( - "%1\$s" => array( - array(2 => "CHANGE COLUMN %1\$s %2\$s,\n", 'combinedby' => ""), - ) - ), - self::DROP_COLUMNS => array( - "%1\$s" => array( - array(1 => "DROP COLUMN %1\$s,\n", 'combinedby' => ""), - ) - ), - self::ADD_CONSTRAINTS => array( - "%1\$s" => array( - array(1 => "ADD %1\$s,\n", 'combinedby' => ""), - ) - ), - self::DROP_CONSTRAINTS => array( - "%1\$s" => array( - array(1 => "DROP CONSTRAINT %1\$s,\n", 'combinedby' => ""), - ) - ) - ); + self::ADD_COLUMNS => [ + "%1\$s" => [ + [1 => "ADD COLUMN %1\$s,\n", 'combinedby' => ""] + ] + ], + self::CHANGE_COLUMNS => [ + "%1\$s" => [ + [2 => "CHANGE COLUMN %1\$s %2\$s,\n", 'combinedby' => ""], + ] + ], + self::DROP_COLUMNS => [ + "%1\$s" => [ + [1 => "DROP COLUMN %1\$s,\n", 'combinedby' => ""], + ] + ], + self::ADD_CONSTRAINTS => [ + "%1\$s" => [ + [1 => "ADD %1\$s,\n", 'combinedby' => ""], + ] + ], + self::DROP_CONSTRAINTS => [ + "%1\$s" => [ + [1 => "DROP CONSTRAINT %1\$s,\n", 'combinedby' => ""], + ] + ] + ]; /** * @var string @@ -165,73 +165,73 @@ public function addConstraint(Constraint\ConstraintInterface $constraint) */ public function getRawState($key = null) { - $rawState = array( + $rawState = [ self::TABLE => $this->table, self::ADD_COLUMNS => $this->addColumns, self::DROP_COLUMNS => $this->dropColumns, self::CHANGE_COLUMNS => $this->changeColumns, self::ADD_CONSTRAINTS => $this->addConstraints, self::DROP_CONSTRAINTS => $this->dropConstraints, - ); + ]; return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } protected function processTable(PlatformInterface $adapterPlatform = null) { - return array($adapterPlatform->quoteIdentifier($this->table)); + return [$adapterPlatform->quoteIdentifier($this->table)]; } protected function processAddColumns(PlatformInterface $adapterPlatform = null) { - $sqls = array(); + $sqls = []; foreach ($this->addColumns as $column) { $sqls[] = $this->processExpression($column, $adapterPlatform); } - return array($sqls); + return [$sqls]; } protected function processChangeColumns(PlatformInterface $adapterPlatform = null) { - $sqls = array(); + $sqls = []; foreach ($this->changeColumns as $name => $column) { - $sqls[] = array( + $sqls[] = [ $adapterPlatform->quoteIdentifier($name), $this->processExpression($column, $adapterPlatform) - ); + ]; } - return array($sqls); + return [$sqls]; } protected function processDropColumns(PlatformInterface $adapterPlatform = null) { - $sqls = array(); + $sqls = []; foreach ($this->dropColumns as $column) { $sqls[] = $adapterPlatform->quoteIdentifier($column); } - return array($sqls); + return [$sqls]; } protected function processAddConstraints(PlatformInterface $adapterPlatform = null) { - $sqls = array(); + $sqls = []; foreach ($this->addConstraints as $constraint) { $sqls[] = $this->processExpression($constraint, $adapterPlatform); } - return array($sqls); + return [$sqls]; } protected function processDropConstraints(PlatformInterface $adapterPlatform = null) { - $sqls = array(); + $sqls = []; foreach ($this->dropConstraints as $constraint) { $sqls[] = $adapterPlatform->quoteIdentifier($constraint); } - return array($sqls); + return [$sqls]; } } diff --git a/src/Sql/Ddl/Column/AbstractLengthColumn.php b/src/Sql/Ddl/Column/AbstractLengthColumn.php index 8bc5074062..c212d06ccb 100644 --- a/src/Sql/Ddl/Column/AbstractLengthColumn.php +++ b/src/Sql/Ddl/Column/AbstractLengthColumn.php @@ -21,7 +21,7 @@ abstract class AbstractLengthColumn extends Column * * @param int $length */ - public function __construct($name, $length = null, $nullable = false, $default = null, array $options = array()) + public function __construct($name, $length = null, $nullable = false, $default = null, array $options = []) { $this->setLength($length); diff --git a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php index d148367d53..c2bae2b122 100644 --- a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php +++ b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php @@ -22,7 +22,7 @@ abstract class AbstractPrecisionColumn extends AbstractLengthColumn * @param int|null $decimal * @param int $digits */ - public function __construct($name, $digits = null, $decimal = null, $nullable = false, $default = null, array $options = array()) + public function __construct($name, $digits = null, $decimal = null, $nullable = false, $default = null, array $options = []) { $this->setDecimal($decimal); diff --git a/src/Sql/Ddl/Column/AbstractTimestampColumn.php b/src/Sql/Ddl/Column/AbstractTimestampColumn.php index 933c84557c..23960238d6 100644 --- a/src/Sql/Ddl/Column/AbstractTimestampColumn.php +++ b/src/Sql/Ddl/Column/AbstractTimestampColumn.php @@ -23,11 +23,11 @@ public function getExpressionData() { $spec = $this->specification; - $params = array(); + $params = []; $params[] = $this->name; $params[] = $this->type; - $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL); + $types = [self::TYPE_IDENTIFIER, self::TYPE_LITERAL]; if (!$this->isNullable) { $spec .= ' NOT NULL'; @@ -47,11 +47,11 @@ public function getExpressionData() $types[] = self::TYPE_LITERAL; } - $data = array(array( + $data = [[ $spec, $params, $types, - )); + ]]; foreach ($this->constraints as $constraint) { $data[] = ' '; diff --git a/src/Sql/Ddl/Column/Column.php b/src/Sql/Ddl/Column/Column.php index 32366fa3e3..8b00ffd188 100644 --- a/src/Sql/Ddl/Column/Column.php +++ b/src/Sql/Ddl/Column/Column.php @@ -31,12 +31,12 @@ class Column implements ColumnInterface /** * @var array */ - protected $options = array(); + protected $options = []; /** * @var ConstraintInterface[] */ - protected $constraints = array(); + protected $constraints = []; /** * @var string @@ -54,7 +54,7 @@ class Column implements ColumnInterface * @param mixed|null $default * @param mixed[] $options */ - public function __construct($name = null, $nullable = false, $default = null, array $options = array()) + public function __construct($name = null, $nullable = false, $default = null, array $options = []) { $this->setName($name); $this->setNullable($nullable); @@ -164,11 +164,11 @@ public function getExpressionData() { $spec = $this->specification; - $params = array(); + $params = []; $params[] = $this->name; $params[] = $this->type; - $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL); + $types = [self::TYPE_IDENTIFIER, self::TYPE_LITERAL]; if (!$this->isNullable) { $spec .= ' NOT NULL'; @@ -180,11 +180,11 @@ public function getExpressionData() $types[] = self::TYPE_VALUE; } - $data = array(array( + $data = [[ $spec, $params, $types, - )); + ]]; foreach ($this->constraints as $constraint) { $data[] = ' '; diff --git a/src/Sql/Ddl/Column/Float.php b/src/Sql/Ddl/Column/Float.php index c04e700783..e6e910d46c 100644 --- a/src/Sql/Ddl/Column/Float.php +++ b/src/Sql/Ddl/Column/Float.php @@ -32,7 +32,7 @@ public function __construct( $decimal = null, $nullable = false, $default = null, - array $options = array() + array $options = [] ) { trigger_error( sprintf( diff --git a/src/Sql/Ddl/Constraint/AbstractConstraint.php b/src/Sql/Ddl/Constraint/AbstractConstraint.php index 57c00fc152..616134c9b6 100644 --- a/src/Sql/Ddl/Constraint/AbstractConstraint.php +++ b/src/Sql/Ddl/Constraint/AbstractConstraint.php @@ -34,7 +34,7 @@ abstract class AbstractConstraint implements ConstraintInterface /** * @var array */ - protected $columns = array(); + protected $columns = []; /** * @param null|string|array $columns @@ -102,8 +102,8 @@ public function getColumns() public function getExpressionData() { $colCount = count($this->columns); - $newSpecTypes = array(); - $values = array(); + $newSpecTypes = []; + $values = []; $newSpec = ''; if ($this->name) { @@ -121,10 +121,10 @@ public function getExpressionData() $newSpec .= sprintf($this->columnSpecification, implode(', ', $newSpecParts)); } - return array(array( + return [[ $newSpec, $values, $newSpecTypes, - )); + ]]; } } diff --git a/src/Sql/Ddl/Constraint/Check.php b/src/Sql/Ddl/Constraint/Check.php index cc4e2a8178..c19a4cd3da 100644 --- a/src/Sql/Ddl/Constraint/Check.php +++ b/src/Sql/Ddl/Constraint/Check.php @@ -36,8 +36,8 @@ public function __construct($expression, $name) */ public function getExpressionData() { - $newSpecTypes = array(self::TYPE_LITERAL); - $values = array($this->expression); + $newSpecTypes = [self::TYPE_LITERAL]; + $values = [$this->expression]; $newSpec = ''; if ($this->name) { @@ -47,10 +47,10 @@ public function getExpressionData() array_unshift($newSpecTypes, self::TYPE_IDENTIFIER); } - return array(array( + return [[ $newSpec . $this->specification, $values, $newSpecTypes, - )); + ]]; } } diff --git a/src/Sql/Ddl/Constraint/ForeignKey.php b/src/Sql/Ddl/Constraint/ForeignKey.php index c8189aaa37..8b87b75b0e 100644 --- a/src/Sql/Ddl/Constraint/ForeignKey.php +++ b/src/Sql/Ddl/Constraint/ForeignKey.php @@ -24,7 +24,7 @@ class ForeignKey extends AbstractConstraint /** * @var string[] */ - protected $referenceColumn = array(); + protected $referenceColumn = []; /** * @var string @@ -39,10 +39,10 @@ class ForeignKey extends AbstractConstraint /** * @var string[] */ - protected $referenceSpecification = array( + protected $referenceSpecification = [ 'REFERENCES %s ', 'ON DELETE %s ON UPDATE %s' - ); + ]; /** * @param null|string $name @@ -150,8 +150,8 @@ public function getExpressionData() { $data = parent::getExpressionData(); $colCount = count($this->referenceColumn); - $newSpecTypes = array(self::TYPE_IDENTIFIER); - $values = array($this->referenceTable); + $newSpecTypes = [self::TYPE_IDENTIFIER]; + $values = [$this->referenceTable]; $data[0][0] .= $this->referenceSpecification[0]; diff --git a/src/Sql/Ddl/CreateTable.php b/src/Sql/Ddl/CreateTable.php index 31aa4cc26d..f43ca7844f 100644 --- a/src/Sql/Ddl/CreateTable.php +++ b/src/Sql/Ddl/CreateTable.php @@ -21,12 +21,12 @@ class CreateTable extends AbstractSql implements SqlInterface /** * @var Column\ColumnInterface[] */ - protected $columns = array(); + protected $columns = []; /** * @var string[] */ - protected $constraints = array(); + protected $constraints = []; /** * @var bool @@ -36,21 +36,21 @@ class CreateTable extends AbstractSql implements SqlInterface /** * {@inheritDoc} */ - protected $specifications = array( + protected $specifications = [ self::TABLE => 'CREATE %1$sTABLE %2$s (', - self::COLUMNS => array( - "\n %1\$s" => array( - array(1 => '%1$s', 'combinedby' => ",\n ") - ) - ), + self::COLUMNS => [ + "\n %1\$s" => [ + [1 => '%1$s', 'combinedby' => ",\n "] + ] + ], 'combinedBy' => ",", - self::CONSTRAINTS => array( - "\n %1\$s" => array( - array(1 => '%1$s', 'combinedby' => ",\n ") - ) - ), + self::CONSTRAINTS => [ + "\n %1\$s" => [ + [1 => '%1$s', 'combinedby' => ",\n "] + ] + ], 'statementEnd' => '%1$s', - ); + ]; /** * @var string @@ -121,11 +121,11 @@ public function addConstraint(Constraint\ConstraintInterface $constraint) */ public function getRawState($key = null) { - $rawState = array( + $rawState = [ self::COLUMNS => $this->columns, self::CONSTRAINTS => $this->constraints, self::TABLE => $this->table, - ); + ]; return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } @@ -137,10 +137,10 @@ public function getRawState($key = null) */ protected function processTable(PlatformInterface $adapterPlatform = null) { - return array( + return [ $this->isTemporary ? 'TEMPORARY ' : '', $adapterPlatform->quoteIdentifier($this->table), - ); + ]; } /** @@ -154,13 +154,13 @@ protected function processColumns(PlatformInterface $adapterPlatform = null) return; } - $sqls = array(); + $sqls = []; foreach ($this->columns as $column) { $sqls[] = $this->processExpression($column, $adapterPlatform); } - return array($sqls); + return [$sqls]; } /** @@ -186,13 +186,13 @@ protected function processConstraints(PlatformInterface $adapterPlatform = null) return; } - $sqls = array(); + $sqls = []; foreach ($this->constraints as $constraint) { $sqls[] = $this->processExpression($constraint, $adapterPlatform); } - return array($sqls); + return [$sqls]; } /** @@ -202,6 +202,6 @@ protected function processConstraints(PlatformInterface $adapterPlatform = null) */ protected function processStatementEnd(PlatformInterface $adapterPlatform = null) { - return array("\n)"); + return ["\n)"]; } } diff --git a/src/Sql/Ddl/DropTable.php b/src/Sql/Ddl/DropTable.php index 6f5646ef0a..683e70ebcc 100644 --- a/src/Sql/Ddl/DropTable.php +++ b/src/Sql/Ddl/DropTable.php @@ -19,9 +19,9 @@ class DropTable extends AbstractSql implements SqlInterface /** * @var array */ - protected $specifications = array( + protected $specifications = [ self::TABLE => 'DROP TABLE %1$s' - ); + ]; /** * @var string @@ -38,6 +38,6 @@ public function __construct($table = '') protected function processTable(PlatformInterface $adapterPlatform = null) { - return array($adapterPlatform->quoteIdentifier($this->table)); + return [$adapterPlatform->quoteIdentifier($this->table)]; } } diff --git a/src/Sql/Ddl/Index/Index.php b/src/Sql/Ddl/Index/Index.php index 872fab727c..4edef01ad3 100644 --- a/src/Sql/Ddl/Index/Index.php +++ b/src/Sql/Ddl/Index/Index.php @@ -26,7 +26,7 @@ class Index extends AbstractIndex * @param null|string $name * @param array $lengths */ - public function __construct($column, $name = null, array $lengths = array()) + public function __construct($column, $name = null, array $lengths = []) { $this->setColumns($column); @@ -53,10 +53,10 @@ public function __construct($column, $name = null, array $lengths = array()) public function getExpressionData() { $colCount = count($this->columns); - $values = array(); + $values = []; $values[] = $this->name ?: ''; - $newSpecTypes = array(self::TYPE_IDENTIFIER); - $newSpecParts = array(); + $newSpecTypes = [self::TYPE_IDENTIFIER]; + $newSpecParts = []; for ($i = 0; $i < $colCount; $i++) { $specPart = '%s'; @@ -71,10 +71,10 @@ public function getExpressionData() $newSpec = str_replace('...', implode(', ', $newSpecParts), $this->specification); - return array(array( + return [[ $newSpec, array_merge($values, $this->columns), $newSpecTypes, - )); + ]]; } } diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index 10ada94ab8..2cedd974f5 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -29,10 +29,10 @@ class Delete extends AbstractPreparableSql /** * {@inheritDoc} */ - protected $specifications = array( + protected $specifications = [ self::SPECIFICATION_DELETE => 'DELETE FROM %1$s', self::SPECIFICATION_WHERE => 'WHERE %1$s' - ); + ]; /** * @var string|TableIdentifier @@ -47,7 +47,7 @@ class Delete extends AbstractPreparableSql /** * @var array */ - protected $set = array(); + protected $set = []; /** * @var null|string|Where @@ -86,12 +86,12 @@ public function from($table) */ public function getRawState($key = null) { - $rawState = array( + $rawState = [ 'emptyWhereProtection' => $this->emptyWhereProtection, 'table' => $this->table, 'set' => $this->set, 'where' => $this->where - ); + ]; return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index 04fb789e71..5e634fe898 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -24,19 +24,19 @@ class Expression extends AbstractExpression /** * @var array */ - protected $parameters = array(); + protected $parameters = []; /** * @var array */ - protected $types = array(); + protected $types = []; /** * @param string $expression * @param string|array $parameters * @param array $types @deprecated will be dropped in version 3.0.0 */ - public function __construct($expression = '', $parameters = null, array $types = array()) + public function __construct($expression = '', $parameters = null, array $types = []) { if ($expression !== '') { $this->setExpression($expression); @@ -45,14 +45,14 @@ public function __construct($expression = '', $parameters = null, array $types = if ($types) { // should be deprecated and removed version 3.0.0 if (is_array($parameters)) { foreach ($parameters as $i=>$parameter) { - $parameters[$i] = array( + $parameters[$i] = [ $parameter => isset($types[$i]) ? $types[$i] : self::TYPE_VALUE, - ); + ]; } } elseif (is_scalar($parameters)) { - $parameters = array( + $parameters = [ $parameters => $types[0], - ); + ]; } } @@ -131,14 +131,14 @@ public function getTypes() */ public function getExpressionData() { - $parameters = (is_scalar($this->parameters)) ? array($this->parameters) : $this->parameters; + $parameters = (is_scalar($this->parameters)) ? [$this->parameters] : $this->parameters; $parametersCount = count($parameters); $expression = str_replace('%', '%%', $this->expression); if ($parametersCount == 0) { - return array( + return [ str_ireplace(self::PLACEHOLDER, '', $expression) - ); + ]; } // assign locally, escaping % signs @@ -149,10 +149,10 @@ public function getExpressionData() foreach ($parameters as $parameter) { list($values[], $types[]) = $this->normalizeArgument($parameter, self::TYPE_VALUE); } - return array(array( + return [[ $expression, $values, $types - )); + ]]; } } diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index b319616dce..f325c47076 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -29,16 +29,16 @@ class Insert extends AbstractPreparableSql /** * @var array Specification array */ - protected $specifications = array( + protected $specifications = [ self::SPECIFICATION_INSERT => 'INSERT INTO %1$s (%2$s) VALUES (%3$s)', self::SPECIFICATION_SELECT => 'INSERT INTO %1$s %2$s %3$s', - ); + ]; /** * @var string|TableIdentifier */ protected $table = null; - protected $columns = array(); + protected $columns = []; /** * @var array|Select @@ -141,11 +141,11 @@ public function select(Select $select) */ public function getRawState($key = null) { - $rawState = array( + $rawState = [ 'table' => $this->table, 'columns' => array_keys($this->columns), 'values' => array_values($this->columns) - ); + ]; return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } @@ -158,8 +158,8 @@ protected function processInsert(PlatformInterface $platform, DriverInterface $d throw new Exception\InvalidArgumentException('values or select should be present'); } - $columns = array(); - $values = array(); + $columns = []; + $values = []; foreach ($this->columns as $column=>$value) { $columns[] = $platform->quoteIdentifier($column); if (is_scalar($value) && $parameterContainer) { @@ -189,7 +189,7 @@ protected function processSelect(PlatformInterface $platform, DriverInterface $d } $selectSql = $this->processSubSelect($this->select, $platform, $driver, $parameterContainer); - $columns = array_map(array($platform, 'quoteIdentifier'), array_keys($this->columns)); + $columns = array_map([$platform, 'quoteIdentifier'], array_keys($this->columns)); $columns = implode(', ', $columns); return sprintf( diff --git a/src/Sql/Literal.php b/src/Sql/Literal.php index 1da410288f..9dc2cf7882 100644 --- a/src/Sql/Literal.php +++ b/src/Sql/Literal.php @@ -47,10 +47,10 @@ public function getLiteral() */ public function getExpressionData() { - return array(array( + return [[ str_replace('%', '%%', $this->literal), - array(), - array() - )); + [], + [] + ]]; } } diff --git a/src/Sql/Platform/AbstractPlatform.php b/src/Sql/Platform/AbstractPlatform.php index 32d5bd1f2c..7a6d279e3d 100644 --- a/src/Sql/Platform/AbstractPlatform.php +++ b/src/Sql/Platform/AbstractPlatform.php @@ -26,7 +26,7 @@ class AbstractPlatform implements PlatformDecoratorInterface, PreparableSqlInter /** * @var PlatformDecoratorInterface[] */ - protected $decorators = array(); + protected $decorators = []; /** * {@inheritDoc} diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index 9df9398c81..311417ff4c 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -90,7 +90,7 @@ protected function processLimitOffset(PlatformInterface $platform, DriverInterfa || (isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR) || strpos($columnParameters[0], $starSuffix) ) { - $selectParameters[0] = array(array(self::SQL_STAR)); + $selectParameters[0] = [[self::SQL_STAR]]; break; } @@ -102,7 +102,7 @@ protected function processLimitOffset(PlatformInterface $platform, DriverInterfa // first, produce column list without compound names (using the AS portion only) array_unshift($sqls, $this->createSqlFromSpecificationAndParameters( - array('SELECT %1$s FROM (' => current($this->specifications[self::SELECT])), + ['SELECT %1$s FROM (' => current($this->specifications[self::SELECT])], $selectParameters )); @@ -151,9 +151,9 @@ protected function processLimitOffset(PlatformInterface $platform, DriverInterfa // add a column for row_number() using the order specification //dense_rank() if ($this->getIsSelectContainDistinct()) { - $parameters[self::SELECT][0][] = array('DENSE_RANK() OVER (' . $orderBy . ')', 'ZEND_DB_ROWNUM'); + $parameters[self::SELECT][0][] = ['DENSE_RANK() OVER (' . $orderBy . ')', 'ZEND_DB_ROWNUM']; } else { - $parameters[self::SELECT][0][] = array('ROW_NUMBER() OVER (' . $orderBy . ')', 'ZEND_DB_ROWNUM'); + $parameters[self::SELECT][0][] = ['ROW_NUMBER() OVER (' . $orderBy . ')', 'ZEND_DB_ROWNUM']; } $sqls[self::SELECT] = $this->createSqlFromSpecificationAndParameters( diff --git a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php index c6390e341b..f8c2db7aec 100644 --- a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php @@ -23,7 +23,7 @@ class AlterTableDecorator extends AlterTable implements PlatformDecoratorInterfa /** * @var int[] */ - protected $columnOptionSortOrder = array( + protected $columnOptionSortOrder = [ 'unsigned' => 0, 'zerofill' => 1, 'identity' => 2, @@ -33,7 +33,7 @@ class AlterTableDecorator extends AlterTable implements PlatformDecoratorInterfa 'columnformat' => 4, 'format' => 4, 'storage' => 5, - ); + ]; /** * @param AlterTable $subject @@ -53,9 +53,9 @@ public function setSubject($subject) protected function getSqlInsertOffsets($sql) { $sqlLength = strlen($sql); - $insertStart = array(); + $insertStart = []; - foreach (array('NOT NULL', 'NULL', 'DEFAULT', 'UNIQUE', 'PRIMARY', 'REFERENCES') as $needle) { + foreach (['NOT NULL', 'NULL', 'DEFAULT', 'UNIQUE', 'PRIMARY', 'REFERENCES'] as $needle) { $insertPos = strpos($sql, ' ' . $needle); if ($insertPos !== false) { @@ -86,14 +86,14 @@ protected function getSqlInsertOffsets($sql) */ protected function processAddColumns(PlatformInterface $adapterPlatform = null) { - $sqls = array(); + $sqls = []; foreach ($this->addColumns as $i => $column) { $sql = $this->processExpression($column, $adapterPlatform); $insertStart = $this->getSqlInsertOffsets($sql); $columnOptions = $column->getOptions(); - uksort($columnOptions, array($this, 'compareColumnOptions')); + uksort($columnOptions, [$this, 'compareColumnOptions']); foreach ($columnOptions as $coName => $coValue) { $insert = ''; @@ -143,7 +143,7 @@ protected function processAddColumns(PlatformInterface $adapterPlatform = null) } $sqls[$i] = $sql; } - return array($sqls); + return [$sqls]; } /** @@ -152,13 +152,13 @@ protected function processAddColumns(PlatformInterface $adapterPlatform = null) */ protected function processChangeColumns(PlatformInterface $adapterPlatform = null) { - $sqls = array(); + $sqls = []; foreach ($this->changeColumns as $name => $column) { $sql = $this->processExpression($column, $adapterPlatform); $insertStart = $this->getSqlInsertOffsets($sql); $columnOptions = $column->getOptions(); - uksort($columnOptions, array($this, 'compareColumnOptions')); + uksort($columnOptions, [$this, 'compareColumnOptions']); foreach ($columnOptions as $coName => $coValue) { $insert = ''; @@ -206,13 +206,13 @@ protected function processChangeColumns(PlatformInterface $adapterPlatform = nul } } } - $sqls[] = array( + $sqls[] = [ $adapterPlatform->quoteIdentifier($name), $sql - ); + ]; } - return array($sqls); + return [$sqls]; } /** @@ -222,7 +222,7 @@ protected function processChangeColumns(PlatformInterface $adapterPlatform = nul */ private function normalizeColumnOption($name) { - return strtolower(str_replace(array('-', '_', ' '), '', $name)); + return strtolower(str_replace(['-', '_', ' '], '', $name)); } /** diff --git a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php index 34ea4adf67..575ac875f7 100644 --- a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php @@ -23,7 +23,7 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter /** * @var int[] */ - protected $columnOptionSortOrder = array( + protected $columnOptionSortOrder = [ 'unsigned' => 0, 'zerofill' => 1, 'identity' => 2, @@ -33,7 +33,7 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter 'columnformat' => 4, 'format' => 4, 'storage' => 5, - ); + ]; /** * @param CreateTable $subject @@ -54,9 +54,9 @@ public function setSubject($subject) protected function getSqlInsertOffsets($sql) { $sqlLength = strlen($sql); - $insertStart = array(); + $insertStart = []; - foreach (array('NOT NULL', 'NULL', 'DEFAULT', 'UNIQUE', 'PRIMARY', 'REFERENCES') as $needle) { + foreach (['NOT NULL', 'NULL', 'DEFAULT', 'UNIQUE', 'PRIMARY', 'REFERENCES'] as $needle) { $insertPos = strpos($sql, ' ' . $needle); if ($insertPos !== false) { @@ -90,14 +90,14 @@ protected function processColumns(PlatformInterface $platform = null) return; } - $sqls = array(); + $sqls = []; foreach ($this->columns as $i => $column) { $sql = $this->processExpression($column, $platform); $insertStart = $this->getSqlInsertOffsets($sql); $columnOptions = $column->getOptions(); - uksort($columnOptions, array($this, 'compareColumnOptions')); + uksort($columnOptions, [$this, 'compareColumnOptions']); foreach ($columnOptions as $coName => $coValue) { $insert = ''; @@ -149,7 +149,7 @@ protected function processColumns(PlatformInterface $platform = null) $sqls[$i] = $sql; } - return array($sqls); + return [$sqls]; } /** @@ -159,7 +159,7 @@ protected function processColumns(PlatformInterface $platform = null) */ private function normalizeColumnOption($name) { - return strtolower(str_replace(array('-', '_', ' '), '', $name)); + return strtolower(str_replace(['-', '_', ' '], '', $name)); } /** diff --git a/src/Sql/Platform/Mysql/SelectDecorator.php b/src/Sql/Platform/Mysql/SelectDecorator.php index decf909108..03f8dd0446 100644 --- a/src/Sql/Platform/Mysql/SelectDecorator.php +++ b/src/Sql/Platform/Mysql/SelectDecorator.php @@ -41,17 +41,17 @@ protected function localizeVariables() protected function processLimit(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { if ($this->limit === null && $this->offset !== null) { - return array(''); + return ['']; } if ($this->limit === null) { return; } if ($parameterContainer) { $parameterContainer->offsetSet('limit', $this->limit, ParameterContainer::TYPE_INTEGER); - return array($driver->formatParameterName('limit')); + return [$driver->formatParameterName('limit')]; } - return array($this->limit); + return [$this->limit]; } protected function processOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) @@ -61,9 +61,9 @@ protected function processOffset(PlatformInterface $platform, DriverInterface $d } if ($parameterContainer) { $parameterContainer->offsetSet('offset', $this->offset, ParameterContainer::TYPE_INTEGER); - return array($driver->formatParameterName('offset')); + return [$driver->formatParameterName('offset')]; } - return array($this->offset); + return [$this->offset]; } } diff --git a/src/Sql/Platform/Oracle/SelectDecorator.php b/src/Sql/Platform/Oracle/SelectDecorator.php index 389d3b2ac3..01d7fb7219 100644 --- a/src/Sql/Platform/Oracle/SelectDecorator.php +++ b/src/Sql/Platform/Oracle/SelectDecorator.php @@ -66,7 +66,7 @@ protected function processLimitOffset(PlatformInterface $platform, DriverInterfa $starSuffix = $platform->getIdentifierSeparator() . self::SQL_STAR; foreach ($selectParameters[0] as $i => $columnParameters) { if ($columnParameters[0] == self::SQL_STAR || (isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR) || strpos($columnParameters[0], $starSuffix)) { - $selectParameters[0] = array(array(self::SQL_STAR)); + $selectParameters[0] = [[self::SQL_STAR]]; break; } if (isset($columnParameters[1])) { @@ -81,7 +81,7 @@ protected function processLimitOffset(PlatformInterface $platform, DriverInterfa // first, produce column list without compound names (using the AS portion only) array_unshift($sqls, $this->createSqlFromSpecificationAndParameters( - array('SELECT %1$s FROM (SELECT b.%1$s, rownum b_rownum FROM (' => current($this->specifications[self::SELECT])), $selectParameters + ['SELECT %1$s FROM (SELECT b.%1$s, rownum b_rownum FROM (' => current($this->specifications[self::SELECT])], $selectParameters )); if ($parameterContainer) { diff --git a/src/Sql/Platform/Platform.php b/src/Sql/Platform/Platform.php index 886ed1933e..237c3918be 100644 --- a/src/Sql/Platform/Platform.php +++ b/src/Sql/Platform/Platform.php @@ -119,7 +119,7 @@ public function getSqlString(PlatformInterface $adapterPlatform = null) protected function resolvePlatformName($adapterOrPlatform) { $platformName = $this->resolvePlatform($adapterOrPlatform)->getName(); - return str_replace(array(' ', '_'), '', strtolower($platformName)); + return str_replace([' ', '_'], '', strtolower($platformName)); } /** * @param null|PlatformInterface|AdapterInterface $adapterOrPlatform diff --git a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php index 0a8ea8c37b..bf401afbb4 100644 --- a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php @@ -37,9 +37,9 @@ public function setSubject($subject) protected function processTable(PlatformInterface $adapterPlatform = null) { $table = ($this->isTemporary ? '#' : '') . ltrim($this->table, '#'); - return array( + return [ '', $adapterPlatform->quoteIdentifier($table), - ); + ]; } } diff --git a/src/Sql/Platform/SqlServer/SelectDecorator.php b/src/Sql/Platform/SqlServer/SelectDecorator.php index e1da3f2298..8537020ad2 100644 --- a/src/Sql/Platform/SqlServer/SelectDecorator.php +++ b/src/Sql/Platform/SqlServer/SelectDecorator.php @@ -59,7 +59,7 @@ protected function processLimitOffset(PlatformInterface $platform, DriverInterfa $starSuffix = $platform->getIdentifierSeparator() . self::SQL_STAR; foreach ($selectParameters[0] as $i => $columnParameters) { if ($columnParameters[0] == self::SQL_STAR || (isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR) || strpos($columnParameters[0], $starSuffix)) { - $selectParameters[0] = array(array(self::SQL_STAR)); + $selectParameters[0] = [[self::SQL_STAR]]; break; } if (isset($columnParameters[1])) { @@ -70,7 +70,7 @@ protected function processLimitOffset(PlatformInterface $platform, DriverInterfa // first, produce column list without compound names (using the AS portion only) array_unshift($sqls, $this->createSqlFromSpecificationAndParameters( - array('SELECT %1$s FROM (' => current($this->specifications[self::SELECT])), + ['SELECT %1$s FROM (' => current($this->specifications[self::SELECT])], $selectParameters )); @@ -99,7 +99,7 @@ protected function processLimitOffset(PlatformInterface $platform, DriverInterfa } // add a column for row_number() using the order specification - $parameters[self::SELECT][0][] = array('ROW_NUMBER() OVER (' . $orderBy . ')', '[__ZEND_ROW_NUMBER]'); + $parameters[self::SELECT][0][] = ['ROW_NUMBER() OVER (' . $orderBy . ')', '[__ZEND_ROW_NUMBER]']; $sqls[self::SELECT] = $this->createSqlFromSpecificationAndParameters( $this->specifications[self::SELECT], diff --git a/src/Sql/Predicate/Between.php b/src/Sql/Predicate/Between.php index b927cdf4ef..d380110ad1 100644 --- a/src/Sql/Predicate/Between.php +++ b/src/Sql/Predicate/Between.php @@ -136,12 +136,12 @@ public function getExpressionData() list($values[], $types[]) = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); list($values[], $types[]) = $this->normalizeArgument($this->minValue, self::TYPE_VALUE); list($values[], $types[]) = $this->normalizeArgument($this->maxValue, self::TYPE_VALUE); - return array( - array( + return [ + [ $this->getSpecification(), $values, $types, - ), - ); + ], + ]; } } diff --git a/src/Sql/Predicate/In.php b/src/Sql/Predicate/In.php index 7fcefcde6d..31124ea7f1 100644 --- a/src/Sql/Predicate/In.php +++ b/src/Sql/Predicate/In.php @@ -99,7 +99,7 @@ public function getExpressionData() { $identifier = $this->getIdentifier(); $values = $this->getValueSet(); - $replacements = array(); + $replacements = []; if (is_array($identifier)) { $identifierSpecFragment = '(' . implode(', ', array_fill(0, count($identifier), '%s')) . ')'; @@ -108,13 +108,13 @@ public function getExpressionData() } else { $identifierSpecFragment = '%s'; $replacements[] = $identifier; - $types = array(self::TYPE_IDENTIFIER); + $types = [self::TYPE_IDENTIFIER]; } if ($values instanceof Select) { $specification = vsprintf( $this->specification, - array($identifierSpecFragment, '%s') + [$identifierSpecFragment, '%s'] ); $replacements[] = $values; $types[] = self::TYPE_VALUE; @@ -124,14 +124,14 @@ public function getExpressionData() } $specification = vsprintf( $this->specification, - array($identifierSpecFragment, '(' . implode(', ', array_fill(0, count($values), '%s')) . ')') + [$identifierSpecFragment, '(' . implode(', ', array_fill(0, count($values), '%s')) . ')'] ); } - return array(array( + return [[ $specification, $replacements, $types, - )); + ]]; } } diff --git a/src/Sql/Predicate/IsNull.php b/src/Sql/Predicate/IsNull.php index 3ae953e5be..4b5d7bd10b 100644 --- a/src/Sql/Predicate/IsNull.php +++ b/src/Sql/Predicate/IsNull.php @@ -87,10 +87,10 @@ public function getSpecification() public function getExpressionData() { $identifier = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); - return array(array( + return [[ $this->getSpecification(), - array($identifier[0]), - array($identifier[1]), - )); + [$identifier[0]], + [$identifier[1]], + ]]; } } diff --git a/src/Sql/Predicate/Like.php b/src/Sql/Predicate/Like.php index 301340c6c0..06d4bde6bb 100644 --- a/src/Sql/Predicate/Like.php +++ b/src/Sql/Predicate/Like.php @@ -103,12 +103,12 @@ public function getExpressionData() { list($values[], $types[]) = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); list($values[], $types[]) = $this->normalizeArgument($this->like, self::TYPE_VALUE); - return array( - array( + return [ + [ $this->specification, $values, $types, - ) - ); + ] + ]; } } diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index 2de5dfd355..9ac331c466 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -35,10 +35,10 @@ class Operator extends AbstractExpression implements PredicateInterface /** * {@inheritDoc} */ - protected $allowedTypes = array( + protected $allowedTypes = [ self::TYPE_IDENTIFIER, self::TYPE_VALUE, - ); + ]; /** * @var int|float|bool|string @@ -261,10 +261,10 @@ public function getExpressionData() list($values[], $types[]) = $this->normalizeArgument($this->left, $this->leftType); list($values[], $types[]) = $this->normalizeArgument($this->right, $this->rightType); - return array(array( + return [[ '%s ' . $this->operator . ' %s', $values, $types - )); + ]]; } } diff --git a/src/Sql/Predicate/PredicateSet.php b/src/Sql/Predicate/PredicateSet.php index 921d8fcb44..06138138dc 100644 --- a/src/Sql/Predicate/PredicateSet.php +++ b/src/Sql/Predicate/PredicateSet.php @@ -21,7 +21,7 @@ class PredicateSet implements PredicateInterface, Countable const OP_OR = 'OR'; protected $defaultCombination = self::COMBINED_BY_AND; - protected $predicates = array(); + protected $predicates = []; /** * Constructor @@ -48,7 +48,7 @@ public function __construct(array $predicates = null, $defaultCombination = self */ public function addPredicate(PredicateInterface $predicate, $combination = null) { - if ($combination === null || !in_array($combination, array(self::OP_AND, self::OP_OR))) { + if ($combination === null || !in_array($combination, [self::OP_AND, self::OP_OR])) { $combination = $this->defaultCombination; } @@ -142,7 +142,7 @@ public function getPredicates() */ public function orPredicate(PredicateInterface $predicate) { - $this->predicates[] = array(self::OP_OR, $predicate); + $this->predicates[] = [self::OP_OR, $predicate]; return $this; } @@ -154,7 +154,7 @@ public function orPredicate(PredicateInterface $predicate) */ public function andPredicate(PredicateInterface $predicate) { - $this->predicates[] = array(self::OP_AND, $predicate); + $this->predicates[] = [self::OP_AND, $predicate]; return $this; } @@ -165,7 +165,7 @@ public function andPredicate(PredicateInterface $predicate) */ public function getExpressionData() { - $parts = array(); + $parts = []; for ($i = 0, $count = count($this->predicates); $i < $count; $i++) { /** @var $predicate PredicateInterface */ $predicate = $this->predicates[$i][1]; diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 2596eb2cc8..2a538b4396 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -55,44 +55,44 @@ class Select extends AbstractPreparableSql /** * @var array Specifications */ - protected $specifications = array( + protected $specifications = [ 'statementStart' => '%1$s', - self::SELECT => array( - 'SELECT %1$s FROM %2$s' => array( - array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '), + self::SELECT => [ + 'SELECT %1$s FROM %2$s' => [ + [1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '], null - ), - 'SELECT %1$s %2$s FROM %3$s' => array( + ], + 'SELECT %1$s %2$s FROM %3$s' => [ null, - array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '), + [1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '], null - ), - 'SELECT %1$s' => array( - array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '), - ), - ), - self::JOINS => array( - '%1$s' => array( - array(3 => '%1$s JOIN %2$s ON %3$s', 'combinedby' => ' ') - ) - ), + ], + 'SELECT %1$s' => [ + [1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '], + ], + ], + self::JOINS => [ + '%1$s' => [ + [3 => '%1$s JOIN %2$s ON %3$s', 'combinedby' => ' '] + ] + ], self::WHERE => 'WHERE %1$s', - self::GROUP => array( - 'GROUP BY %1$s' => array( - array(1 => '%1$s', 'combinedby' => ', ') - ) - ), + self::GROUP => [ + 'GROUP BY %1$s' => [ + [1 => '%1$s', 'combinedby' => ', '] + ] + ], self::HAVING => 'HAVING %1$s', - self::ORDER => array( - 'ORDER BY %1$s' => array( - array(1 => '%1$s', 2 => '%1$s %2$s', 'combinedby' => ', ') - ) - ), + self::ORDER => [ + 'ORDER BY %1$s' => [ + [1 => '%1$s', 2 => '%1$s %2$s', 'combinedby' => ', '] + ] + ], self::LIMIT => 'LIMIT %1$s', self::OFFSET => 'OFFSET %1$s', 'statementEnd' => '%1$s', self::COMBINE => '%1$s ( %2$s )', - ); + ]; /** * @var bool @@ -117,12 +117,12 @@ class Select extends AbstractPreparableSql /** * @var array */ - protected $columns = array(self::SQL_STAR); + protected $columns = [self::SQL_STAR]; /** * @var array */ - protected $joins = array(); + protected $joins = []; /** * @var Where @@ -132,7 +132,7 @@ class Select extends AbstractPreparableSql /** * @var array */ - protected $order = array(); + protected $order = []; /** * @var null|array @@ -157,7 +157,7 @@ class Select extends AbstractPreparableSql /** * @var array */ - protected $combine = array(); + protected $combine = []; /** * Constructor @@ -258,14 +258,14 @@ public function join($name, $on, $columns = self::SQL_STAR, $type = self::JOIN_I ); } if (!is_array($columns)) { - $columns = array($columns); + $columns = [$columns]; } - $this->joins[] = array( + $this->joins[] = [ 'name' => $name, 'on' => $on, 'columns' => $columns, 'type' => $type - ); + ]; return $this; } @@ -329,7 +329,7 @@ public function order($order) $order = (array) $order; } } elseif (!is_array($order)) { - $order = array($order); + $order = [$order]; } foreach ($order as $k => $v) { if (is_string($k)) { @@ -386,14 +386,14 @@ public function offset($offset) */ public function combine(Select $select, $type = self::COMBINE_UNION, $modifier = '') { - if ($this->combine !== array()) { + if ($this->combine !== []) { throw new Exception\InvalidArgumentException('This Select object is already combined and cannot be combined with multiple Selects objects'); } - $this->combine = array( + $this->combine = [ 'select' => $select, 'type' => $type, 'modifier' => $modifier - ); + ]; return $this; } @@ -417,10 +417,10 @@ public function reset($part) $this->quantifier = null; break; case self::COLUMNS: - $this->columns = array(); + $this->columns = []; break; case self::JOINS: - $this->joins = array(); + $this->joins = []; break; case self::WHERE: $this->where = new Where; @@ -438,10 +438,10 @@ public function reset($part) $this->offset = null; break; case self::ORDER: - $this->order = array(); + $this->order = []; break; case self::COMBINE: - $this->combine = array(); + $this->combine = []; break; } return $this; @@ -458,7 +458,7 @@ public function setSpecification($index, $specification) public function getRawState($key = null) { - $rawState = array( + $rawState = [ self::TABLE => $this->table, self::QUANTIFIER => $this->quantifier, self::COLUMNS => $this->columns, @@ -470,7 +470,7 @@ public function getRawState($key = null) self::LIMIT => $this->limit, self::OFFSET => $this->offset, self::COMBINE => $this->combine - ); + ]; return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } @@ -499,15 +499,15 @@ protected function renderTable($table, $alias = null) protected function processStatementStart(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { - if ($this->combine !== array()) { - return array('('); + if ($this->combine !== []) { + return ['(']; } } protected function processStatementEnd(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { - if ($this->combine !== array()) { - return array(')'); + if ($this->combine !== []) { + return [')']; } } @@ -525,19 +525,19 @@ protected function processSelect(PlatformInterface $platform, DriverInterface $d list($table, $fromTable) = $this->resolveTable($this->table, $platform, $driver, $parameterContainer); // process table columns - $columns = array(); + $columns = []; foreach ($this->columns as $columnIndexOrAs => $column) { if ($column === self::SQL_STAR) { - $columns[] = array($fromTable . self::SQL_STAR); + $columns[] = [$fromTable . self::SQL_STAR]; continue; } $columnName = $this->resolveColumnValue( - array( + [ 'column' => $column, 'fromTable' => $fromTable, 'isIdentifier' => true, - ), + ], $platform, $driver, $parameterContainer, @@ -549,7 +549,7 @@ protected function processSelect(PlatformInterface $platform, DriverInterface $d } elseif (stripos($columnName, ' as ') === false) { $columnAs = (is_string($column)) ? $platform->quoteIdentifier($column) : 'Expression' . $expr++; } - $columns[] = (isset($columnAs)) ? array($columnName, $columnAs) : array($columnName); + $columns[] = (isset($columnAs)) ? [$columnName, $columnAs] : [$columnName]; } // process join columns @@ -558,16 +558,16 @@ protected function processSelect(PlatformInterface $platform, DriverInterface $d $joinName = parent::resolveTable($joinName, $platform, $driver, $parameterContainer); foreach ($join['columns'] as $jKey => $jColumn) { - $jColumns = array(); + $jColumns = []; $jFromTable = is_scalar($jColumn) ? $joinName . $platform->getIdentifierSeparator() : ''; $jColumns[] = $this->resolveColumnValue( - array( + [ 'column' => $jColumn, 'fromTable' => $jFromTable, 'isIdentifier' => true, - ), + ], $platform, $driver, $parameterContainer, @@ -589,11 +589,11 @@ protected function processSelect(PlatformInterface $platform, DriverInterface $d } if (!isset($table)) { - return array($columns); + return [$columns]; } elseif (isset($quantifier)) { - return array($quantifier, $columns, $table); + return [$quantifier, $columns, $table]; } else { - return array($columns, $table); + return [$columns, $table]; } } @@ -604,7 +604,7 @@ protected function processJoins(PlatformInterface $platform, DriverInterface $dr } // process joins - $joinSpecArgArray = array(); + $joinSpecArgArray = []; foreach ($this->joins as $j => $join) { $joinName = null; $joinAs = null; @@ -624,25 +624,25 @@ protected function processJoins(PlatformInterface $platform, DriverInterface $dr $joinName = ($joinName[1] ? $platform->quoteIdentifier($joinName[1]) . $platform->getIdentifierSeparator() : '') . $platform->quoteIdentifier($joinName[0]); } elseif ($joinName instanceof Select) { $joinName = '(' . $this->processSubSelect($joinName, $platform, $driver, $parameterContainer) . ')'; - } elseif (is_string($joinName) || (is_object($joinName) && is_callable(array($joinName, '__toString')))) { + } elseif (is_string($joinName) || (is_object($joinName) && is_callable([$joinName, '__toString']))) { $joinName = $platform->quoteIdentifier($joinName); } else { throw new Exception\InvalidArgumentException(sprintf('Join name expected to be Expression|TableIdentifier|Select|string, "%s" given', gettype($joinName))); } - $joinSpecArgArray[$j] = array( + $joinSpecArgArray[$j] = [ strtoupper($join['type']), $this->renderTable($joinName, $joinAs), - ); + ]; // on expression // note: for Expression objects, pass them to processExpression with a prefix specific to each join (used for named parameters) $joinSpecArgArray[$j][] = ($join['on'] instanceof ExpressionInterface) ? $this->processExpression($join['on'], $platform, $driver, $parameterContainer, 'join' . ($j+1) . 'part') - : $platform->quoteIdentifierInFragment($join['on'], array('=', 'AND', 'OR', '(', ')', 'BETWEEN', '<', '>')); // on + : $platform->quoteIdentifierInFragment($join['on'], ['=', 'AND', 'OR', '(', ')', 'BETWEEN', '<', '>']); // on } - return array($joinSpecArgArray); + return [$joinSpecArgArray]; } protected function processWhere(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) @@ -650,9 +650,9 @@ protected function processWhere(PlatformInterface $platform, DriverInterface $dr if ($this->where->count() == 0) { return; } - return array( + return [ $this->processExpression($this->where, $platform, $driver, $parameterContainer, 'where') - ); + ]; } protected function processGroup(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) @@ -661,20 +661,20 @@ protected function processGroup(PlatformInterface $platform, DriverInterface $dr return; } // process table columns - $groups = array(); + $groups = []; foreach ($this->group as $column) { $groups[] = $this->resolveColumnValue( - array( + [ 'column' => $column, 'isIdentifier' => true, - ), + ], $platform, $driver, $parameterContainer, 'group' ); } - return array($groups); + return [$groups]; } protected function processHaving(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) @@ -682,9 +682,9 @@ protected function processHaving(PlatformInterface $platform, DriverInterface $d if ($this->having->count() == 0) { return; } - return array( + return [ $this->processExpression($this->having, $platform, $driver, $parameterContainer, 'having') - ); + ]; } protected function processOrder(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) @@ -692,12 +692,12 @@ protected function processOrder(PlatformInterface $platform, DriverInterface $dr if (empty($this->order)) { return; } - $orders = array(); + $orders = []; foreach ($this->order as $k => $v) { if ($v instanceof ExpressionInterface) { - $orders[] = array( + $orders[] = [ $this->processExpression($v, $platform, $driver, $parameterContainer) - ); + ]; continue; } if (is_int($k)) { @@ -709,12 +709,12 @@ protected function processOrder(PlatformInterface $platform, DriverInterface $dr } } if (strtoupper($v) == self::ORDER_DESCENDING) { - $orders[] = array($platform->quoteIdentifierInFragment($k), self::ORDER_DESCENDING); + $orders[] = [$platform->quoteIdentifierInFragment($k), self::ORDER_DESCENDING]; } else { - $orders[] = array($platform->quoteIdentifierInFragment($k), self::ORDER_ASCENDING); + $orders[] = [$platform->quoteIdentifierInFragment($k), self::ORDER_ASCENDING]; } } - return array($orders); + return [$orders]; } protected function processLimit(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) @@ -724,9 +724,9 @@ protected function processLimit(PlatformInterface $platform, DriverInterface $dr } if ($parameterContainer) { $parameterContainer->offsetSet('limit', $this->limit, ParameterContainer::TYPE_INTEGER); - return array($driver->formatParameterName('limit')); + return [$driver->formatParameterName('limit')]; } - return array($platform->quoteValue($this->limit)); + return [$platform->quoteValue($this->limit)]; } protected function processOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) @@ -736,15 +736,15 @@ protected function processOffset(PlatformInterface $platform, DriverInterface $d } if ($parameterContainer) { $parameterContainer->offsetSet('offset', $this->offset, ParameterContainer::TYPE_INTEGER); - return array($driver->formatParameterName('offset')); + return [$driver->formatParameterName('offset')]; } - return array($platform->quoteValue($this->offset)); + return [$platform->quoteValue($this->offset)]; } protected function processCombine(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { - if ($this->combine == array()) { + if ($this->combine == []) { return; } @@ -753,10 +753,10 @@ protected function processCombine(PlatformInterface $platform, DriverInterface $ $type .= ' ' . $this->combine['modifier']; } - return array( + return [ strtoupper($type), $this->processSubSelect($this->combine['select'], $platform, $driver, $parameterContainer), - ); + ]; } /** @@ -822,9 +822,9 @@ protected function resolveTable($table, PlatformInterface $platform, DriverInter $fromTable = ''; } - return array( + return [ $table, $fromTable - ); + ]; } } diff --git a/src/Sql/TableIdentifier.php b/src/Sql/TableIdentifier.php index 315e52433a..2b775202d5 100644 --- a/src/Sql/TableIdentifier.php +++ b/src/Sql/TableIdentifier.php @@ -29,7 +29,7 @@ class TableIdentifier */ public function __construct($table, $schema = null) { - if (! (is_string($table) || is_callable(array($table, '__toString')))) { + if (! (is_string($table) || is_callable([$table, '__toString']))) { throw new Exception\InvalidArgumentException(sprintf( '$table must be a valid table name, parameter of type %s given', is_object($table) ? get_class($table) : gettype($table) @@ -45,7 +45,7 @@ public function __construct($table, $schema = null) if (null === $schema) { $this->schema = null; } else { - if (! (is_string($schema) || is_callable(array($schema, '__toString')))) { + if (! (is_string($schema) || is_callable([$schema, '__toString']))) { throw new Exception\InvalidArgumentException(sprintf( '$schema must be a valid schema name, parameter of type %s given', is_object($schema) ? get_class($schema) : gettype($schema) @@ -108,6 +108,6 @@ public function getSchema() public function getTableAndSchema() { - return array($this->table, $this->schema); + return [$this->table, $this->schema]; } } diff --git a/src/Sql/Update.php b/src/Sql/Update.php index 75dd4ea8b5..95712158ef 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -30,10 +30,10 @@ class Update extends AbstractPreparableSql const VALUES_SET = 'set'; /**@#-**/ - protected $specifications = array( + protected $specifications = [ self::SPECIFICATION_UPDATE => 'UPDATE %1$s SET %2$s', self::SPECIFICATION_WHERE => 'WHERE %1$s' - ); + ]; /** * @var string|TableIdentifier @@ -129,18 +129,18 @@ public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) public function getRawState($key = null) { - $rawState = array( + $rawState = [ 'emptyWhereProtection' => $this->emptyWhereProtection, 'table' => $this->table, 'set' => $this->set->toArray(), 'where' => $this->where - ); + ]; return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } protected function processUpdate(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null) { - $setSql = array(); + $setSql = []; foreach ($this->set as $column => $value) { $prefix = $platform->quoteIdentifier($column) . ' = '; if (is_scalar($value) && $parameterContainer) { diff --git a/src/TableGateway/AbstractTableGateway.php b/src/TableGateway/AbstractTableGateway.php index 43037259db..1b2ef275ca 100644 --- a/src/TableGateway/AbstractTableGateway.php +++ b/src/TableGateway/AbstractTableGateway.php @@ -47,7 +47,7 @@ abstract class AbstractTableGateway implements TableGatewayInterface /** * @var array */ - protected $columns = array(); + protected $columns = []; /** * @var Feature\FeatureSet @@ -95,7 +95,7 @@ public function initialize() } $this->featureSet->setTableGateway($this); - $this->featureSet->apply(EventFeature::EVENT_PRE_INITIALIZE, array()); + $this->featureSet->apply(EventFeature::EVENT_PRE_INITIALIZE, []); if (!$this->adapter instanceof AdapterInterface) { throw new Exception\RuntimeException('This table does not have an Adapter setup'); @@ -113,7 +113,7 @@ public function initialize() $this->sql = new Sql($this->adapter, $this->table); } - $this->featureSet->apply(EventFeature::EVENT_POST_INITIALIZE, array()); + $this->featureSet->apply(EventFeature::EVENT_POST_INITIALIZE, []); $this->isInitialized = true; } @@ -225,13 +225,13 @@ protected function executeSelect(Select $select) ); } - if ($selectState['columns'] == array(Select::SQL_STAR) - && $this->columns !== array()) { + if ($selectState['columns'] == [Select::SQL_STAR] + && $this->columns !== []) { $select->columns($this->columns); } // apply preSelect features - $this->featureSet->apply(EventFeature::EVENT_PRE_SELECT, array($select)); + $this->featureSet->apply(EventFeature::EVENT_PRE_SELECT, [$select]); // prepare and execute $statement = $this->sql->prepareStatementForSqlObject($select); @@ -242,7 +242,7 @@ protected function executeSelect(Select $select) $resultSet->initialize($result); // apply postSelect features - $this->featureSet->apply(EventFeature::EVENT_POST_SELECT, array($statement, $result, $resultSet)); + $this->featureSet->apply(EventFeature::EVENT_POST_SELECT, [$statement, $result, $resultSet]); return $resultSet; } @@ -292,7 +292,7 @@ protected function executeInsert(Insert $insert) } // apply preInsert features - $this->featureSet->apply(EventFeature::EVENT_PRE_INSERT, array($insert)); + $this->featureSet->apply(EventFeature::EVENT_PRE_INSERT, [$insert]); // Most RDBMS solutions do not allow using table aliases in INSERTs // See https://github.com/zendframework/zf2/issues/7311 @@ -308,7 +308,7 @@ protected function executeInsert(Insert $insert) $this->lastInsertValue = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue(); // apply postInsert features - $this->featureSet->apply(EventFeature::EVENT_POST_INSERT, array($statement, $result)); + $this->featureSet->apply(EventFeature::EVENT_POST_INSERT, [$statement, $result]); // Reset original table information in Insert instance, if necessary if ($unaliasedTable) { @@ -369,13 +369,13 @@ protected function executeUpdate(Update $update) } // apply preUpdate features - $this->featureSet->apply(EventFeature::EVENT_PRE_UPDATE, array($update)); + $this->featureSet->apply(EventFeature::EVENT_PRE_UPDATE, [$update]); $statement = $this->sql->prepareStatementForSqlObject($update); $result = $statement->execute(); // apply postUpdate features - $this->featureSet->apply(EventFeature::EVENT_POST_UPDATE, array($statement, $result)); + $this->featureSet->apply(EventFeature::EVENT_POST_UPDATE, [$statement, $result]); return $result->getAffectedRows(); } @@ -427,13 +427,13 @@ protected function executeDelete(Delete $delete) } // pre delete update - $this->featureSet->apply(EventFeature::EVENT_PRE_DELETE, array($delete)); + $this->featureSet->apply(EventFeature::EVENT_PRE_DELETE, [$delete]); $statement = $this->sql->prepareStatementForSqlObject($delete); $result = $statement->execute(); // apply postDelete features - $this->featureSet->apply(EventFeature::EVENT_POST_DELETE, array($statement, $result)); + $this->featureSet->apply(EventFeature::EVENT_POST_DELETE, [$statement, $result]); return $result->getAffectedRows(); } diff --git a/src/TableGateway/Feature/AbstractFeature.php b/src/TableGateway/Feature/AbstractFeature.php index ddbf33284d..c644dbf8d7 100644 --- a/src/TableGateway/Feature/AbstractFeature.php +++ b/src/TableGateway/Feature/AbstractFeature.php @@ -19,7 +19,7 @@ abstract class AbstractFeature extends AbstractTableGateway */ protected $tableGateway = null; - protected $sharedData = array(); + protected $sharedData = []; public function getName() { @@ -38,7 +38,7 @@ public function initialize() public function getMagicMethodSpecifications() { - return array(); + return []; } diff --git a/src/TableGateway/Feature/EventFeature.php b/src/TableGateway/Feature/EventFeature.php index 73de610f41..5960a96de9 100644 --- a/src/TableGateway/Feature/EventFeature.php +++ b/src/TableGateway/Feature/EventFeature.php @@ -59,9 +59,9 @@ public function __construct( ? $eventManager : new EventManager; - $this->eventManager->addIdentifiers(array( + $this->eventManager->addIdentifiers([ 'Zend\Db\TableGateway\TableGateway', - )); + ]); $this->event = ($tableGatewayEvent) ?: new EventFeature\TableGatewayEvent(); } @@ -129,7 +129,7 @@ public function postInitialize() public function preSelect(Select $select) { $this->event->setName(static::EVENT_PRE_SELECT); - $this->event->setParams(array('select' => $select)); + $this->event->setParams(['select' => $select]); $this->eventManager->trigger($this->event); } @@ -149,11 +149,11 @@ public function preSelect(Select $select) public function postSelect(StatementInterface $statement, ResultInterface $result, ResultSetInterface $resultSet) { $this->event->setName(static::EVENT_POST_SELECT); - $this->event->setParams(array( + $this->event->setParams([ 'statement' => $statement, 'result' => $result, 'result_set' => $resultSet - )); + ]); $this->eventManager->trigger($this->event); } @@ -169,7 +169,7 @@ public function postSelect(StatementInterface $statement, ResultInterface $resul public function preInsert(Insert $insert) { $this->event->setName(static::EVENT_PRE_INSERT); - $this->event->setParams(array('insert' => $insert)); + $this->event->setParams(['insert' => $insert]); $this->eventManager->trigger($this->event); } @@ -187,10 +187,10 @@ public function preInsert(Insert $insert) public function postInsert(StatementInterface $statement, ResultInterface $result) { $this->event->setName(static::EVENT_POST_INSERT); - $this->event->setParams(array( + $this->event->setParams([ 'statement' => $statement, 'result' => $result, - )); + ]); $this->eventManager->trigger($this->event); } @@ -206,7 +206,7 @@ public function postInsert(StatementInterface $statement, ResultInterface $resul public function preUpdate(Update $update) { $this->event->setName(static::EVENT_PRE_UPDATE); - $this->event->setParams(array('update' => $update)); + $this->event->setParams(['update' => $update]); $this->eventManager->trigger($this->event); } @@ -224,10 +224,10 @@ public function preUpdate(Update $update) public function postUpdate(StatementInterface $statement, ResultInterface $result) { $this->event->setName(static::EVENT_POST_UPDATE); - $this->event->setParams(array( + $this->event->setParams([ 'statement' => $statement, 'result' => $result, - )); + ]); $this->eventManager->trigger($this->event); } @@ -243,7 +243,7 @@ public function postUpdate(StatementInterface $statement, ResultInterface $resul public function preDelete(Delete $delete) { $this->event->setName(static::EVENT_PRE_DELETE); - $this->event->setParams(array('delete' => $delete)); + $this->event->setParams(['delete' => $delete]); $this->eventManager->trigger($this->event); } @@ -261,10 +261,10 @@ public function preDelete(Delete $delete) public function postDelete(StatementInterface $statement, ResultInterface $result) { $this->event->setName(static::EVENT_POST_DELETE); - $this->event->setParams(array( + $this->event->setParams([ 'statement' => $statement, 'result' => $result, - )); + ]); $this->eventManager->trigger($this->event); } } diff --git a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php index af46132d11..4835a62c2c 100644 --- a/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php +++ b/src/TableGateway/Feature/EventFeature/TableGatewayEvent.php @@ -27,7 +27,7 @@ class TableGatewayEvent implements EventInterface /** * @var array|\ArrayAccess */ - protected $params = array(); + protected $params = []; /** * Get event name diff --git a/src/TableGateway/Feature/FeatureSet.php b/src/TableGateway/Feature/FeatureSet.php index 939444e0e7..2e70817685 100644 --- a/src/TableGateway/Feature/FeatureSet.php +++ b/src/TableGateway/Feature/FeatureSet.php @@ -21,14 +21,14 @@ class FeatureSet /** * @var AbstractFeature[] */ - protected $features = array(); + protected $features = []; /** * @var array */ - protected $magicSpecifications = array(); + protected $magicSpecifications = []; - public function __construct(array $features = array()) + public function __construct(array $features = []) { if ($features) { $this->addFeatures($features); @@ -77,7 +77,7 @@ public function apply($method, $args) { foreach ($this->features as $feature) { if (method_exists($feature, $method)) { - $return = call_user_func_array(array($feature, $method), $args); + $return = call_user_func_array([$feature, $method], $args); if ($return === self::APPLY_HALT) { break; } diff --git a/src/TableGateway/Feature/GlobalAdapterFeature.php b/src/TableGateway/Feature/GlobalAdapterFeature.php index bdcd97dc30..4b4d68fe6e 100644 --- a/src/TableGateway/Feature/GlobalAdapterFeature.php +++ b/src/TableGateway/Feature/GlobalAdapterFeature.php @@ -17,7 +17,7 @@ class GlobalAdapterFeature extends AbstractFeature /** * @var Adapter[] */ - protected static $staticAdapters = array(); + protected static $staticAdapters = []; /** * Set static adapter diff --git a/src/TableGateway/Feature/MetadataFeature.php b/src/TableGateway/Feature/MetadataFeature.php index a1cc39e5a9..398f73a246 100644 --- a/src/TableGateway/Feature/MetadataFeature.php +++ b/src/TableGateway/Feature/MetadataFeature.php @@ -31,10 +31,10 @@ public function __construct(MetadataInterface $metadata = null) if ($metadata) { $this->metadata = $metadata; } - $this->sharedData['metadata'] = array( + $this->sharedData['metadata'] = [ 'primaryKey' => null, - 'columns' => array() - ); + 'columns' => [] + ]; } public function postInitialize() diff --git a/src/TableGateway/Feature/RowGatewayFeature.php b/src/TableGateway/Feature/RowGatewayFeature.php index 88f07097b7..4161fd7e1f 100644 --- a/src/TableGateway/Feature/RowGatewayFeature.php +++ b/src/TableGateway/Feature/RowGatewayFeature.php @@ -19,7 +19,7 @@ class RowGatewayFeature extends AbstractFeature /** * @var array */ - protected $constructorArguments = array(); + protected $constructorArguments = []; /** * @param null $primaryKey diff --git a/src/TableGateway/Feature/SequenceFeature.php b/src/TableGateway/Feature/SequenceFeature.php index fa34068aed..07e7651efa 100644 --- a/src/TableGateway/Feature/SequenceFeature.php +++ b/src/TableGateway/Feature/SequenceFeature.php @@ -60,7 +60,7 @@ public function preInsert(Insert $insert) return $insert; } - $insert->values(array($this->primaryKeyField => $this->sequenceValue), Insert::VALUES_MERGE); + $insert->values([$this->primaryKeyField => $this->sequenceValue], Insert::VALUES_MERGE); return $insert; } diff --git a/src/TableGateway/TableGateway.php b/src/TableGateway/TableGateway.php index 62604f6a20..fc24e30ac6 100644 --- a/src/TableGateway/TableGateway.php +++ b/src/TableGateway/TableGateway.php @@ -42,7 +42,7 @@ public function __construct($table, AdapterInterface $adapter, $features = null, // process features if ($features !== null) { if ($features instanceof Feature\AbstractFeature) { - $features = array($features); + $features = [$features]; } if (is_array($features)) { $this->featureSet = new Feature\FeatureSet($features); diff --git a/test/Adapter/AdapterAbstractServiceFactoryTest.php b/test/Adapter/AdapterAbstractServiceFactoryTest.php index 62c0ed6970..00d9a92e56 100644 --- a/test/Adapter/AdapterAbstractServiceFactoryTest.php +++ b/test/Adapter/AdapterAbstractServiceFactoryTest.php @@ -26,22 +26,22 @@ class AdapterAbstractServiceFactoryTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->serviceManager = new ServiceManager(new ServiceManagerConfig(array( - 'abstract_factories' => array('Zend\Db\Adapter\AdapterAbstractServiceFactory'), - ))); + $this->serviceManager = new ServiceManager(new ServiceManagerConfig([ + 'abstract_factories' => ['Zend\Db\Adapter\AdapterAbstractServiceFactory'], + ])); - $this->serviceManager->setService('Config', array( - 'db' => array( - 'adapters' => array( - 'Zend\Db\Adapter\Writer' => array( + $this->serviceManager->setService('Config', [ + 'db' => [ + 'adapters' => [ + 'Zend\Db\Adapter\Writer' => [ 'driver' => 'mysqli', - ), - 'Zend\Db\Adapter\Reader' => array( + ], + 'Zend\Db\Adapter\Reader' => [ 'driver' => 'mysqli', - ), - ), - ), - )); + ], + ], + ], + ]); } /** @@ -49,10 +49,10 @@ protected function setUp() */ public function providerValidService() { - return array( - array('Zend\Db\Adapter\Writer'), - array('Zend\Db\Adapter\Reader'), - ); + return [ + ['Zend\Db\Adapter\Writer'], + ['Zend\Db\Adapter\Reader'], + ]; } /** @@ -60,9 +60,9 @@ public function providerValidService() */ public function providerInvalidService() { - return array( - array('Zend\Db\Adapter\Unknown'), - ); + return [ + ['Zend\Db\Adapter\Unknown'], + ]; } /** diff --git a/test/Adapter/AdapterTest.php b/test/Adapter/AdapterTest.php index b5e2f284fc..dca479fe3e 100644 --- a/test/Adapter/AdapterTest.php +++ b/test/Adapter/AdapterTest.php @@ -71,7 +71,7 @@ public function testGetProfiler() $this->adapter->setProfiler($profiler = new Profiler\Profiler()); $this->assertSame($profiler, $this->adapter->getProfiler()); - $adapter = new Adapter(array('driver' => $this->mockDriver, 'profiler' => true), $this->mockPlatform); + $adapter = new Adapter(['driver' => $this->mockDriver, 'profiler' => true], $this->mockPlatform); $this->assertInstanceOf('Zend\Db\Adapter\Profiler\Profiler', $adapter->getProfiler()); } @@ -82,25 +82,25 @@ public function testGetProfiler() public function testCreateDriver() { if (extension_loaded('mysqli')) { - $adapter = new Adapter(array('driver' => 'mysqli'), $this->mockPlatform); + $adapter = new Adapter(['driver' => 'mysqli'], $this->mockPlatform); $this->assertInstanceOf('Zend\Db\Adapter\Driver\Mysqli\Mysqli', $adapter->driver); unset($adapter); } if (extension_loaded('pgsql')) { - $adapter = new Adapter(array('driver' => 'pgsql'), $this->mockPlatform); + $adapter = new Adapter(['driver' => 'pgsql'], $this->mockPlatform); $this->assertInstanceOf('Zend\Db\Adapter\Driver\Pgsql\Pgsql', $adapter->driver); unset($adapter); } if (extension_loaded('sqlsrv')) { - $adapter = new Adapter(array('driver' => 'sqlsrv'), $this->mockPlatform); + $adapter = new Adapter(['driver' => 'sqlsrv'], $this->mockPlatform); $this->assertInstanceOf('Zend\Db\Adapter\Driver\Sqlsrv\Sqlsrv', $adapter->driver); unset($adapter); } if (extension_loaded('pdo')) { - $adapter = new Adapter(array('driver' => 'pdo_sqlite'), $this->mockPlatform); + $adapter = new Adapter(['driver' => 'pdo_sqlite'], $this->mockPlatform); $this->assertInstanceOf('Zend\Db\Adapter\Driver\Pdo\Pdo', $adapter->driver); unset($adapter); } @@ -155,7 +155,7 @@ public function testCreatePlatform() unset($adapter, $driver); // ensure platform can created via string, and also that it passed in options to platform object - $driver = array('driver' => 'pdo_sqlite', 'platform' => 'Oracle', 'platform_options' => array('quote_identifiers' => false)); + $driver = ['driver' => 'pdo_sqlite', 'platform' => 'Oracle', 'platform_options' => ['quote_identifiers' => false]]; $adapter = new Adapter($driver); $this->assertInstanceOf('Zend\Db\Adapter\Platform\Oracle', $adapter->platform); $this->assertEquals('foo', $adapter->getPlatform()->quoteIdentifier('foo')); @@ -216,7 +216,7 @@ public function testQueryWhenPreparedProducesStatement() */ public function testQueryWhenPreparedWithParameterArrayProducesResult() { - $parray = array('bar'=>'foo'); + $parray = ['bar'=>'foo']; $sql = 'SELECT foo, :bar'; $statement = $this->getMock('\Zend\Db\Adapter\Driver\StatementInterface'); $result = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface'); diff --git a/test/Adapter/Driver/IbmDb2/AbstractIntegrationTest.php b/test/Adapter/Driver/IbmDb2/AbstractIntegrationTest.php index 593e7c9de6..df04068c3c 100644 --- a/test/Adapter/Driver/IbmDb2/AbstractIntegrationTest.php +++ b/test/Adapter/Driver/IbmDb2/AbstractIntegrationTest.php @@ -14,11 +14,11 @@ abstract class AbstractIntegrationTest extends \PHPUnit_Framework_TestCase /** * @var array */ - protected $variables = array( + protected $variables = [ 'database' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_IBMDB2_DATABASE', 'username' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_IBMDB2_USERNAME', 'password' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_IBMDB2_PASSWORD', - ); + ]; /** * Sets up the fixture, for example, opens a network connection. diff --git a/test/Adapter/Driver/IbmDb2/ConnectionIntegrationTest.php b/test/Adapter/Driver/IbmDb2/ConnectionIntegrationTest.php index dc796c3f31..6ec66a17c7 100644 --- a/test/Adapter/Driver/IbmDb2/ConnectionIntegrationTest.php +++ b/test/Adapter/Driver/IbmDb2/ConnectionIntegrationTest.php @@ -37,7 +37,7 @@ public function testSetResource() $this->variables['username'], $this->variables['password'] ); - $connection = new Connection(array()); + $connection = new Connection([]); $this->assertSame($connection, $connection->setResource($resource)); $connection->disconnect(); @@ -202,7 +202,7 @@ public function testConnectReturnsConnectionWhenResourceSet() $this->variables['username'], $this->variables['password'] ); - $connection = new Connection(array()); + $connection = new Connection([]); $connection->setResource($resource); $this->assertSame($connection, $connection->connect()); diff --git a/test/Adapter/Driver/IbmDb2/ConnectionTest.php b/test/Adapter/Driver/IbmDb2/ConnectionTest.php index f6adfc9907..7a1e2bb34d 100644 --- a/test/Adapter/Driver/IbmDb2/ConnectionTest.php +++ b/test/Adapter/Driver/IbmDb2/ConnectionTest.php @@ -25,7 +25,7 @@ class ConnectionTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->connection = new Connection(array()); + $this->connection = new Connection([]); } /** @@ -41,7 +41,7 @@ protected function tearDown() */ public function testSetDriver() { - $this->assertEquals($this->connection, $this->connection->setDriver(new IbmDb2(array()))); + $this->assertEquals($this->connection, $this->connection->setDriver(new IbmDb2([]))); } /** @@ -49,7 +49,7 @@ public function testSetDriver() */ public function testSetConnectionParameters() { - $this->assertEquals($this->connection, $this->connection->setConnectionParameters(array())); + $this->assertEquals($this->connection, $this->connection->setConnectionParameters([])); } /** @@ -57,7 +57,7 @@ public function testSetConnectionParameters() */ public function testGetConnectionParameters() { - $this->connection->setConnectionParameters(array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $this->connection->getConnectionParameters()); + $this->connection->setConnectionParameters(['foo' => 'bar']); + $this->assertEquals(['foo' => 'bar'], $this->connection->getConnectionParameters()); } } diff --git a/test/Adapter/Driver/IbmDb2/IbmDb2IntegrationTest.php b/test/Adapter/Driver/IbmDb2/IbmDb2IntegrationTest.php index ccc3e1e2e1..3c9115c14b 100644 --- a/test/Adapter/Driver/IbmDb2/IbmDb2IntegrationTest.php +++ b/test/Adapter/Driver/IbmDb2/IbmDb2IntegrationTest.php @@ -23,13 +23,13 @@ class IbmDb2IntegrationTest extends AbstractIntegrationTest */ public function testCheckEnvironment() { - $ibmdb2 = new IbmDb2(array()); + $ibmdb2 = new IbmDb2([]); $this->assertNull($ibmdb2->checkEnvironment()); } public function testCreateStatement() { - $driver = new IbmDb2(array()); + $driver = new IbmDb2([]); $resource = db2_connect( $this->variables['database'], diff --git a/test/Adapter/Driver/IbmDb2/IbmDb2Test.php b/test/Adapter/Driver/IbmDb2/IbmDb2Test.php index e911a5bcdd..e9e0ce5449 100644 --- a/test/Adapter/Driver/IbmDb2/IbmDb2Test.php +++ b/test/Adapter/Driver/IbmDb2/IbmDb2Test.php @@ -24,7 +24,7 @@ class IbmDb2Test extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->ibmdb2 = new IbmDb2(array()); + $this->ibmdb2 = new IbmDb2([]); } /** @@ -32,7 +32,7 @@ protected function setUp() */ public function testRegisterConnection() { - $mockConnection = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\IbmDb2\Connection', array(array()), '', true, true, true, array('setDriver')); + $mockConnection = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\IbmDb2\Connection', [[]], '', true, true, true, ['setDriver']); $mockConnection->expects($this->once())->method('setDriver')->with($this->equalTo($this->ibmdb2)); $this->assertSame($this->ibmdb2, $this->ibmdb2->registerConnection($mockConnection)); } @@ -42,8 +42,8 @@ public function testRegisterConnection() */ public function testRegisterStatementPrototype() { - $this->ibmdb2 = new IbmDb2(array()); - $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\IbmDb2\Statement', array(), '', true, true, true, array('setDriver')); + $this->ibmdb2 = new IbmDb2([]); + $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\IbmDb2\Statement', [], '', true, true, true, ['setDriver']); $mockStatement->expects($this->once())->method('setDriver')->with($this->equalTo($this->ibmdb2)); $this->assertSame($this->ibmdb2, $this->ibmdb2->registerStatementPrototype($mockStatement)); } @@ -53,8 +53,8 @@ public function testRegisterStatementPrototype() */ public function testRegisterResultPrototype() { - $this->ibmdb2 = new IbmDb2(array()); - $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\IbmDb2\Result', array(), '', true, true, true, array('setDriver')); + $this->ibmdb2 = new IbmDb2([]); + $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\IbmDb2\Result', [], '', true, true, true, ['setDriver']); $this->assertSame($this->ibmdb2, $this->ibmdb2->registerResultPrototype($mockStatement)); } @@ -63,7 +63,7 @@ public function testRegisterResultPrototype() */ public function testGetDatabasePlatformName() { - $this->ibmdb2 = new IbmDb2(array()); + $this->ibmdb2 = new IbmDb2([]); $this->assertEquals('IbmDb2', $this->ibmdb2->getDatabasePlatformName()); $this->assertEquals('IBM DB2', $this->ibmdb2->getDatabasePlatformName(IbmDb2::NAME_FORMAT_NATURAL)); } @@ -74,7 +74,7 @@ public function testGetDatabasePlatformName() */ public function testGetConnection($mockConnection) { - $conn = new \Zend\Db\Adapter\Driver\IbmDb2\Connection(array()); + $conn = new \Zend\Db\Adapter\Driver\IbmDb2\Connection([]); $this->ibmdb2->registerConnection($conn); $this->assertSame($conn, $this->ibmdb2->getConnection()); } diff --git a/test/Adapter/Driver/IbmDb2/StatementIntegrationTest.php b/test/Adapter/Driver/IbmDb2/StatementIntegrationTest.php index d2855889ca..41f47572b8 100644 --- a/test/Adapter/Driver/IbmDb2/StatementIntegrationTest.php +++ b/test/Adapter/Driver/IbmDb2/StatementIntegrationTest.php @@ -18,11 +18,11 @@ */ class StatementIntegrationTest extends \PHPUnit_Framework_TestCase { - protected $variables = array( + protected $variables = [ 'database' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_IBMDB2_DATABASE', 'username' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_IBMDB2_USERNAME', 'password' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_IBMDB2_PASSWORD', - ); + ]; /** * Sets up the fixture, for example, opens a network connection. diff --git a/test/Adapter/Driver/IbmDb2/StatementTest.php b/test/Adapter/Driver/IbmDb2/StatementTest.php index 178db2a116..1fb34a5488 100644 --- a/test/Adapter/Driver/IbmDb2/StatementTest.php +++ b/test/Adapter/Driver/IbmDb2/StatementTest.php @@ -42,7 +42,7 @@ protected function tearDown() */ public function testSetDriver() { - $this->assertEquals($this->statement, $this->statement->setDriver(new IbmDb2(array()))); + $this->assertEquals($this->statement, $this->statement->setDriver(new IbmDb2([]))); } /** diff --git a/test/Adapter/Driver/Oci8/AbstractIntegrationTest.php b/test/Adapter/Driver/Oci8/AbstractIntegrationTest.php index c1a617d1b5..091e320bc3 100644 --- a/test/Adapter/Driver/Oci8/AbstractIntegrationTest.php +++ b/test/Adapter/Driver/Oci8/AbstractIntegrationTest.php @@ -11,11 +11,11 @@ abstract class AbstractIntegrationTest extends \PHPUnit_Framework_TestCase { - protected $variables = array( + protected $variables = [ 'hostname' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_HOSTNAME', 'username' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_USERNAME', 'password' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD', - ); + ]; /** * Sets up the fixture, for example, opens a network connection. diff --git a/test/Adapter/Driver/Oci8/ConnectionIntegrationTest.php b/test/Adapter/Driver/Oci8/ConnectionIntegrationTest.php index 5d58d69b9e..b1af12bac2 100644 --- a/test/Adapter/Driver/Oci8/ConnectionIntegrationTest.php +++ b/test/Adapter/Driver/Oci8/ConnectionIntegrationTest.php @@ -35,7 +35,7 @@ public function testSetResource() $this->markTestIncomplete('edit this'); $resource = oci_connect($this->variables['username'], $this->variables['password'], $this->variables['hostname']); - $connection = new Connection(array()); + $connection = new Connection([]); $this->assertSame($connection, $connection->setResource($resource)); $connection->disconnect(); @@ -161,7 +161,7 @@ public function testConnectReturnsConnectionWhenResourceSet() $this->markTestIncomplete('edit this'); $resource = oci_connect($this->variables['username'], $this->variables['password'], $this->variables['hostname']); - $connection = new Connection(array()); + $connection = new Connection([]); $connection->setResource($resource); $this->assertSame($connection, $connection->connect()); diff --git a/test/Adapter/Driver/Oci8/ConnectionTest.php b/test/Adapter/Driver/Oci8/ConnectionTest.php index 3e57a6c1de..678f085e41 100644 --- a/test/Adapter/Driver/Oci8/ConnectionTest.php +++ b/test/Adapter/Driver/Oci8/ConnectionTest.php @@ -25,7 +25,7 @@ class ConnectionTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->connection = new Connection(array()); + $this->connection = new Connection([]); } /** @@ -41,7 +41,7 @@ protected function tearDown() */ public function testSetDriver() { - $this->assertEquals($this->connection, $this->connection->setDriver(new Oci8(array()))); + $this->assertEquals($this->connection, $this->connection->setDriver(new Oci8([]))); } /** @@ -49,7 +49,7 @@ public function testSetDriver() */ public function testSetConnectionParameters() { - $this->assertEquals($this->connection, $this->connection->setConnectionParameters(array())); + $this->assertEquals($this->connection, $this->connection->setConnectionParameters([])); } /** @@ -57,7 +57,7 @@ public function testSetConnectionParameters() */ public function testGetConnectionParameters() { - $this->connection->setConnectionParameters(array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $this->connection->getConnectionParameters()); + $this->connection->setConnectionParameters(['foo' => 'bar']); + $this->assertEquals(['foo' => 'bar'], $this->connection->getConnectionParameters()); } } diff --git a/test/Adapter/Driver/Oci8/Oci8IntegrationTest.php b/test/Adapter/Driver/Oci8/Oci8IntegrationTest.php index b6e9703fb8..5b22d001fe 100644 --- a/test/Adapter/Driver/Oci8/Oci8IntegrationTest.php +++ b/test/Adapter/Driver/Oci8/Oci8IntegrationTest.php @@ -23,13 +23,13 @@ class Oci8IntegrationTest extends AbstractIntegrationTest */ public function testCheckEnvironment() { - $sqlserver = new Oci8(array()); + $sqlserver = new Oci8([]); $this->assertNull($sqlserver->checkEnvironment()); } public function testCreateStatement() { - $driver = new Oci8(array()); + $driver = new Oci8([]); $resource = oci_connect($this->variables['username'], $this->variables['password'], $this->variables['hostname']); $driver->getConnection()->setResource($resource); diff --git a/test/Adapter/Driver/Oci8/Oci8Test.php b/test/Adapter/Driver/Oci8/Oci8Test.php index a74049ff70..7abb4c9174 100644 --- a/test/Adapter/Driver/Oci8/Oci8Test.php +++ b/test/Adapter/Driver/Oci8/Oci8Test.php @@ -24,7 +24,7 @@ class Oci8Test extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->oci8 = new Oci8(array()); + $this->oci8 = new Oci8([]); } /** @@ -32,7 +32,7 @@ protected function setUp() */ public function testRegisterConnection() { - $mockConnection = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Oci8\Connection', array(array()), '', true, true, true, array('setDriver')); + $mockConnection = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Oci8\Connection', [[]], '', true, true, true, ['setDriver']); $mockConnection->expects($this->once())->method('setDriver')->with($this->equalTo($this->oci8)); $this->assertSame($this->oci8, $this->oci8->registerConnection($mockConnection)); } @@ -42,8 +42,8 @@ public function testRegisterConnection() */ public function testRegisterStatementPrototype() { - $this->oci8 = new Oci8(array()); - $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Oci8\Statement', array(), '', true, true, true, array('setDriver')); + $this->oci8 = new Oci8([]); + $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Oci8\Statement', [], '', true, true, true, ['setDriver']); $mockStatement->expects($this->once())->method('setDriver')->with($this->equalTo($this->oci8)); $this->assertSame($this->oci8, $this->oci8->registerStatementPrototype($mockStatement)); } @@ -53,8 +53,8 @@ public function testRegisterStatementPrototype() */ public function testRegisterResultPrototype() { - $this->oci8 = new Oci8(array()); - $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Oci8\Result', array(), '', true, true, true, array('setDriver')); + $this->oci8 = new Oci8([]); + $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Oci8\Result', [], '', true, true, true, ['setDriver']); $this->assertSame($this->oci8, $this->oci8->registerResultPrototype($mockStatement)); } @@ -63,7 +63,7 @@ public function testRegisterResultPrototype() */ public function testGetDatabasePlatformName() { - $this->oci8 = new Oci8(array()); + $this->oci8 = new Oci8([]); $this->assertEquals('Oracle', $this->oci8->getDatabasePlatformName()); $this->assertEquals('Oracle', $this->oci8->getDatabasePlatformName(Oci8::NAME_FORMAT_NATURAL)); } @@ -74,7 +74,7 @@ public function testGetDatabasePlatformName() */ public function testGetConnection($mockConnection) { - $conn = new \Zend\Db\Adapter\Driver\Oci8\Connection(array()); + $conn = new \Zend\Db\Adapter\Driver\Oci8\Connection([]); $this->oci8->registerConnection($conn); $this->assertSame($conn, $this->oci8->getConnection()); } diff --git a/test/Adapter/Driver/Oci8/StatementIntegrationTest.php b/test/Adapter/Driver/Oci8/StatementIntegrationTest.php index 83fcc1cb80..abb371eb3e 100644 --- a/test/Adapter/Driver/Oci8/StatementIntegrationTest.php +++ b/test/Adapter/Driver/Oci8/StatementIntegrationTest.php @@ -18,11 +18,11 @@ */ class StatementIntegrationTest extends \PHPUnit_Framework_TestCase { - protected $variables = array( + protected $variables = [ 'hostname' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_HOSTNAME', 'username' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_USERNAME', 'password' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD', - ); + ]; /** * Sets up the fixture, for example, opens a network connection. diff --git a/test/Adapter/Driver/Oci8/StatementTest.php b/test/Adapter/Driver/Oci8/StatementTest.php index 3ac480bea1..cce26b6c9c 100644 --- a/test/Adapter/Driver/Oci8/StatementTest.php +++ b/test/Adapter/Driver/Oci8/StatementTest.php @@ -42,7 +42,7 @@ protected function tearDown() */ public function testSetDriver() { - $this->assertEquals($this->statement, $this->statement->setDriver(new Oci8(array()))); + $this->assertEquals($this->statement, $this->statement->setDriver(new Oci8([]))); } /** diff --git a/test/Adapter/Driver/Pdo/ConnectionIntegrationTest.php b/test/Adapter/Driver/Pdo/ConnectionIntegrationTest.php index 8836350bc8..3bcace0bc7 100644 --- a/test/Adapter/Driver/Pdo/ConnectionIntegrationTest.php +++ b/test/Adapter/Driver/Pdo/ConnectionIntegrationTest.php @@ -18,7 +18,7 @@ */ class ConnectionIntegrationTest extends \PHPUnit_Framework_TestCase { - protected $variables = array('pdodriver' => 'sqlite', 'database' => ':memory:'); + protected $variables = ['pdodriver' => 'sqlite', 'database' => ':memory:']; /** * @covers Zend\Db\Adapter\Driver\Pdo\Connection::getCurrentSchema @@ -35,7 +35,7 @@ public function testGetCurrentSchema() public function testSetResource() { $resource = new TestAsset\SqliteMemoryPdo(); - $connection = new Connection(array()); + $connection = new Connection([]); $this->assertSame($connection, $connection->setResource($resource)); $connection->disconnect(); @@ -171,7 +171,7 @@ public function testGetLastGeneratedValue() public function testConnectReturnsConnectionWhenResourceSet() { $resource = new TestAsset\SqliteMemoryPdo(); - $connection = new Connection(array()); + $connection = new Connection([]); $connection->setResource($resource); $this->assertSame($connection, $connection->connect()); diff --git a/test/Adapter/Driver/Pdo/ConnectionTest.php b/test/Adapter/Driver/Pdo/ConnectionTest.php index 27b1d9b502..c619459d21 100644 --- a/test/Adapter/Driver/Pdo/ConnectionTest.php +++ b/test/Adapter/Driver/Pdo/ConnectionTest.php @@ -46,7 +46,7 @@ public function testResource() public function testGetDsn() { $dsn = "sqlite::memory:"; - $this->connection->setConnectionParameters(array('dsn' => $dsn)); + $this->connection->setConnectionParameters(['dsn' => $dsn]); try { $this->connection->connect(); } catch (\Exception $e) { @@ -61,13 +61,13 @@ public function testGetDsn() */ public function testArrayOfConnectionParametersCreatesCorrectDsn() { - $this->connection->setConnectionParameters(array( + $this->connection->setConnectionParameters([ 'driver' => 'pdo_mysql', 'host' => '127.0.0.1', 'charset' => 'utf8', 'dbname' => 'foo', 'port' => '3306', - )); + ]); try { $this->connection->connect(); } catch (\Exception $e) { diff --git a/test/Adapter/Driver/Pdo/Feature/OracleRowCounterTest.php b/test/Adapter/Driver/Pdo/Feature/OracleRowCounterTest.php index 6c5910da2e..80f542bc8c 100644 --- a/test/Adapter/Driver/Pdo/Feature/OracleRowCounterTest.php +++ b/test/Adapter/Driver/Pdo/Feature/OracleRowCounterTest.php @@ -70,13 +70,13 @@ public function testGetRowCountClosure() protected function getMockStatement($sql, $returnValue) { /** @var \Zend\Db\Adapter\Driver\Pdo\Statement|\PHPUnit_Framework_MockObject_MockObject $statement */ - $statement = $this->getMock('Zend\Db\Adapter\Driver\Pdo\Statement', array('prepare', 'execute'), array(), '', false); + $statement = $this->getMock('Zend\Db\Adapter\Driver\Pdo\Statement', ['prepare', 'execute'], [], '', false); // mock PDOStatement with stdClass - $resource = $this->getMock('stdClass', array('fetch')); + $resource = $this->getMock('stdClass', ['fetch']); $resource->expects($this->once()) ->method('fetch') - ->will($this->returnValue(array('count' => $returnValue))); + ->will($this->returnValue(['count' => $returnValue])); // mock the result $result = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface'); @@ -94,12 +94,12 @@ protected function getMockStatement($sql, $returnValue) protected function getMockDriver($returnValue) { - $pdoStatement = $this->getMock('stdClass', array('fetch'), array(), '', false); // stdClass can be used here + $pdoStatement = $this->getMock('stdClass', ['fetch'], [], '', false); // stdClass can be used here $pdoStatement->expects($this->once()) ->method('fetch') - ->will($this->returnValue(array('count' => $returnValue))); + ->will($this->returnValue(['count' => $returnValue])); - $pdoConnection = $this->getMock('stdClass', array('query')); + $pdoConnection = $this->getMock('stdClass', ['query']); $pdoConnection->expects($this->once()) ->method('query') ->will($this->returnValue($pdoStatement)); @@ -109,7 +109,7 @@ protected function getMockDriver($returnValue) ->method('getResource') ->will($this->returnValue($pdoConnection)); - $driver = $this->getMock('Zend\Db\Adapter\Driver\Pdo\Pdo', array('getConnection'), array(), '', false); + $driver = $this->getMock('Zend\Db\Adapter\Driver\Pdo\Pdo', ['getConnection'], [], '', false); $driver->expects($this->once()) ->method('getConnection') ->will($this->returnValue($connection)); diff --git a/test/Adapter/Driver/Pdo/Feature/SqliteRowCounterTest.php b/test/Adapter/Driver/Pdo/Feature/SqliteRowCounterTest.php index 1a6a55db04..bd7fca4ebe 100644 --- a/test/Adapter/Driver/Pdo/Feature/SqliteRowCounterTest.php +++ b/test/Adapter/Driver/Pdo/Feature/SqliteRowCounterTest.php @@ -70,13 +70,13 @@ public function testGetRowCountClosure() protected function getMockStatement($sql, $returnValue) { /** @var \Zend\Db\Adapter\Driver\Pdo\Statement|\PHPUnit_Framework_MockObject_MockObject $statement */ - $statement = $this->getMock('Zend\Db\Adapter\Driver\Pdo\Statement', array('prepare', 'execute'), array(), '', false); + $statement = $this->getMock('Zend\Db\Adapter\Driver\Pdo\Statement', ['prepare', 'execute'], [], '', false); // mock PDOStatement with stdClass - $resource = $this->getMock('stdClass', array('fetch')); + $resource = $this->getMock('stdClass', ['fetch']); $resource->expects($this->once()) ->method('fetch') - ->will($this->returnValue(array('count' => $returnValue))); + ->will($this->returnValue(['count' => $returnValue])); // mock the result $result = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface'); @@ -94,12 +94,12 @@ protected function getMockStatement($sql, $returnValue) protected function getMockDriver($returnValue) { - $pdoStatement = $this->getMock('stdClass', array('fetch'), array(), '', false); // stdClass can be used here + $pdoStatement = $this->getMock('stdClass', ['fetch'], [], '', false); // stdClass can be used here $pdoStatement->expects($this->once()) ->method('fetch') - ->will($this->returnValue(array('count' => $returnValue))); + ->will($this->returnValue(['count' => $returnValue])); - $pdoConnection = $this->getMock('stdClass', array('query')); + $pdoConnection = $this->getMock('stdClass', ['query']); $pdoConnection->expects($this->once()) ->method('query') ->will($this->returnValue($pdoStatement)); @@ -109,7 +109,7 @@ protected function getMockDriver($returnValue) ->method('getResource') ->will($this->returnValue($pdoConnection)); - $driver = $this->getMock('Zend\Db\Adapter\Driver\Pdo\Pdo', array('getConnection'), array(), '', false); + $driver = $this->getMock('Zend\Db\Adapter\Driver\Pdo\Pdo', ['getConnection'], [], '', false); $driver->expects($this->once()) ->method('getConnection') ->will($this->returnValue($connection)); diff --git a/test/Adapter/Driver/Pdo/PdoTest.php b/test/Adapter/Driver/Pdo/PdoTest.php index b2f52061c2..ce38698d16 100644 --- a/test/Adapter/Driver/Pdo/PdoTest.php +++ b/test/Adapter/Driver/Pdo/PdoTest.php @@ -25,7 +25,7 @@ class PdoTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->pdo = new Pdo(array()); + $this->pdo = new Pdo([]); } /** @@ -34,7 +34,7 @@ protected function setUp() public function testGetDatabasePlatformName() { // Test platform name for SqlServer - $this->pdo->getConnection()->setConnectionParameters(array('pdodriver' => 'sqlsrv')); + $this->pdo->getConnection()->setConnectionParameters(['pdodriver' => 'sqlsrv']); $this->assertEquals('SqlServer', $this->pdo->getDatabasePlatformName()); $this->assertEquals('SQLServer', $this->pdo->getDatabasePlatformName(DriverInterface::NAME_FORMAT_NATURAL)); } diff --git a/test/Adapter/Driver/Pdo/StatementIntegrationTest.php b/test/Adapter/Driver/Pdo/StatementIntegrationTest.php index 10b9f44790..d862ae7ba0 100644 --- a/test/Adapter/Driver/Pdo/StatementIntegrationTest.php +++ b/test/Adapter/Driver/Pdo/StatementIntegrationTest.php @@ -30,9 +30,9 @@ class StatementIntegrationTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->statement = new Statement; - $this->statement->setDriver($this->getMock('Zend\Db\Adapter\Driver\Pdo\Pdo', array('createResult'), array(), '', false)); + $this->statement->setDriver($this->getMock('Zend\Db\Adapter\Driver\Pdo\Pdo', ['createResult'], [], '', false)); $this->statement->initialize(new TestAsset\CtorlessPdo( - $this->pdoStatementMock = $this->getMock('PDOStatement', array('execute', 'bindParam'))) + $this->pdoStatementMock = $this->getMock('PDOStatement', ['execute', 'bindParam'])) ); } @@ -51,7 +51,7 @@ public function testStatementExecuteWillConvertPhpBoolToPdoBoolWhenBinding() $this->equalTo(false), $this->equalTo(\PDO::PARAM_BOOL) ); - $this->statement->execute(array('foo' => false)); + $this->statement->execute(['foo' => false]); } public function testStatementExecuteWillUsePdoStrByDefaultWhenBinding() @@ -61,6 +61,6 @@ public function testStatementExecuteWillUsePdoStrByDefaultWhenBinding() $this->equalTo('bar'), $this->equalTo(\PDO::PARAM_STR) ); - $this->statement->execute(array('foo' => 'bar')); + $this->statement->execute(['foo' => 'bar']); } } diff --git a/test/Adapter/Driver/Pdo/StatementTest.php b/test/Adapter/Driver/Pdo/StatementTest.php index be7f50f3c1..b34ab66022 100644 --- a/test/Adapter/Driver/Pdo/StatementTest.php +++ b/test/Adapter/Driver/Pdo/StatementTest.php @@ -43,7 +43,7 @@ protected function tearDown() */ public function testSetDriver() { - $this->assertEquals($this->statement, $this->statement->setDriver(new Pdo(array()))); + $this->assertEquals($this->statement, $this->statement->setDriver(new Pdo([]))); } /** diff --git a/test/Adapter/Driver/Pgsql/ConnectionTest.php b/test/Adapter/Driver/Pgsql/ConnectionTest.php index e2463428df..01b55c4ddf 100644 --- a/test/Adapter/Driver/Pgsql/ConnectionTest.php +++ b/test/Adapter/Driver/Pgsql/ConnectionTest.php @@ -66,14 +66,14 @@ public function testDisconnect() */ public function testGetConnectionStringEncodeSpecialSymbol() { - $connectionParameters = array( + $connectionParameters = [ 'driver' => 'pgsql', 'host' => 'localhost', 'post' => '5432', 'dbname' => 'test', 'username' => 'test', 'password' => 'test123!', - ); + ]; $this->connection->setConnectionParameters($connectionParameters); diff --git a/test/Adapter/Driver/Pgsql/PgsqlTest.php b/test/Adapter/Driver/Pgsql/PgsqlTest.php index 17b44e2b7a..7b3ef093d2 100644 --- a/test/Adapter/Driver/Pgsql/PgsqlTest.php +++ b/test/Adapter/Driver/Pgsql/PgsqlTest.php @@ -24,7 +24,7 @@ class PgsqlTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->pgsql = new Pgsql(array()); + $this->pgsql = new Pgsql([]); } /** @@ -44,7 +44,7 @@ public function testCheckEnvironment() */ public function testRegisterConnection() { - $mockConnection = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Pgsql\Connection', array(array()), '', true, true, true, array('setDriver')); + $mockConnection = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Pgsql\Connection', [[]], '', true, true, true, ['setDriver']); $mockConnection->expects($this->once())->method('setDriver')->with($this->equalTo($this->pgsql)); $this->assertSame($this->pgsql, $this->pgsql->registerConnection($mockConnection)); } @@ -54,8 +54,8 @@ public function testRegisterConnection() */ public function testRegisterStatementPrototype() { - $this->pgsql = new Pgsql(array()); - $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Pgsql\Statement', array(), '', true, true, true, array('setDriver')); + $this->pgsql = new Pgsql([]); + $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Pgsql\Statement', [], '', true, true, true, ['setDriver']); $mockStatement->expects($this->once())->method('setDriver')->with($this->equalTo($this->pgsql)); $this->assertSame($this->pgsql, $this->pgsql->registerStatementPrototype($mockStatement)); } @@ -65,8 +65,8 @@ public function testRegisterStatementPrototype() */ public function testRegisterResultPrototype() { - $this->pgsql = new Pgsql(array()); - $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Pgsql\Result', array(), '', true, true, true, array('setDriver')); + $this->pgsql = new Pgsql([]); + $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Pgsql\Result', [], '', true, true, true, ['setDriver']); $this->assertSame($this->pgsql, $this->pgsql->registerResultPrototype($mockStatement)); } @@ -75,7 +75,7 @@ public function testRegisterResultPrototype() */ public function testGetDatabasePlatformName() { - $this->pgsql = new Pgsql(array()); + $this->pgsql = new Pgsql([]); $this->assertEquals('Postgresql', $this->pgsql->getDatabasePlatformName()); $this->assertEquals('PostgreSQL', $this->pgsql->getDatabasePlatformName(Pgsql::NAME_FORMAT_NATURAL)); } @@ -86,7 +86,7 @@ public function testGetDatabasePlatformName() */ public function testGetConnection($mockConnection) { - $conn = new \Zend\Db\Adapter\Driver\Pgsql\Connection(array()); + $conn = new \Zend\Db\Adapter\Driver\Pgsql\Connection([]); $this->pgsql->registerConnection($conn); $this->assertSame($conn, $this->pgsql->getConnection()); } diff --git a/test/Adapter/Driver/Sqlsrv/AbstractIntegrationTest.php b/test/Adapter/Driver/Sqlsrv/AbstractIntegrationTest.php index eeca90076a..adc2b57459 100644 --- a/test/Adapter/Driver/Sqlsrv/AbstractIntegrationTest.php +++ b/test/Adapter/Driver/Sqlsrv/AbstractIntegrationTest.php @@ -11,11 +11,11 @@ abstract class AbstractIntegrationTest extends \PHPUnit_Framework_TestCase { - protected $variables = array( + protected $variables = [ 'hostname' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_SQLSRV_HOSTNAME', 'username' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_SQLSRV_USERNAME', 'password' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_SQLSRV_PASSWORD', - ); + ]; /** * Sets up the fixture, for example, opens a network connection. diff --git a/test/Adapter/Driver/Sqlsrv/ConnectionIntegrationTest.php b/test/Adapter/Driver/Sqlsrv/ConnectionIntegrationTest.php index 6aee2196f4..7a49cd5eb5 100644 --- a/test/Adapter/Driver/Sqlsrv/ConnectionIntegrationTest.php +++ b/test/Adapter/Driver/Sqlsrv/ConnectionIntegrationTest.php @@ -33,12 +33,12 @@ public function testGetCurrentSchema() public function testSetResource() { $resource = sqlsrv_connect( - $this->variables['hostname'], array( + $this->variables['hostname'], [ 'UID' => $this->variables['username'], 'PWD' => $this->variables['password'] - ) + ] ); - $connection = new Connection(array()); + $connection = new Connection([]); $this->assertSame($connection, $connection->setResource($resource)); $connection->disconnect(); @@ -174,12 +174,12 @@ public function testGetLastGeneratedValue() public function testConnectReturnsConnectionWhenResourceSet() { $resource = sqlsrv_connect( - $this->variables['hostname'], array( + $this->variables['hostname'], [ 'UID' => $this->variables['username'], 'PWD' => $this->variables['password'] - ) + ] ); - $connection = new Connection(array()); + $connection = new Connection([]); $connection->setResource($resource); $this->assertSame($connection, $connection->connect()); diff --git a/test/Adapter/Driver/Sqlsrv/ConnectionTest.php b/test/Adapter/Driver/Sqlsrv/ConnectionTest.php index 5afc6d5c25..e387abf463 100644 --- a/test/Adapter/Driver/Sqlsrv/ConnectionTest.php +++ b/test/Adapter/Driver/Sqlsrv/ConnectionTest.php @@ -25,7 +25,7 @@ class ConnectionTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->connection = new Connection(array()); + $this->connection = new Connection([]); } /** @@ -41,7 +41,7 @@ protected function tearDown() */ public function testSetDriver() { - $this->assertEquals($this->connection, $this->connection->setDriver(new Sqlsrv(array()))); + $this->assertEquals($this->connection, $this->connection->setDriver(new Sqlsrv([]))); } /** @@ -49,7 +49,7 @@ public function testSetDriver() */ public function testSetConnectionParameters() { - $this->assertEquals($this->connection, $this->connection->setConnectionParameters(array())); + $this->assertEquals($this->connection, $this->connection->setConnectionParameters([])); } /** @@ -57,7 +57,7 @@ public function testSetConnectionParameters() */ public function testGetConnectionParameters() { - $this->connection->setConnectionParameters(array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $this->connection->getConnectionParameters()); + $this->connection->setConnectionParameters(['foo' => 'bar']); + $this->assertEquals(['foo' => 'bar'], $this->connection->getConnectionParameters()); } } diff --git a/test/Adapter/Driver/Sqlsrv/SqlSrvIntegrationTest.php b/test/Adapter/Driver/Sqlsrv/SqlSrvIntegrationTest.php index 04a40384d2..190ebf5b9b 100644 --- a/test/Adapter/Driver/Sqlsrv/SqlSrvIntegrationTest.php +++ b/test/Adapter/Driver/Sqlsrv/SqlSrvIntegrationTest.php @@ -23,19 +23,19 @@ class SqlSrvIntegrationTest extends AbstractIntegrationTest */ public function testCheckEnvironment() { - $sqlserver = new Sqlsrv(array()); + $sqlserver = new Sqlsrv([]); $this->assertNull($sqlserver->checkEnvironment()); } public function testCreateStatement() { - $driver = new Sqlsrv(array()); + $driver = new Sqlsrv([]); $resource = sqlsrv_connect( - $this->variables['hostname'], array( + $this->variables['hostname'], [ 'UID' => $this->variables['username'], 'PWD' => $this->variables['password'] - ) + ] ); $driver->getConnection()->setResource($resource); diff --git a/test/Adapter/Driver/Sqlsrv/SqlsrvTest.php b/test/Adapter/Driver/Sqlsrv/SqlsrvTest.php index 797dd6796d..e6fe56f38e 100644 --- a/test/Adapter/Driver/Sqlsrv/SqlsrvTest.php +++ b/test/Adapter/Driver/Sqlsrv/SqlsrvTest.php @@ -24,7 +24,7 @@ class SqlsrvTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->sqlsrv = new Sqlsrv(array()); + $this->sqlsrv = new Sqlsrv([]); } /** @@ -32,7 +32,7 @@ protected function setUp() */ public function testRegisterConnection() { - $mockConnection = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Sqlsrv\Connection', array(array()), '', true, true, true, array('setDriver')); + $mockConnection = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Sqlsrv\Connection', [[]], '', true, true, true, ['setDriver']); $mockConnection->expects($this->once())->method('setDriver')->with($this->equalTo($this->sqlsrv)); $this->assertSame($this->sqlsrv, $this->sqlsrv->registerConnection($mockConnection)); } @@ -42,8 +42,8 @@ public function testRegisterConnection() */ public function testRegisterStatementPrototype() { - $this->sqlsrv = new Sqlsrv(array()); - $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Sqlsrv\Statement', array(), '', true, true, true, array('setDriver')); + $this->sqlsrv = new Sqlsrv([]); + $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Sqlsrv\Statement', [], '', true, true, true, ['setDriver']); $mockStatement->expects($this->once())->method('setDriver')->with($this->equalTo($this->sqlsrv)); $this->assertSame($this->sqlsrv, $this->sqlsrv->registerStatementPrototype($mockStatement)); } @@ -53,8 +53,8 @@ public function testRegisterStatementPrototype() */ public function testRegisterResultPrototype() { - $this->sqlsrv = new Sqlsrv(array()); - $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Sqlsrv\Result', array(), '', true, true, true, array('setDriver')); + $this->sqlsrv = new Sqlsrv([]); + $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Sqlsrv\Result', [], '', true, true, true, ['setDriver']); $this->assertSame($this->sqlsrv, $this->sqlsrv->registerResultPrototype($mockStatement)); } @@ -63,7 +63,7 @@ public function testRegisterResultPrototype() */ public function testGetDatabasePlatformName() { - $this->sqlsrv = new Sqlsrv(array()); + $this->sqlsrv = new Sqlsrv([]); $this->assertEquals('SqlServer', $this->sqlsrv->getDatabasePlatformName()); $this->assertEquals('SQLServer', $this->sqlsrv->getDatabasePlatformName(Sqlsrv::NAME_FORMAT_NATURAL)); } @@ -74,7 +74,7 @@ public function testGetDatabasePlatformName() */ public function testGetConnection($mockConnection) { - $conn = new \Zend\Db\Adapter\Driver\Sqlsrv\Connection(array()); + $conn = new \Zend\Db\Adapter\Driver\Sqlsrv\Connection([]); $this->sqlsrv->registerConnection($conn); $this->assertSame($conn, $this->sqlsrv->getConnection()); } diff --git a/test/Adapter/Driver/Sqlsrv/StatementIntegrationTest.php b/test/Adapter/Driver/Sqlsrv/StatementIntegrationTest.php index 9588ee4169..968e2ad326 100644 --- a/test/Adapter/Driver/Sqlsrv/StatementIntegrationTest.php +++ b/test/Adapter/Driver/Sqlsrv/StatementIntegrationTest.php @@ -18,11 +18,11 @@ */ class StatementIntegrationTest extends \PHPUnit_Framework_TestCase { - protected $variables = array( + protected $variables = [ 'hostname' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_SQLSRV_HOSTNAME', 'username' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_SQLSRV_USERNAME', 'password' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_SQLSRV_PASSWORD', - ); + ]; /** * Sets up the fixture, for example, opens a network connection. @@ -47,7 +47,7 @@ protected function setUp() */ public function testInitialize() { - $sqlsrvResource = sqlsrv_connect($this->variables['hostname'], array('UID' => $this->variables['username'], 'PWD' => $this->variables['password'])); + $sqlsrvResource = sqlsrv_connect($this->variables['hostname'], ['UID' => $this->variables['username'], 'PWD' => $this->variables['password']]); $statement = new Statement; $this->assertSame($statement, $statement->initialize($sqlsrvResource)); @@ -59,7 +59,7 @@ public function testInitialize() */ public function testGetResource() { - $sqlsrvResource = sqlsrv_connect($this->variables['hostname'], array('UID' => $this->variables['username'], 'PWD' => $this->variables['password'])); + $sqlsrvResource = sqlsrv_connect($this->variables['hostname'], ['UID' => $this->variables['username'], 'PWD' => $this->variables['password']]); $statement = new Statement; $statement->initialize($sqlsrvResource); @@ -75,7 +75,7 @@ public function testGetResource() */ public function testPrepare() { - $sqlsrvResource = sqlsrv_connect($this->variables['hostname'], array('UID' => $this->variables['username'], 'PWD' => $this->variables['password'])); + $sqlsrvResource = sqlsrv_connect($this->variables['hostname'], ['UID' => $this->variables['username'], 'PWD' => $this->variables['password']]); $statement = new Statement; $statement->initialize($sqlsrvResource); diff --git a/test/Adapter/Driver/Sqlsrv/StatementTest.php b/test/Adapter/Driver/Sqlsrv/StatementTest.php index 8f21bd9514..1a898e42c7 100644 --- a/test/Adapter/Driver/Sqlsrv/StatementTest.php +++ b/test/Adapter/Driver/Sqlsrv/StatementTest.php @@ -42,7 +42,7 @@ protected function tearDown() */ public function testSetDriver() { - $this->assertEquals($this->statement, $this->statement->setDriver(new Sqlsrv(array()))); + $this->assertEquals($this->statement, $this->statement->setDriver(new Sqlsrv([]))); } /** diff --git a/test/Adapter/ParameterContainerTest.php b/test/Adapter/ParameterContainerTest.php index 0dde42c3dc..a4bbaeefce 100644 --- a/test/Adapter/ParameterContainerTest.php +++ b/test/Adapter/ParameterContainerTest.php @@ -27,7 +27,7 @@ class ParameterContainerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->parameterContainer = new ParameterContainer(array('foo' => 'bar')); + $this->parameterContainer = new ParameterContainer(['foo' => 'bar']); } /** @@ -66,7 +66,7 @@ public function testOffsetSet() $this->parameterContainer->offsetSet('1', 'book', ParameterContainer::TYPE_STRING, 4); $this->assertEquals( - array('foo' => 'bar', 'boo' => 'baz', '1' => 'book'), + ['foo' => 'bar', 'boo' => 'baz', '1' => 'book'], $this->parameterContainer->getNamedArray() ); @@ -77,11 +77,11 @@ public function testOffsetSet() $this->parameterContainer[0] = 'Zero'; $this->parameterContainer[1] = 'One'; $this->assertEquals( - array('foo' => 'Zero', 'boo' => 'One', '1' => 'book'), + ['foo' => 'Zero', 'boo' => 'One', '1' => 'book'], $this->parameterContainer->getNamedArray() ); $this->assertEquals( - array(0 => 'Zero', 1 => 'One', 2 => 'book'), + [0 => 'Zero', 1 => 'One', 2 => 'book'], $this->parameterContainer->getPositionalArray() ); @@ -90,11 +90,11 @@ public function testOffsetSet() $this->parameterContainer[] = 'Second To Last'; $this->parameterContainer[] = 'Last'; $this->assertEquals( - array('foo' => 'Zero', 'boo' => 'One', '1' => 'book', 'buffer' => 'A buffer Element', '4' => 'Second To Last', '5' => 'Last'), + ['foo' => 'Zero', 'boo' => 'One', '1' => 'book', 'buffer' => 'A buffer Element', '4' => 'Second To Last', '5' => 'Last'], $this->parameterContainer->getNamedArray() ); $this->assertEquals( - array(0 => 'Zero', 1 => 'One', 2 => 'book', 3 => 'A buffer Element', 4 => 'Second To Last', 5 => 'Last'), + [0 => 'Zero', 1 => 'One', 2 => 'book', 3 => 'A buffer Element', 4 => 'Second To Last', 5 => 'Last'], $this->parameterContainer->getPositionalArray() ); } @@ -119,7 +119,7 @@ public function testOffsetUnset() */ public function testSetFromArray() { - $this->parameterContainer->setFromArray(array('bar' => 'baz')); + $this->parameterContainer->setFromArray(['bar' => 'baz']); $this->assertEquals('baz', $this->parameterContainer['bar']); } @@ -226,7 +226,7 @@ public function testGetErrataIterator() public function testGetNamedArray() { $data = $this->parameterContainer->getNamedArray(); - $this->assertEquals(array('foo' => 'bar'), $data); + $this->assertEquals(['foo' => 'bar'], $data); } /** diff --git a/test/Adapter/Platform/IbmDb2Test.php b/test/Adapter/Platform/IbmDb2Test.php index f9687ad6b5..9836edba0f 100644 --- a/test/Adapter/Platform/IbmDb2Test.php +++ b/test/Adapter/Platform/IbmDb2Test.php @@ -50,7 +50,7 @@ public function testQuoteIdentifier() { $this->assertEquals('"identifier"', $this->platform->quoteIdentifier('identifier')); - $platform = new IbmDb2(array('quote_identifiers' => false)); + $platform = new IbmDb2(['quote_identifiers' => false]); $this->assertEquals('identifier', $platform->quoteIdentifier('identifier')); } @@ -60,16 +60,16 @@ public function testQuoteIdentifier() public function testQuoteIdentifierChain() { $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain('identifier')); - $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain(array('identifier'))); - $this->assertEquals('"schema"."identifier"', $this->platform->quoteIdentifierChain(array('schema', 'identifier'))); + $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain(['identifier'])); + $this->assertEquals('"schema"."identifier"', $this->platform->quoteIdentifierChain(['schema', 'identifier'])); - $platform = new IbmDb2(array('quote_identifiers' => false)); + $platform = new IbmDb2(['quote_identifiers' => false]); $this->assertEquals('identifier', $platform->quoteIdentifierChain('identifier')); - $this->assertEquals('identifier', $platform->quoteIdentifierChain(array('identifier'))); - $this->assertEquals('schema.identifier', $platform->quoteIdentifierChain(array('schema', 'identifier'))); + $this->assertEquals('identifier', $platform->quoteIdentifierChain(['identifier'])); + $this->assertEquals('schema.identifier', $platform->quoteIdentifierChain(['schema', 'identifier'])); - $platform = new IbmDb2(array('identifier_separator' => '\\')); - $this->assertEquals('"schema"\"identifier"', $platform->quoteIdentifierChain(array('schema', 'identifier'))); + $platform = new IbmDb2(['identifier_separator' => '\\']); + $this->assertEquals('"schema"\"identifier"', $platform->quoteIdentifierChain(['schema', 'identifier'])); } /** @@ -137,7 +137,7 @@ public function testGetIdentifierSeparator() { $this->assertEquals('.', $this->platform->getIdentifierSeparator()); - $platform = new IbmDb2(array('identifier_separator' => '\\')); + $platform = new IbmDb2(['identifier_separator' => '\\']); $this->assertEquals('\\', $platform->getIdentifierSeparator()); } @@ -149,23 +149,23 @@ public function testQuoteIdentifierInFragment() $this->assertEquals('"foo"."bar"', $this->platform->quoteIdentifierInFragment('foo.bar')); $this->assertEquals('"foo" as "bar"', $this->platform->quoteIdentifierInFragment('foo as bar')); - $platform = new IbmDb2(array('quote_identifiers' => false)); + $platform = new IbmDb2(['quote_identifiers' => false]); $this->assertEquals('foo.bar', $platform->quoteIdentifierInFragment('foo.bar')); $this->assertEquals('foo as bar', $platform->quoteIdentifierInFragment('foo as bar')); // single char words - $this->assertEquals('("foo"."bar" = "boo"."baz")', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', array('(', ')', '='))); + $this->assertEquals('("foo"."bar" = "boo"."baz")', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', ['(', ')', '='])); // case insensitive safe words $this->assertEquals( '("foo"."bar" = "boo"."baz") AND ("foo"."baz" = "boo"."baz")', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and']) ); // case insensitive safe words in field $this->assertEquals( '("foo"."bar" = "boo".baz) AND ("foo".baz = "boo".baz)', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and', 'bAz')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and', 'bAz']) ); } } diff --git a/test/Adapter/Platform/MysqlIntegrationTest.php b/test/Adapter/Platform/MysqlIntegrationTest.php index 312b3ac541..d847f836f0 100644 --- a/test/Adapter/Platform/MysqlIntegrationTest.php +++ b/test/Adapter/Platform/MysqlIntegrationTest.php @@ -19,7 +19,7 @@ */ class MysqlIntegrationTest extends \PHPUnit_Framework_TestCase { - public $adapters = array(); + public $adapters = []; public function testQuoteValueWithMysqli() { diff --git a/test/Adapter/Platform/MysqlTest.php b/test/Adapter/Platform/MysqlTest.php index 4ba15060cd..a8b8bbe4e9 100644 --- a/test/Adapter/Platform/MysqlTest.php +++ b/test/Adapter/Platform/MysqlTest.php @@ -59,12 +59,12 @@ public function testQuoteIdentifier() public function testQuoteIdentifierChain() { $this->assertEquals('`identifier`', $this->platform->quoteIdentifierChain('identifier')); - $this->assertEquals('`identifier`', $this->platform->quoteIdentifierChain(array('identifier'))); - $this->assertEquals('`schema`.`identifier`', $this->platform->quoteIdentifierChain(array('schema', 'identifier'))); + $this->assertEquals('`identifier`', $this->platform->quoteIdentifierChain(['identifier'])); + $this->assertEquals('`schema`.`identifier`', $this->platform->quoteIdentifierChain(['schema', 'identifier'])); $this->assertEquals('`ident``ifier`', $this->platform->quoteIdentifierChain('ident`ifier')); - $this->assertEquals('`ident``ifier`', $this->platform->quoteIdentifierChain(array('ident`ifier'))); - $this->assertEquals('`schema`.`ident``ifier`', $this->platform->quoteIdentifierChain(array('schema', 'ident`ifier'))); + $this->assertEquals('`ident``ifier`', $this->platform->quoteIdentifierChain(['ident`ifier'])); + $this->assertEquals('`schema`.`ident``ifier`', $this->platform->quoteIdentifierChain(['schema', 'ident`ifier'])); } /** @@ -142,20 +142,20 @@ public function testQuoteIdentifierInFragment() $this->assertEquals('`cmis:$TableName` as `cmis:TableAlias`', $this->platform->quoteIdentifierInFragment('cmis:$TableName as cmis:TableAlias')); // single char words - $this->assertEquals('(`foo`.`bar` = `boo`.`baz`)', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', array('(', ')', '='))); - $this->assertEquals('(`foo`.`bar`=`boo`.`baz`)', $this->platform->quoteIdentifierInFragment('(foo.bar=boo.baz)', array('(', ')', '='))); - $this->assertEquals('`foo`=`bar`', $this->platform->quoteIdentifierInFragment('foo=bar', array('='))); + $this->assertEquals('(`foo`.`bar` = `boo`.`baz`)', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', ['(', ')', '='])); + $this->assertEquals('(`foo`.`bar`=`boo`.`baz`)', $this->platform->quoteIdentifierInFragment('(foo.bar=boo.baz)', ['(', ')', '='])); + $this->assertEquals('`foo`=`bar`', $this->platform->quoteIdentifierInFragment('foo=bar', ['='])); // case insensitive safe words $this->assertEquals( '(`foo`.`bar` = `boo`.`baz`) AND (`foo`.`baz` = `boo`.`baz`)', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and']) ); // case insensitive safe words in field $this->assertEquals( '(`foo`.`bar` = `boo`.baz) AND (`foo`.baz = `boo`.baz)', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and', 'bAz')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and', 'bAz']) ); } } diff --git a/test/Adapter/Platform/OracleTest.php b/test/Adapter/Platform/OracleTest.php index b88f74a417..c03e86a682 100644 --- a/test/Adapter/Platform/OracleTest.php +++ b/test/Adapter/Platform/OracleTest.php @@ -50,7 +50,7 @@ public function testQuoteIdentifier() { $this->assertEquals('"identifier"', $this->platform->quoteIdentifier('identifier')); - $platform = new Oracle(array('quote_identifiers' => false)); + $platform = new Oracle(['quote_identifiers' => false]); $this->assertEquals('identifier', $platform->quoteIdentifier('identifier')); } @@ -60,13 +60,13 @@ public function testQuoteIdentifier() public function testQuoteIdentifierChain() { $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain('identifier')); - $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain(array('identifier'))); - $this->assertEquals('"schema"."identifier"', $this->platform->quoteIdentifierChain(array('schema', 'identifier'))); + $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain(['identifier'])); + $this->assertEquals('"schema"."identifier"', $this->platform->quoteIdentifierChain(['schema', 'identifier'])); - $platform = new Oracle(array('quote_identifiers' => false)); + $platform = new Oracle(['quote_identifiers' => false]); $this->assertEquals('identifier', $platform->quoteIdentifierChain('identifier')); - $this->assertEquals('identifier', $platform->quoteIdentifierChain(array('identifier'))); - $this->assertEquals('schema.identifier', $platform->quoteIdentifierChain(array('schema', 'identifier'))); + $this->assertEquals('identifier', $platform->quoteIdentifierChain(['identifier'])); + $this->assertEquals('schema.identifier', $platform->quoteIdentifierChain(['schema', 'identifier'])); } /** @@ -141,23 +141,23 @@ public function testQuoteIdentifierInFragment() $this->assertEquals('"foo"."bar"', $this->platform->quoteIdentifierInFragment('foo.bar')); $this->assertEquals('"foo" as "bar"', $this->platform->quoteIdentifierInFragment('foo as bar')); - $platform = new Oracle(array('quote_identifiers' => false)); + $platform = new Oracle(['quote_identifiers' => false]); $this->assertEquals('foo.bar', $platform->quoteIdentifierInFragment('foo.bar')); $this->assertEquals('foo as bar', $platform->quoteIdentifierInFragment('foo as bar')); // single char words - $this->assertEquals('("foo"."bar" = "boo"."baz")', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', array('(', ')', '='))); + $this->assertEquals('("foo"."bar" = "boo"."baz")', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', ['(', ')', '='])); // case insensitive safe words $this->assertEquals( '("foo"."bar" = "boo"."baz") AND ("foo"."baz" = "boo"."baz")', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and']) ); // case insensitive safe words in field $this->assertEquals( '("foo"."bar" = "boo".baz) AND ("foo".baz = "boo".baz)', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and', 'bAz')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and', 'bAz']) ); } } diff --git a/test/Adapter/Platform/PostgresqlIntegrationTest.php b/test/Adapter/Platform/PostgresqlIntegrationTest.php index 25e807e311..ba44cb9f3f 100644 --- a/test/Adapter/Platform/PostgresqlIntegrationTest.php +++ b/test/Adapter/Platform/PostgresqlIntegrationTest.php @@ -19,7 +19,7 @@ */ class PostgresqlIntegrationTest extends \PHPUnit_Framework_TestCase { - public $adapters = array(); + public $adapters = []; public function testQuoteValueWithPgsql() { diff --git a/test/Adapter/Platform/PostgresqlTest.php b/test/Adapter/Platform/PostgresqlTest.php index 3017d929c3..fc1ef052de 100644 --- a/test/Adapter/Platform/PostgresqlTest.php +++ b/test/Adapter/Platform/PostgresqlTest.php @@ -58,9 +58,9 @@ public function testQuoteIdentifier() public function testQuoteIdentifierChain() { $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain('identifier')); - $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain(array('identifier'))); - $this->assertEquals('"schema"."identifier"', $this->platform->quoteIdentifierChain(array('schema', 'identifier'))); - $this->assertEquals('"schema"."identifier ""with"" double-quotes"', $this->platform->quoteIdentifierChain(array('schema', 'identifier "with" double-quotes'))); + $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain(['identifier'])); + $this->assertEquals('"schema"."identifier"', $this->platform->quoteIdentifierChain(['schema', 'identifier'])); + $this->assertEquals('"schema"."identifier ""with"" double-quotes"', $this->platform->quoteIdentifierChain(['schema', 'identifier "with" double-quotes'])); } /** @@ -136,18 +136,18 @@ public function testQuoteIdentifierInFragment() $this->assertEquals('"foo" as "bar"', $this->platform->quoteIdentifierInFragment('foo as bar')); // single char words - $this->assertEquals('("foo"."bar" = "boo"."baz")', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', array('(', ')', '='))); + $this->assertEquals('("foo"."bar" = "boo"."baz")', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', ['(', ')', '='])); // case insensitive safe words $this->assertEquals( '("foo"."bar" = "boo"."baz") AND ("foo"."baz" = "boo"."baz")', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and']) ); // case insensitive safe words in field $this->assertEquals( '("foo"."bar" = "boo".baz) AND ("foo".baz = "boo".baz)', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and', 'bAz')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and', 'bAz']) ); } } diff --git a/test/Adapter/Platform/Sql92Test.php b/test/Adapter/Platform/Sql92Test.php index 44abd75a17..00cbab1cfc 100644 --- a/test/Adapter/Platform/Sql92Test.php +++ b/test/Adapter/Platform/Sql92Test.php @@ -57,8 +57,8 @@ public function testQuoteIdentifier() public function testQuoteIdentifierChain() { $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain('identifier')); - $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain(array('identifier'))); - $this->assertEquals('"schema"."identifier"', $this->platform->quoteIdentifierChain(array('schema', 'identifier'))); + $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain(['identifier'])); + $this->assertEquals('"schema"."identifier"', $this->platform->quoteIdentifierChain(['schema', 'identifier'])); } /** @@ -134,18 +134,18 @@ public function testQuoteIdentifierInFragment() $this->assertEquals('"foo" as "bar"', $this->platform->quoteIdentifierInFragment('foo as bar')); // single char words - $this->assertEquals('("foo"."bar" = "boo"."baz")', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', array('(', ')', '='))); + $this->assertEquals('("foo"."bar" = "boo"."baz")', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', ['(', ')', '='])); // case insensitive safe words $this->assertEquals( '("foo"."bar" = "boo"."baz") AND ("foo"."baz" = "boo"."baz")', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and']) ); // case insensitive safe words in field $this->assertEquals( '("foo"."bar" = "boo".baz) AND ("foo".baz = "boo".baz)', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and', 'bAz')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and', 'bAz']) ); } } diff --git a/test/Adapter/Platform/SqlServerIntegrationTest.php b/test/Adapter/Platform/SqlServerIntegrationTest.php index 8390fc62fc..2a3688a1c3 100644 --- a/test/Adapter/Platform/SqlServerIntegrationTest.php +++ b/test/Adapter/Platform/SqlServerIntegrationTest.php @@ -17,7 +17,7 @@ */ class SqlServerIntegrationTest extends \PHPUnit_Framework_TestCase { - public $adapters = array(); + public $adapters = []; public function testQuoteValueWithSqlServer() { diff --git a/test/Adapter/Platform/SqlServerTest.php b/test/Adapter/Platform/SqlServerTest.php index 6d867942e8..23b211daf0 100644 --- a/test/Adapter/Platform/SqlServerTest.php +++ b/test/Adapter/Platform/SqlServerTest.php @@ -41,7 +41,7 @@ public function testGetName() */ public function testGetQuoteIdentifierSymbol() { - $this->assertEquals(array('[', ']'), $this->platform->getQuoteIdentifierSymbol()); + $this->assertEquals(['[', ']'], $this->platform->getQuoteIdentifierSymbol()); } /** @@ -58,8 +58,8 @@ public function testQuoteIdentifier() public function testQuoteIdentifierChain() { $this->assertEquals('[identifier]', $this->platform->quoteIdentifierChain('identifier')); - $this->assertEquals('[identifier]', $this->platform->quoteIdentifierChain(array('identifier'))); - $this->assertEquals('[schema].[identifier]', $this->platform->quoteIdentifierChain(array('schema', 'identifier'))); + $this->assertEquals('[identifier]', $this->platform->quoteIdentifierChain(['identifier'])); + $this->assertEquals('[schema].[identifier]', $this->platform->quoteIdentifierChain(['schema', 'identifier'])); } /** @@ -133,18 +133,18 @@ public function testQuoteIdentifierInFragment() $this->assertEquals('[foo] as [bar]', $this->platform->quoteIdentifierInFragment('foo as bar')); // single char words - $this->assertEquals('([foo].[bar] = [boo].[baz])', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', array('(', ')', '='))); + $this->assertEquals('([foo].[bar] = [boo].[baz])', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', ['(', ')', '='])); // case insensitive safe words $this->assertEquals( '([foo].[bar] = [boo].[baz]) AND ([foo].[baz] = [boo].[baz])', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and']) ); // case insensitive safe words in field $this->assertEquals( '([foo].[bar] = [boo].baz) AND ([foo].baz = [boo].baz)', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and', 'bAz')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and', 'bAz']) ); } @@ -153,7 +153,7 @@ public function testQuoteIdentifierInFragment() */ public function testSetDriver() { - $driver = new Pdo(array('pdodriver' => 'sqlsrv')); + $driver = new Pdo(['pdodriver' => 'sqlsrv']); $this->platform->setDriver($driver); } diff --git a/test/Adapter/Platform/SqliteIntegrationTest.php b/test/Adapter/Platform/SqliteIntegrationTest.php index bf7ce49358..78a35a23ea 100644 --- a/test/Adapter/Platform/SqliteIntegrationTest.php +++ b/test/Adapter/Platform/SqliteIntegrationTest.php @@ -18,7 +18,7 @@ */ class SqliteIntegrationTest extends \PHPUnit_Framework_TestCase { - public $adapters = array(); + public $adapters = []; public function testQuoteValueWithPdoSqlite() { diff --git a/test/Adapter/Platform/SqliteTest.php b/test/Adapter/Platform/SqliteTest.php index f4b4738ae8..f03026e79f 100644 --- a/test/Adapter/Platform/SqliteTest.php +++ b/test/Adapter/Platform/SqliteTest.php @@ -57,8 +57,8 @@ public function testQuoteIdentifier() public function testQuoteIdentifierChain() { $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain('identifier')); - $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain(array('identifier'))); - $this->assertEquals('"schema"."identifier"', $this->platform->quoteIdentifierChain(array('schema', 'identifier'))); + $this->assertEquals('"identifier"', $this->platform->quoteIdentifierChain(['identifier'])); + $this->assertEquals('"schema"."identifier"', $this->platform->quoteIdentifierChain(['schema', 'identifier'])); } /** @@ -134,18 +134,18 @@ public function testQuoteIdentifierInFragment() $this->assertEquals('"foo" as "bar"', $this->platform->quoteIdentifierInFragment('foo as bar')); // single char words - $this->assertEquals('("foo"."bar" = "boo"."baz")', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', array('(', ')', '='))); + $this->assertEquals('("foo"."bar" = "boo"."baz")', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', ['(', ')', '='])); // case insensitive safe words $this->assertEquals( '("foo"."bar" = "boo"."baz") AND ("foo"."baz" = "boo"."baz")', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and']) ); // case insensitive safe words in field $this->assertEquals( '("foo"."bar" = "boo".baz) AND ("foo".baz = "boo".baz)', - $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', array('(', ')', '=', 'and', 'bAz')) + $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz) AND (foo.baz = boo.baz)', ['(', ')', '=', 'and', 'bAz']) ); } @@ -161,10 +161,10 @@ public function testCanCloseConnectionAfterQuoteValue() touch($filePath); } - $driver = new \Zend\Db\Adapter\Driver\Pdo\Pdo(array( + $driver = new \Zend\Db\Adapter\Driver\Pdo\Pdo([ 'driver' => 'Pdo_Sqlite', 'database' => $filePath - )); + ]); $this->platform->setDriver($driver); diff --git a/test/IntegrationTestListener.php b/test/IntegrationTestListener.php index b47ec0cb15..3a4b9b1ef5 100644 --- a/test/IntegrationTestListener.php +++ b/test/IntegrationTestListener.php @@ -17,7 +17,7 @@ class IntegrationTestListener implements PHPUnit_Framework_TestListener { - protected $adapters = array( + protected $adapters = [ 'mysqli' => null, 'pdo_mysql' => null, 'pgsql' => null, @@ -25,7 +25,7 @@ class IntegrationTestListener implements PHPUnit_Framework_TestListener 'pdo_sqlite' => null, 'sqlsrv' => null, 'pdo_sqlsrv' => null, - ); + ]; public function __construct() { @@ -74,12 +74,12 @@ public function __construct() if (extension_loaded('sqlsrv')) { $this->adapters['sqlsrv'] = sqlsrv_connect( getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_SQLSRV_HOSTNAME'), - array( + [ 'UID' => getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_SQLSRV_USERNAME'), 'PWD' => getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_SQLSRV_PASSWORD'), 'Database' => (getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_SQLSRV_DATABASE') ? : null) - ) + ] ); if (!$this->adapters['sqlsrv']) { var_dump(sqlsrv_errors()); @@ -155,7 +155,7 @@ public function endTest(PHPUnit_Framework_Test $test, $time) if ($refObj->hasProperty('adapters')) { $refProp = $refObj->getProperty('adapters'); $refProp->setAccessible(true); - $refProp->setValue($test, array()); + $refProp->setValue($test, []); } } } diff --git a/test/Metadata/Source/AbstractSourceTest.php b/test/Metadata/Source/AbstractSourceTest.php index e174660b6a..5846caa20e 100644 --- a/test/Metadata/Source/AbstractSourceTest.php +++ b/test/Metadata/Source/AbstractSourceTest.php @@ -20,7 +20,7 @@ class AbstractSourceTest extends \PHPUnit_Framework_TestCase public function setup() { - $this->abstractSourceMock = $this->getMockForAbstractClass('Zend\Db\Metadata\Source\AbstractSource', array(), '', false); + $this->abstractSourceMock = $this->getMockForAbstractClass('Zend\Db\Metadata\Source\AbstractSource', [], '', false); } public function testGetConstraintKeys() @@ -29,29 +29,29 @@ public function testGetConstraintKeys() $refProp->setAccessible(true); // internal data - $data = array( - 'constraint_references' => array( - 'foo_schema' => array( - array( + $data = [ + 'constraint_references' => [ + 'foo_schema' => [ + [ 'constraint_name' => 'bam_constraint', 'update_rule' => 'UP', 'delete_rule' => 'DOWN', 'referenced_table_name' => 'another_table', 'referenced_column_name' => 'another_column' - ) - ) - ), - 'constraint_keys' => array( - 'foo_schema' => array( - array( + ] + ] + ], + 'constraint_keys' => [ + 'foo_schema' => [ + [ 'table_name'=> 'bar_table', 'constraint_name' => 'bam_constraint', 'column_name' => 'a', 'ordinal_position' => 1, - ) - ) - ) - ); + ] + ] + ] + ]; $refProp->setValue($this->abstractSourceMock, $data); $constraints = $this->abstractSourceMock->getConstraintKeys('bam_constraint', 'bar_table', 'foo_schema'); diff --git a/test/Metadata/Source/SqliteMetadataTest.php b/test/Metadata/Source/SqliteMetadataTest.php index 2f52a9974f..7f1b4b4d79 100644 --- a/test/Metadata/Source/SqliteMetadataTest.php +++ b/test/Metadata/Source/SqliteMetadataTest.php @@ -36,10 +36,10 @@ protected function setUp() if (!extension_loaded('pdo_sqlite')) { $this->markTestSkipped('I cannot test without the pdo_sqlite extension'); } - $this->adapter = new Adapter(array( + $this->adapter = new Adapter([ 'driver' => 'Pdo', 'dsn' => 'sqlite::memory:' - )); + ]); $this->metadata = new SqliteMetadata($this->adapter); } diff --git a/test/ResultSet/AbstractResultSetIntegrationTest.php b/test/ResultSet/AbstractResultSetIntegrationTest.php index cae564ece3..4907c201cb 100644 --- a/test/ResultSet/AbstractResultSetIntegrationTest.php +++ b/test/ResultSet/AbstractResultSetIntegrationTest.php @@ -32,7 +32,7 @@ public function testCurrentCallsDataSourceCurrentAsManyTimesWithoutBuffer() { $result = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface'); $this->resultSet->initialize($result); - $result->expects($this->exactly(3))->method('current')->will($this->returnValue(array('foo' => 'bar'))); + $result->expects($this->exactly(3))->method('current')->will($this->returnValue(['foo' => 'bar'])); $value1 = $this->resultSet->current(); $value2 = $this->resultSet->current(); $this->resultSet->current(); @@ -47,7 +47,7 @@ public function testCurrentCallsDataSourceCurrentOnceWithBuffer() $result = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface'); $this->resultSet->buffer(); $this->resultSet->initialize($result); - $result->expects($this->once())->method('current')->will($this->returnValue(array('foo' => 'bar'))); + $result->expects($this->once())->method('current')->will($this->returnValue(['foo' => 'bar'])); $value1 = $this->resultSet->current(); $value2 = $this->resultSet->current(); $this->resultSet->current(); diff --git a/test/ResultSet/AbstractResultSetTest.php b/test/ResultSet/AbstractResultSetTest.php index a1b860677a..4ce13fad3e 100644 --- a/test/ResultSet/AbstractResultSetTest.php +++ b/test/ResultSet/AbstractResultSetTest.php @@ -32,11 +32,11 @@ public function testInitialize() { $resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet'); - $this->assertSame($resultSet, $resultSet->initialize(array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - array('id' => 3, 'name' => 'three'), - ))); + $this->assertSame($resultSet, $resultSet->initialize([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ])); $this->setExpectedException( 'Zend\Db\ResultSet\Exception\InvalidArgumentException', @@ -54,11 +54,11 @@ public function testBuffer() $this->assertSame($resultSet, $resultSet->buffer()); $resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet'); - $resultSet->initialize(new \ArrayIterator(array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - array('id' => 3, 'name' => 'three'), - ))); + $resultSet->initialize(new \ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ])); $resultSet->next(); // start iterator $this->setExpectedException( 'Zend\Db\ResultSet\Exception\RuntimeException', @@ -84,11 +84,11 @@ public function testIsBuffered() public function testGetDataSource() { $resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet'); - $resultSet->initialize(new \ArrayIterator(array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - array('id' => 3, 'name' => 'three'), - ))); + $resultSet->initialize(new \ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ])); $this->assertInstanceOf('\ArrayIterator', $resultSet->getDataSource()); } @@ -98,9 +98,9 @@ public function testGetDataSource() public function testGetFieldCount() { $resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet'); - $resultSet->initialize(new \ArrayIterator(array( - array('id' => 1, 'name' => 'one'), - ))); + $resultSet->initialize(new \ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ])); $this->assertEquals(2, $resultSet->getFieldCount()); } @@ -110,11 +110,11 @@ public function testGetFieldCount() public function testNext() { $resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet'); - $resultSet->initialize(new \ArrayIterator(array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - array('id' => 3, 'name' => 'three'), - ))); + $resultSet->initialize(new \ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ])); $this->assertNull($resultSet->next()); } @@ -124,11 +124,11 @@ public function testNext() public function testKey() { $resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet'); - $resultSet->initialize(new \ArrayIterator(array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - array('id' => 3, 'name' => 'three'), - ))); + $resultSet->initialize(new \ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ])); $resultSet->next(); $this->assertEquals(1, $resultSet->key()); $resultSet->next(); @@ -143,12 +143,12 @@ public function testKey() public function testCurrent() { $resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet'); - $resultSet->initialize(new \ArrayIterator(array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - array('id' => 3, 'name' => 'three'), - ))); - $this->assertEquals(array('id' => 1, 'name' => 'one'), $resultSet->current()); + $resultSet->initialize(new \ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ])); + $this->assertEquals(['id' => 1, 'name' => 'one'], $resultSet->current()); } /** @@ -157,11 +157,11 @@ public function testCurrent() public function testValid() { $resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet'); - $resultSet->initialize(new \ArrayIterator(array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - array('id' => 3, 'name' => 'three'), - ))); + $resultSet->initialize(new \ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ])); $this->assertTrue($resultSet->valid()); $resultSet->next(); $resultSet->next(); @@ -175,11 +175,11 @@ public function testValid() public function testRewind() { $resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet'); - $resultSet->initialize(new \ArrayIterator(array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - array('id' => 3, 'name' => 'three'), - ))); + $resultSet->initialize(new \ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ])); $this->assertNull($resultSet->rewind()); } @@ -189,11 +189,11 @@ public function testRewind() public function testCount() { $resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet'); - $resultSet->initialize(new \ArrayIterator(array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - array('id' => 3, 'name' => 'three'), - ))); + $resultSet->initialize(new \ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ])); $this->assertEquals(3, $resultSet->count()); } @@ -203,17 +203,17 @@ public function testCount() public function testToArray() { $resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet'); - $resultSet->initialize(new \ArrayIterator(array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - array('id' => 3, 'name' => 'three'), - ))); + $resultSet->initialize(new \ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ])); $this->assertEquals( - array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - array('id' => 3, 'name' => 'three'), - ), + [ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ], $resultSet->toArray() ); } @@ -225,11 +225,11 @@ public function testToArray() public function testBufferIterations() { $resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet'); - $resultSet->initialize(new \ArrayIterator(array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - array('id' => 3, 'name' => 'three'), - ))); + $resultSet->initialize(new \ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ])); $resultSet->buffer(); $data = $resultSet->current(); diff --git a/test/ResultSet/HydratingResultSetIntegrationTest.php b/test/ResultSet/HydratingResultSetIntegrationTest.php index e3a39fe6a2..b6650a722b 100644 --- a/test/ResultSet/HydratingResultSetIntegrationTest.php +++ b/test/ResultSet/HydratingResultSetIntegrationTest.php @@ -19,10 +19,10 @@ class HydratingResultSetIntegrationTest extends \PHPUnit_Framework_TestCase public function testCurrentWillReturnBufferedRow() { $hydratingRs = new HydratingResultSet; - $hydratingRs->initialize(new \ArrayIterator(array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two'), - ))); + $hydratingRs->initialize(new \ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ])); $hydratingRs->buffer(); $obj1 = $hydratingRs->current(); $hydratingRs->rewind(); diff --git a/test/ResultSet/HydratingResultSetTest.php b/test/ResultSet/HydratingResultSetTest.php index 4304a14585..803900b16a 100644 --- a/test/ResultSet/HydratingResultSetTest.php +++ b/test/ResultSet/HydratingResultSetTest.php @@ -56,9 +56,9 @@ public function testGetHydrator() public function testCurrent() { $hydratingRs = new HydratingResultSet; - $hydratingRs->initialize(array( - array('id' => 1, 'name' => 'one') - )); + $hydratingRs->initialize([ + ['id' => 1, 'name' => 'one'] + ]); $obj = $hydratingRs->current(); $this->assertInstanceOf('ArrayObject', $obj); } @@ -70,9 +70,9 @@ public function testCurrent() public function testToArray() { $hydratingRs = new HydratingResultSet; - $hydratingRs->initialize(array( - array('id' => 1, 'name' => 'one') - )); + $hydratingRs->initialize([ + ['id' => 1, 'name' => 'one'] + ]); $obj = $hydratingRs->toArray(); $this->assertInternalType('array', $obj); } diff --git a/test/ResultSet/ResultSetIntegrationTest.php b/test/ResultSet/ResultSetIntegrationTest.php index 8d4539b4eb..a4fecaafc1 100644 --- a/test/ResultSet/ResultSetIntegrationTest.php +++ b/test/ResultSet/ResultSetIntegrationTest.php @@ -59,14 +59,14 @@ public function testReturnTypeIsObjectByDefault() public function invalidReturnTypes() { - return array( - array(1), - array(1.0), - array(true), - array('string'), - array(array('foo')), - array(new stdClass), - ); + return [ + [1], + [1.0], + [true], + ['string'], + [['foo']], + [new stdClass], + ]; } /** @@ -92,7 +92,7 @@ public function testCanProvideIteratorAsDataSource() public function testCanProvideIteratorAggregateAsDataSource() { - $iteratorAggregate = $this->getMock('IteratorAggregate', array('getIterator'), array(new SplStack)); + $iteratorAggregate = $this->getMock('IteratorAggregate', ['getIterator'], [new SplStack]); $iteratorAggregate->expects($this->any())->method('getIterator')->will($this->returnValue($iteratorAggregate)); $this->resultSet->initialize($iteratorAggregate); $this->assertSame($iteratorAggregate->getIterator(), $this->resultSet->getDataSource()); @@ -118,12 +118,12 @@ public function testFieldCountIsZeroWithNoDataSourcePresent() public function getArrayDataSource($count) { - $array = array(); + $array = []; for ($i = 0; $i < $count; $i++) { - $array[] = array( + $array[] = [ 'id' => $i, 'title' => 'title ' . $i, - ); + ]; } return new ArrayIterator($array); } @@ -192,7 +192,7 @@ public function testToArrayCreatesArrayOfArraysRepresentingRows() public function testCurrentWithBufferingCallsDataSourceCurrentOnce() { $mockResult = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface'); - $mockResult->expects($this->once())->method('current')->will($this->returnValue(array('foo' => 'bar'))); + $mockResult->expects($this->once())->method('current')->will($this->returnValue(['foo' => 'bar'])); $this->resultSet->initialize($mockResult); $this->resultSet->buffer(); diff --git a/test/RowGateway/AbstractRowGatewayTest.php b/test/RowGateway/AbstractRowGatewayTest.php index e9b434de3c..03c824d7c0 100644 --- a/test/RowGateway/AbstractRowGatewayTest.php +++ b/test/RowGateway/AbstractRowGatewayTest.php @@ -34,15 +34,15 @@ public function setup() $mockDriver->expects($this->any())->method('getConnection')->will($this->returnValue($mockConnection)); // setup mock adapter - $this->mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $this->mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $this->rowGateway = $this->getMockForAbstractClass('Zend\Db\RowGateway\AbstractRowGateway'); - $rgPropertyValues = array( + $rgPropertyValues = [ 'primaryKeyColumn' => 'id', 'table' => 'foo', 'sql' => new \Zend\Db\Sql\Sql($this->mockAdapter) - ); + ]; $this->setRowGatewayState($rgPropertyValues); } @@ -142,9 +142,9 @@ public function test__get() public function testSaveInsert() { // test insert - $this->mockResult->expects($this->any())->method('current')->will($this->returnValue(array('id' => 5, 'name' => 'foo'))); + $this->mockResult->expects($this->any())->method('current')->will($this->returnValue(['id' => 5, 'name' => 'foo'])); $this->mockResult->expects($this->any())->method('getGeneratedValue')->will($this->returnValue(5)); - $this->rowGateway->populate(array('name' => 'foo')); + $this->rowGateway->populate(['name' => 'foo']); $this->rowGateway->save(); $this->assertEquals(5, $this->rowGateway->id); $this->assertEquals(5, $this->rowGateway['id']); @@ -157,17 +157,17 @@ public function testSaveInsertMultiKey() { $this->rowGateway = $this->getMockForAbstractClass('Zend\Db\RowGateway\AbstractRowGateway'); - $mockSql = $this->getMockForAbstractClass('Zend\Db\Sql\Sql', array($this->mockAdapter)); + $mockSql = $this->getMockForAbstractClass('Zend\Db\Sql\Sql', [$this->mockAdapter]); - $rgPropertyValues = array( - 'primaryKeyColumn' => array('one', 'two'), + $rgPropertyValues = [ + 'primaryKeyColumn' => ['one', 'two'], 'table' => 'foo', 'sql' => $mockSql - ); + ]; $this->setRowGatewayState($rgPropertyValues); // test insert - $this->mockResult->expects($this->any())->method('current')->will($this->returnValue(array('one' => 'foo', 'two' => 'bar'))); + $this->mockResult->expects($this->any())->method('current')->will($this->returnValue(['one' => 'foo', 'two' => 'bar'])); // @todo Need to assert that $where was filled in @@ -175,14 +175,14 @@ public function testSaveInsertMultiKey() $refRowGatewayProp = $refRowGateway->getProperty('primaryKeyData'); $refRowGatewayProp->setAccessible(true); - $this->rowGateway->populate(array('one' => 'foo', 'two' => 'bar')); + $this->rowGateway->populate(['one' => 'foo', 'two' => 'bar']); $this->assertNull($refRowGatewayProp->getValue($this->rowGateway)); // save should setup the primaryKeyData $this->rowGateway->save(); - $this->assertEquals(array('one' => 'foo', 'two' => 'bar'), $refRowGatewayProp->getValue($this->rowGateway)); + $this->assertEquals(['one' => 'foo', 'two' => 'bar'], $refRowGatewayProp->getValue($this->rowGateway)); } /** @@ -191,8 +191,8 @@ public function testSaveInsertMultiKey() public function testSaveUpdate() { // test update - $this->mockResult->expects($this->any())->method('current')->will($this->returnValue(array('id' => 6, 'name' => 'foo'))); - $this->rowGateway->populate(array('id' => 6, 'name' => 'foo'), true); + $this->mockResult->expects($this->any())->method('current')->will($this->returnValue(['id' => 6, 'name' => 'foo'])); + $this->rowGateway->populate(['id' => 6, 'name' => 'foo'], true); $this->rowGateway->save(); $this->assertEquals(6, $this->rowGateway['id']); } @@ -203,29 +203,29 @@ public function testSaveUpdate() public function testSaveUpdateChangingPrimaryKey() { // this mock is the select to be used to re-fresh the rowobject's data - $selectMock = $this->getMock('Zend\Db\Sql\Select', array('where')); + $selectMock = $this->getMock('Zend\Db\Sql\Select', ['where']); $selectMock->expects($this->once()) ->method('where') - ->with($this->equalTo(array('id' => 7))) + ->with($this->equalTo(['id' => 7])) ->will($this->returnValue($selectMock)); - $sqlMock = $this->getMock('Zend\Db\Sql\Sql', array('select'), array($this->mockAdapter)); + $sqlMock = $this->getMock('Zend\Db\Sql\Sql', ['select'], [$this->mockAdapter]); $sqlMock->expects($this->any()) ->method('select') ->will($this->returnValue($selectMock)); - $this->setRowGatewayState(array('sql' => $sqlMock)); + $this->setRowGatewayState(['sql' => $sqlMock]); // original mock returning updated data $this->mockResult->expects($this->any()) ->method('current') - ->will($this->returnValue(array('id' => 7, 'name' => 'fooUpdated'))); + ->will($this->returnValue(['id' => 7, 'name' => 'fooUpdated'])); // populate forces an update in save(), seeds with original data (from db) - $this->rowGateway->populate(array('id' => 6, 'name' => 'foo'), true); + $this->rowGateway->populate(['id' => 6, 'name' => 'foo'], true); $this->rowGateway->id = 7; $this->rowGateway->save(); - $this->assertEquals(array('id' => 7, 'name' => 'fooUpdated'), $this->rowGateway->toArray()); + $this->assertEquals(['id' => 7, 'name' => 'fooUpdated'], $this->rowGateway->toArray()); } /** @@ -245,12 +245,12 @@ public function testDelete() */ public function testPopulate() { - $this->rowGateway->populate(array('id' => 5, 'name' => 'foo')); + $this->rowGateway->populate(['id' => 5, 'name' => 'foo']); $this->assertEquals(5, $this->rowGateway['id']); $this->assertEquals('foo', $this->rowGateway['name']); $this->assertFalse($this->rowGateway->rowExistsInDatabase()); - $this->rowGateway->populate(array('id' => 5, 'name' => 'foo'), true); + $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); $this->assertTrue($this->rowGateway->rowExistsInDatabase()); } @@ -259,10 +259,10 @@ public function testPopulate() */ public function testProcessPrimaryKeyData() { - $this->rowGateway->populate(array('id' => 5, 'name' => 'foo'), true); + $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); $this->setExpectedException('Zend\Db\RowGateway\Exception\RuntimeException', 'a known key id was not found'); - $this->rowGateway->populate(array('boo' => 5, 'name' => 'foo'), true); + $this->rowGateway->populate(['boo' => 5, 'name' => 'foo'], true); } /** @@ -270,7 +270,7 @@ public function testProcessPrimaryKeyData() */ public function testCount() { - $this->rowGateway->populate(array('id' => 5, 'name' => 'foo'), true); + $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); $this->assertEquals(2, $this->rowGateway->count()); } @@ -279,8 +279,8 @@ public function testCount() */ public function testToArray() { - $this->rowGateway->populate(array('id' => 5, 'name' => 'foo'), true); - $this->assertEquals(array('id' => 5, 'name' => 'foo'), $this->rowGateway->toArray()); + $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); + $this->assertEquals(['id' => 5, 'name' => 'foo'], $this->rowGateway->toArray()); } protected function setRowGatewayState(array $properties) diff --git a/test/RowGateway/RowGatewayTest.php b/test/RowGateway/RowGatewayTest.php index 0f74574434..b27d1e36b6 100644 --- a/test/RowGateway/RowGatewayTest.php +++ b/test/RowGateway/RowGatewayTest.php @@ -34,7 +34,7 @@ public function setup() $mockDriver->expects($this->any())->method('getConnection')->will($this->returnValue($mockConnection)); // setup mock adapter - $this->mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $this->mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); } public function testEmptyPrimaryKey() diff --git a/test/Sql/AbstractSqlTest.php b/test/Sql/AbstractSqlTest.php index 2049898d1d..e4fec360ce 100644 --- a/test/Sql/AbstractSqlTest.php +++ b/test/Sql/AbstractSqlTest.php @@ -48,7 +48,7 @@ public function setup() */ public function testProcessExpressionWithoutParameterContainer() { - $expression = new Expression('? > ? AND y < ?', array('x', 5, 10), array(Expression::TYPE_IDENTIFIER)); + $expression = new Expression('? > ? AND y < ?', ['x', 5, 10], [Expression::TYPE_IDENTIFIER]); $sqlAndParams = $this->invokeProcessExpressionMethod($expression); $this->assertEquals("\"x\" > '5' AND y < '10'", $sqlAndParams); @@ -60,7 +60,7 @@ public function testProcessExpressionWithoutParameterContainer() public function testProcessExpressionWithParameterContainerAndParameterizationTypeNamed() { $parameterContainer = new ParameterContainer; - $expression = new Expression('? > ? AND y < ?', array('x', 5, 10), array(Expression::TYPE_IDENTIFIER)); + $expression = new Expression('? > ? AND y < ?', ['x', 5, 10], [Expression::TYPE_IDENTIFIER]); $sqlAndParams = $this->invokeProcessExpressionMethod($expression, $parameterContainer); $parameters = $parameterContainer->getNamedArray(); @@ -96,7 +96,7 @@ public function testProcessExpressionWorksWithExpressionContainingStringParts() { $expression = new Predicate\Expression('x = ?', 5); - $predicateSet = new Predicate\PredicateSet(array(new Predicate\PredicateSet(array($expression)))); + $predicateSet = new Predicate\PredicateSet([new Predicate\PredicateSet([$expression])]); $sqlAndParams = $this->invokeProcessExpressionMethod($predicateSet); $this->assertEquals("(x = '5')", $sqlAndParams); @@ -111,7 +111,7 @@ public function testProcessExpressionWorksWithExpressionContainingSelectObject() $select->from('x')->where->like('bar', 'Foo%'); $expression = new Predicate\In('x', $select); - $predicateSet = new Predicate\PredicateSet(array(new Predicate\PredicateSet(array($expression)))); + $predicateSet = new Predicate\PredicateSet([new Predicate\PredicateSet([$expression])]); $sqlAndParams = $this->invokeProcessExpressionMethod($predicateSet); $this->assertEquals('("x" IN (SELECT "x".* FROM "x" WHERE "bar" LIKE \'Foo%\'))', $sqlAndParams); @@ -145,7 +145,7 @@ public function testProcessExpressionWorksWithNamedParameterPrefix() { $parameterContainer = new ParameterContainer(); $namedParameterPrefix = uniqid(); - $expression = new Expression('FROM_UNIXTIME(?)', array(10000000)); + $expression = new Expression('FROM_UNIXTIME(?)', [10000000]); $this->invokeProcessExpressionMethod($expression, $parameterContainer, $namedParameterPrefix); $this->assertSame($namedParameterPrefix . '1', key($parameterContainer->getNamedArray())); @@ -155,7 +155,7 @@ public function testProcessExpressionWorksWithNamedParameterPrefixContainingWhit { $parameterContainer = new ParameterContainer(); $namedParameterPrefix = "string\ncontaining white space"; - $expression = new Expression('FROM_UNIXTIME(?)', array(10000000)); + $expression = new Expression('FROM_UNIXTIME(?)', [10000000]); $this->invokeProcessExpressionMethod($expression, $parameterContainer, $namedParameterPrefix); $this->assertSame('string__containing__white__space1', key($parameterContainer->getNamedArray())); diff --git a/test/Sql/CombineTest.php b/test/Sql/CombineTest.php index 9a4c4b2d32..4a27e77eed 100644 --- a/test/Sql/CombineTest.php +++ b/test/Sql/CombineTest.php @@ -66,11 +66,11 @@ public function testGetSqlStringWithModifier() public function testGetSqlStringFromArray() { - $this->combine->combine(array( - array(new Select('t1')), - array(new Select('t2'), Combine::COMBINE_INTERSECT, 'ALL'), - array(new Select('t3'), Combine::COMBINE_EXCEPT), - )); + $this->combine->combine([ + [new Select('t1')], + [new Select('t2'), Combine::COMBINE_INTERSECT, 'ALL'], + [new Select('t3'), Combine::COMBINE_EXCEPT], + ]); $this->assertEquals( '(SELECT "t1".* FROM "t1") INTERSECT ALL (SELECT "t2".* FROM "t2") EXCEPT (SELECT "t3".* FROM "t3")', @@ -78,11 +78,11 @@ public function testGetSqlStringFromArray() ); $this->combine = new Combine(); - $this->combine->combine(array( + $this->combine->combine([ new Select('t1'), new Select('t2'), new Select('t3'), - )); + ]); $this->assertEquals( '(SELECT "t1".* FROM "t1") UNION (SELECT "t2".* FROM "t2") UNION (SELECT "t3".* FROM "t3")', @@ -101,14 +101,14 @@ public function testGetSqlStringEmpty() public function testPrepareStatementWithModifier() { $select1 = new Select('t1'); - $select1->where(array('x1'=>10)); + $select1->where(['x1'=>10]); $select2 = new Select('t2'); - $select2->where(array('x2'=>20)); + $select2->where(['x2'=>20]); - $this->combine->combine(array( + $this->combine->combine([ $select1, $select2 - )); + ]); $adapter = $this->getMockAdapter(); @@ -123,35 +123,35 @@ public function testPrepareStatementWithModifier() public function testAlignColumns() { $select1 = new Select('t1'); - $select1->columns(array( + $select1->columns([ 'c0' => 'c0', 'c1' => 'c1', - )); + ]); $select2 = new Select('t2'); - $select2->columns(array( + $select2->columns([ 'c1' => 'c1', 'c2' => 'c2', - )); + ]); $this->combine - ->union(array($select1, $select2)) + ->union([$select1, $select2]) ->alignColumns(); $this->assertEquals( - array( + [ 'c0' => 'c0', 'c1' => 'c1', 'c2' => new Expression('NULL'), - ), + ], $select1->getRawState('columns') ); $this->assertEquals( - array( + [ 'c0' => new Expression('NULL'), 'c1' => 'c1', 'c2' => 'c2', - ), + ], $select2->getRawState('columns') ); } @@ -161,18 +161,18 @@ public function testGetRawState() $select = new Select('t1'); $this->combine->combine($select); $this->assertSame( - array( - 'combine' => array( - array( + [ + 'combine' => [ + [ 'select' => $select, 'type' => Combine::COMBINE_UNION, 'modifier' => '' - ), - ), - 'columns' => array( + ], + ], + 'columns' => [ '0' => '*', - ), - ), + ], + ], $this->combine->getRawState() ); } @@ -204,6 +204,6 @@ protected function getMockAdapter() $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?')); $mockDriver->expects($this->any())->method('createStatement')->will($this->returnValue($mockStatement)); - return $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + return $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); } } diff --git a/test/Sql/Ddl/AlterTableTest.php b/test/Sql/Ddl/AlterTableTest.php index 75082f29df..41e8db3918 100644 --- a/test/Sql/Ddl/AlterTableTest.php +++ b/test/Sql/Ddl/AlterTableTest.php @@ -35,7 +35,7 @@ public function testAddColumn() /** @var \Zend\Db\Sql\Ddl\Column\ColumnInterface $colMock */ $colMock = $this->getMock('Zend\Db\Sql\Ddl\Column\ColumnInterface'); $this->assertSame($at, $at->addColumn($colMock)); - $this->assertEquals(array($colMock), $at->getRawState($at::ADD_COLUMNS)); + $this->assertEquals([$colMock], $at->getRawState($at::ADD_COLUMNS)); } /** @@ -47,7 +47,7 @@ public function testChangeColumn() /** @var \Zend\Db\Sql\Ddl\Column\ColumnInterface $colMock */ $colMock = $this->getMock('Zend\Db\Sql\Ddl\Column\ColumnInterface'); $this->assertSame($at, $at->changeColumn('newname', $colMock)); - $this->assertEquals(array('newname' => $colMock), $at->getRawState($at::CHANGE_COLUMNS)); + $this->assertEquals(['newname' => $colMock], $at->getRawState($at::CHANGE_COLUMNS)); } /** @@ -57,7 +57,7 @@ public function testDropColumn() { $at = new AlterTable(); $this->assertSame($at, $at->dropColumn('foo')); - $this->assertEquals(array('foo'), $at->getRawState($at::DROP_COLUMNS)); + $this->assertEquals(['foo'], $at->getRawState($at::DROP_COLUMNS)); } /** @@ -67,7 +67,7 @@ public function testDropConstraint() { $at = new AlterTable(); $this->assertSame($at, $at->dropConstraint('foo')); - $this->assertEquals(array('foo'), $at->getRawState($at::DROP_CONSTRAINTS)); + $this->assertEquals(['foo'], $at->getRawState($at::DROP_CONSTRAINTS)); } /** @@ -79,7 +79,7 @@ public function testAddConstraint() /** @var \Zend\Db\Sql\Ddl\Constraint\ConstraintInterface $conMock */ $conMock = $this->getMock('Zend\Db\Sql\Ddl\Constraint\ConstraintInterface'); $this->assertSame($at, $at->addConstraint($conMock)); - $this->assertEquals(array($conMock), $at->getRawState($at::ADD_CONSTRAINTS)); + $this->assertEquals([$conMock], $at->getRawState($at::ADD_CONSTRAINTS)); } /** @@ -105,8 +105,8 @@ public function testGetSqlString() $actual = $at->getSqlString(); $this->assertEquals( - str_replace(array("\r", "\n"), "", $expected), - str_replace(array("\r", "\n"), "", $actual) + str_replace(["\r", "\n"], "", $expected), + str_replace(["\r", "\n"], "", $actual) ); } } diff --git a/test/Sql/Ddl/Column/AbstractLengthColumnTest.php b/test/Sql/Ddl/Column/AbstractLengthColumnTest.php index e8487b9192..f067b3d031 100644 --- a/test/Sql/Ddl/Column/AbstractLengthColumnTest.php +++ b/test/Sql/Ddl/Column/AbstractLengthColumnTest.php @@ -16,9 +16,9 @@ class AbstractLengthColumnTest extends \PHPUnit_Framework_TestCase */ public function testSetLength() { - $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractLengthColumn', array( + $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractLengthColumn', [ 'foo', 55 - )); + ]); $this->assertEquals(55, $column->getLength()); $this->assertSame($column, $column->setLength(20)); $this->assertEquals(20, $column->getLength()); @@ -29,9 +29,9 @@ public function testSetLength() */ public function testGetLength() { - $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractLengthColumn', array( + $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractLengthColumn', [ 'foo', 55 - )); + ]); $this->assertEquals(55, $column->getLength()); } @@ -40,12 +40,12 @@ public function testGetLength() */ public function testGetExpressionData() { - $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractLengthColumn', array( + $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractLengthColumn', [ 'foo', 4 - )); + ]); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'INTEGER(4)'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'INTEGER(4)'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/AbstractPrecisionColumnTest.php b/test/Sql/Ddl/Column/AbstractPrecisionColumnTest.php index 5688b86148..f5c746498e 100644 --- a/test/Sql/Ddl/Column/AbstractPrecisionColumnTest.php +++ b/test/Sql/Ddl/Column/AbstractPrecisionColumnTest.php @@ -16,9 +16,9 @@ class AbstractPrecisionColumnTest extends \PHPUnit_Framework_TestCase */ public function testSetDigits() { - $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractPrecisionColumn', array( + $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractPrecisionColumn', [ 'foo', 10 - )); + ]); $this->assertEquals(10, $column->getDigits()); $this->assertSame($column, $column->setDigits(12)); $this->assertEquals(12, $column->getDigits()); @@ -29,9 +29,9 @@ public function testSetDigits() */ public function testGetDigits() { - $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractPrecisionColumn', array( + $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractPrecisionColumn', [ 'foo', 10 - )); + ]); $this->assertEquals(10, $column->getDigits()); } @@ -40,9 +40,9 @@ public function testGetDigits() */ public function testSetDecimal() { - $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractPrecisionColumn', array( + $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractPrecisionColumn', [ 'foo', 10, 5 - )); + ]); $this->assertEquals(5, $column->getDecimal()); $this->assertSame($column, $column->setDecimal(2)); $this->assertEquals(2, $column->getDecimal()); @@ -53,9 +53,9 @@ public function testSetDecimal() */ public function testGetDecimal() { - $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractPrecisionColumn', array( + $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractPrecisionColumn', [ 'foo', 10, 5 - )); + ]); $this->assertEquals(5, $column->getDecimal()); } @@ -64,12 +64,12 @@ public function testGetDecimal() */ public function testGetExpressionData() { - $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractPrecisionColumn', array( + $column = $this->getMockForAbstractClass('Zend\Db\Sql\Ddl\Column\AbstractPrecisionColumn', [ 'foo', 10, 5 - )); + ]); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'INTEGER(10,5)'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'INTEGER(10,5)'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/BigIntegerTest.php b/test/Sql/Ddl/Column/BigIntegerTest.php index 41c04f8ae0..5d5676c880 100644 --- a/test/Sql/Ddl/Column/BigIntegerTest.php +++ b/test/Sql/Ddl/Column/BigIntegerTest.php @@ -29,7 +29,7 @@ public function testGetExpressionData() { $column = new BigInteger('foo'); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'BIGINT'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'BIGINT'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/BinaryTest.php b/test/Sql/Ddl/Column/BinaryTest.php index aebea74ca4..1bc7ffaceb 100644 --- a/test/Sql/Ddl/Column/BinaryTest.php +++ b/test/Sql/Ddl/Column/BinaryTest.php @@ -20,7 +20,7 @@ public function testGetExpressionData() { $column = new Binary('foo', 10000000); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'BINARY(10000000)'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'BINARY(10000000)'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/BlobTest.php b/test/Sql/Ddl/Column/BlobTest.php index 035d16516d..a0fd001ab4 100644 --- a/test/Sql/Ddl/Column/BlobTest.php +++ b/test/Sql/Ddl/Column/BlobTest.php @@ -20,7 +20,7 @@ public function testGetExpressionData() { $column = new Blob('foo'); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'BLOB'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'BLOB'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/BooleanTest.php b/test/Sql/Ddl/Column/BooleanTest.php index 821526238e..141d82d997 100644 --- a/test/Sql/Ddl/Column/BooleanTest.php +++ b/test/Sql/Ddl/Column/BooleanTest.php @@ -20,7 +20,7 @@ public function testGetExpressionData() { $column = new Boolean('foo'); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'BOOLEAN'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'BOOLEAN'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/CharTest.php b/test/Sql/Ddl/Column/CharTest.php index eccf39a68f..d6503ba028 100644 --- a/test/Sql/Ddl/Column/CharTest.php +++ b/test/Sql/Ddl/Column/CharTest.php @@ -20,7 +20,7 @@ public function testGetExpressionData() { $column = new Char('foo', 20); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'CHAR(20)'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'CHAR(20)'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/ColumnTest.php b/test/Sql/Ddl/Column/ColumnTest.php index 3c193edcce..13a6d56cea 100644 --- a/test/Sql/Ddl/Column/ColumnTest.php +++ b/test/Sql/Ddl/Column/ColumnTest.php @@ -78,7 +78,7 @@ public function testGetDefault(Column $column) public function testSetOptions() { $column = new Column; - $this->assertSame($column, $column->setOptions(array('autoincrement' => true))); + $this->assertSame($column, $column->setOptions(['autoincrement' => true])); return $column; } @@ -97,7 +97,7 @@ public function testSetOption() */ public function testGetOptions(Column $column) { - $this->assertEquals(array('autoincrement' => true), $column->getOptions()); + $this->assertEquals(['autoincrement' => true], $column->getOptions()); } /** @@ -108,19 +108,19 @@ public function testGetExpressionData() $column = new Column; $column->setName('foo'); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'INTEGER'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'INTEGER'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); $column->setNullable(true); $this->assertEquals( - array(array('%s %s', array('foo', 'INTEGER'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s', ['foo', 'INTEGER'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); $column->setDefault('bar'); $this->assertEquals( - array(array('%s %s DEFAULT %s', array('foo', 'INTEGER', 'bar'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL, $column::TYPE_VALUE))), + [['%s %s DEFAULT %s', ['foo', 'INTEGER', 'bar'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL, $column::TYPE_VALUE]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/DateTest.php b/test/Sql/Ddl/Column/DateTest.php index b5691b34f0..e27c4fa4bc 100644 --- a/test/Sql/Ddl/Column/DateTest.php +++ b/test/Sql/Ddl/Column/DateTest.php @@ -20,7 +20,7 @@ public function testGetExpressionData() { $column = new Date('foo'); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'DATE'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'DATE'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/DatetimeTest.php b/test/Sql/Ddl/Column/DatetimeTest.php index 5577243fab..1e10fcd9ec 100644 --- a/test/Sql/Ddl/Column/DatetimeTest.php +++ b/test/Sql/Ddl/Column/DatetimeTest.php @@ -20,7 +20,7 @@ public function testGetExpressionData() { $column = new Datetime('foo'); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'DATETIME'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'DATETIME'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/DecimalTest.php b/test/Sql/Ddl/Column/DecimalTest.php index 09fbc55b27..9b4029de6f 100644 --- a/test/Sql/Ddl/Column/DecimalTest.php +++ b/test/Sql/Ddl/Column/DecimalTest.php @@ -20,7 +20,7 @@ public function testGetExpressionData() { $column = new Decimal('foo', 10, 5); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'DECIMAL(10,5)'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'DECIMAL(10,5)'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/FloatingTest.php b/test/Sql/Ddl/Column/FloatingTest.php index 05794c0441..8cd4fe9990 100644 --- a/test/Sql/Ddl/Column/FloatingTest.php +++ b/test/Sql/Ddl/Column/FloatingTest.php @@ -20,11 +20,11 @@ public function testGetExpressionData() { $column = new Floating('foo', 10, 5); $this->assertEquals( - array(array( + [[ '%s %s NOT NULL', - array('foo', 'FLOAT(10,5)'), - array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL) - )), + ['foo', 'FLOAT(10,5)'], + [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL] + ]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/IntegerTest.php b/test/Sql/Ddl/Column/IntegerTest.php index 4ddb2d1871..ed8a6c69da 100644 --- a/test/Sql/Ddl/Column/IntegerTest.php +++ b/test/Sql/Ddl/Column/IntegerTest.php @@ -30,18 +30,18 @@ public function testGetExpressionData() { $column = new Integer('foo'); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'INTEGER'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'INTEGER'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); $column = new Integer('foo'); $column->addConstraint(new PrimaryKey()); $this->assertEquals( - array( - array('%s %s NOT NULL', array('foo', 'INTEGER'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL)), + [ + ['%s %s NOT NULL', ['foo', 'INTEGER'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]], ' ', - array('PRIMARY KEY', array(), array()) - ), + ['PRIMARY KEY', [], []] + ], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/TextTest.php b/test/Sql/Ddl/Column/TextTest.php index 31a3873dad..11c3891a6b 100644 --- a/test/Sql/Ddl/Column/TextTest.php +++ b/test/Sql/Ddl/Column/TextTest.php @@ -20,7 +20,7 @@ public function testGetExpressionData() { $column = new Text('foo'); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'TEXT'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'TEXT'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/TimeTest.php b/test/Sql/Ddl/Column/TimeTest.php index 4621396112..a5457fdfad 100644 --- a/test/Sql/Ddl/Column/TimeTest.php +++ b/test/Sql/Ddl/Column/TimeTest.php @@ -20,7 +20,7 @@ public function testGetExpressionData() { $column = new Time('foo'); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'TIME'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'TIME'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/TimestampTest.php b/test/Sql/Ddl/Column/TimestampTest.php index 80f8c04bf3..fe8144fb68 100644 --- a/test/Sql/Ddl/Column/TimestampTest.php +++ b/test/Sql/Ddl/Column/TimestampTest.php @@ -20,7 +20,7 @@ public function testGetExpressionData() { $column = new Timestamp('foo'); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'TIMESTAMP'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'TIMESTAMP'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/VarbinaryTest.php b/test/Sql/Ddl/Column/VarbinaryTest.php index bcc0a38783..409dcf4429 100644 --- a/test/Sql/Ddl/Column/VarbinaryTest.php +++ b/test/Sql/Ddl/Column/VarbinaryTest.php @@ -20,7 +20,7 @@ public function testGetExpressionData() { $column = new Varbinary('foo', 20); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'VARBINARY(20)'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'VARBINARY(20)'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Column/VarcharTest.php b/test/Sql/Ddl/Column/VarcharTest.php index 5bf0316c17..2787fd4c5e 100644 --- a/test/Sql/Ddl/Column/VarcharTest.php +++ b/test/Sql/Ddl/Column/VarcharTest.php @@ -20,13 +20,13 @@ public function testGetExpressionData() { $column = new Varchar('foo', 20); $this->assertEquals( - array(array('%s %s NOT NULL', array('foo', 'VARCHAR(20)'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL))), + [['%s %s NOT NULL', ['foo', 'VARCHAR(20)'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL]]], $column->getExpressionData() ); $column->setDefault('bar'); $this->assertEquals( - array(array('%s %s NOT NULL DEFAULT %s', array('foo', 'VARCHAR(20)', 'bar'), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL, $column::TYPE_VALUE))), + [['%s %s NOT NULL DEFAULT %s', ['foo', 'VARCHAR(20)', 'bar'], [$column::TYPE_IDENTIFIER, $column::TYPE_LITERAL, $column::TYPE_VALUE]]], $column->getExpressionData() ); } diff --git a/test/Sql/Ddl/Constraint/AbstractConstraintTest.php b/test/Sql/Ddl/Constraint/AbstractConstraintTest.php index 0b13a7a9d4..2a22a0b591 100644 --- a/test/Sql/Ddl/Constraint/AbstractConstraintTest.php +++ b/test/Sql/Ddl/Constraint/AbstractConstraintTest.php @@ -24,8 +24,8 @@ public function setup() */ public function testSetColumns() { - $this->assertSame($this->ac, $this->ac->setColumns(array('foo', 'bar'))); - $this->assertEquals(array('foo', 'bar'), $this->ac->getColumns()); + $this->assertSame($this->ac, $this->ac->setColumns(['foo', 'bar'])); + $this->assertEquals(['foo', 'bar'], $this->ac->getColumns()); } /** @@ -34,7 +34,7 @@ public function testSetColumns() public function testAddColumn() { $this->assertSame($this->ac, $this->ac->addColumn('foo')); - $this->assertEquals(array('foo'), $this->ac->getColumns()); + $this->assertEquals(['foo'], $this->ac->getColumns()); } /** @@ -42,7 +42,7 @@ public function testAddColumn() */ public function testGetColumns() { - $this->ac->setColumns(array('foo', 'bar')); - $this->assertEquals(array('foo', 'bar'), $this->ac->getColumns()); + $this->ac->setColumns(['foo', 'bar']); + $this->assertEquals(['foo', 'bar'], $this->ac->getColumns()); } } diff --git a/test/Sql/Ddl/Constraint/CheckTest.php b/test/Sql/Ddl/Constraint/CheckTest.php index 2d09b745c9..e44c043fd9 100644 --- a/test/Sql/Ddl/Constraint/CheckTest.php +++ b/test/Sql/Ddl/Constraint/CheckTest.php @@ -20,11 +20,11 @@ public function testGetExpressionData() { $check = new Check('id>0', 'foo'); $this->assertEquals( - array(array( + [[ 'CONSTRAINT %s CHECK (%s)', - array('foo', 'id>0'), - array($check::TYPE_IDENTIFIER, $check::TYPE_LITERAL) - )), + ['foo', 'id>0'], + [$check::TYPE_IDENTIFIER, $check::TYPE_LITERAL] + ]], $check->getExpressionData() ); } diff --git a/test/Sql/Ddl/Constraint/ForeignKeyTest.php b/test/Sql/Ddl/Constraint/ForeignKeyTest.php index 5b2179d4c0..70568c8da0 100644 --- a/test/Sql/Ddl/Constraint/ForeignKeyTest.php +++ b/test/Sql/Ddl/Constraint/ForeignKeyTest.php @@ -67,7 +67,7 @@ public function testSetReferenceColumn() */ public function testGetReferenceColumn(ForeignKey $fk) { - $this->assertEquals(array('xxxx'), $fk->getReferenceColumn()); + $this->assertEquals(['xxxx'], $fk->getReferenceColumn()); } /** @@ -115,11 +115,11 @@ public function testGetExpressionData() { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam', 'CASCADE', 'SET NULL'); $this->assertEquals( - array(array( + [[ 'CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s) ON DELETE %s ON UPDATE %s', - array('foo', 'bar', 'baz', 'bam', 'CASCADE', 'SET NULL'), - array($fk::TYPE_IDENTIFIER, $fk::TYPE_IDENTIFIER, $fk::TYPE_IDENTIFIER, $fk::TYPE_IDENTIFIER, $fk::TYPE_LITERAL, $fk::TYPE_LITERAL) - )), + ['foo', 'bar', 'baz', 'bam', 'CASCADE', 'SET NULL'], + [$fk::TYPE_IDENTIFIER, $fk::TYPE_IDENTIFIER, $fk::TYPE_IDENTIFIER, $fk::TYPE_IDENTIFIER, $fk::TYPE_LITERAL, $fk::TYPE_LITERAL] + ]], $fk->getExpressionData() ); } diff --git a/test/Sql/Ddl/Constraint/PrimaryKeyTest.php b/test/Sql/Ddl/Constraint/PrimaryKeyTest.php index 6e9a40effd..58e3d75eea 100644 --- a/test/Sql/Ddl/Constraint/PrimaryKeyTest.php +++ b/test/Sql/Ddl/Constraint/PrimaryKeyTest.php @@ -20,11 +20,11 @@ public function testGetExpressionData() { $pk = new PrimaryKey('foo'); $this->assertEquals( - array(array( + [[ 'PRIMARY KEY (%s)', - array('foo'), - array($pk::TYPE_IDENTIFIER) - )), + ['foo'], + [$pk::TYPE_IDENTIFIER] + ]], $pk->getExpressionData() ); } diff --git a/test/Sql/Ddl/Constraint/UniqueKeyTest.php b/test/Sql/Ddl/Constraint/UniqueKeyTest.php index 1861d9e7ce..0b67b46fb6 100644 --- a/test/Sql/Ddl/Constraint/UniqueKeyTest.php +++ b/test/Sql/Ddl/Constraint/UniqueKeyTest.php @@ -20,11 +20,11 @@ public function testGetExpressionData() { $uk = new UniqueKey('foo', 'my_uk'); $this->assertEquals( - array(array( + [[ 'CONSTRAINT %s UNIQUE (%s)', - array('my_uk', 'foo'), - array($uk::TYPE_IDENTIFIER, $uk::TYPE_IDENTIFIER) - )), + ['my_uk', 'foo'], + [$uk::TYPE_IDENTIFIER, $uk::TYPE_IDENTIFIER] + ]], $uk->getExpressionData() ); } diff --git a/test/Sql/Ddl/Index/IndexTest.php b/test/Sql/Ddl/Index/IndexTest.php index 043a4709c2..9e7c37c8af 100644 --- a/test/Sql/Ddl/Index/IndexTest.php +++ b/test/Sql/Ddl/Index/IndexTest.php @@ -20,11 +20,11 @@ public function testGetExpressionData() { $uk = new Index('foo', 'my_uk'); $this->assertEquals( - array(array( + [[ 'INDEX %s(%s)', - array('my_uk', 'foo'), - array($uk::TYPE_IDENTIFIER, $uk::TYPE_IDENTIFIER) - )), + ['my_uk', 'foo'], + [$uk::TYPE_IDENTIFIER, $uk::TYPE_IDENTIFIER] + ]], $uk->getExpressionData() ); } @@ -34,13 +34,13 @@ public function testGetExpressionData() */ public function testGetExpressionDataWithLength() { - $key = new Index(array('foo', 'bar'), 'my_uk', array(10, 5)); + $key = new Index(['foo', 'bar'], 'my_uk', [10, 5]); $this->assertEquals( - array(array( + [[ 'INDEX %s(%s(10), %s(5))', - array('my_uk', 'foo', 'bar'), - array($key::TYPE_IDENTIFIER, $key::TYPE_IDENTIFIER, $key::TYPE_IDENTIFIER) - )), + ['my_uk', 'foo', 'bar'], + [$key::TYPE_IDENTIFIER, $key::TYPE_IDENTIFIER, $key::TYPE_IDENTIFIER] + ]], $key->getExpressionData() ); } @@ -50,13 +50,13 @@ public function testGetExpressionDataWithLength() */ public function testGetExpressionDataWithLengthUnmatched() { - $key = new Index(array('foo', 'bar'), 'my_uk', array(10)); + $key = new Index(['foo', 'bar'], 'my_uk', [10]); $this->assertEquals( - array(array( + [[ 'INDEX %s(%s(10), %s)', - array('my_uk', 'foo', 'bar'), - array($key::TYPE_IDENTIFIER, $key::TYPE_IDENTIFIER, $key::TYPE_IDENTIFIER) - )), + ['my_uk', 'foo', 'bar'], + [$key::TYPE_IDENTIFIER, $key::TYPE_IDENTIFIER, $key::TYPE_IDENTIFIER] + ]], $key->getExpressionData() ); } diff --git a/test/Sql/DeleteTest.php b/test/Sql/DeleteTest.php index 81c854de88..83bb920f63 100644 --- a/test/Sql/DeleteTest.php +++ b/test/Sql/DeleteTest.php @@ -59,13 +59,13 @@ public function testFrom() public function testWhere() { $this->delete->where('x = y'); - $this->delete->where(array('foo > ?' => 5)); - $this->delete->where(array('id' => 2)); - $this->delete->where(array('a = b'), Where::OP_OR); - $this->delete->where(array('c1' => null)); - $this->delete->where(array('c2' => array(1, 2, 3))); - $this->delete->where(array(new IsNotNull('c3'))); - $this->delete->where(array('one' => 1, 'two' => 2)); + $this->delete->where(['foo > ?' => 5]); + $this->delete->where(['id' => 2]); + $this->delete->where(['a = b'], Where::OP_OR); + $this->delete->where(['c1' => null]); + $this->delete->where(['c2' => [1, 2, 3]]); + $this->delete->where([new IsNotNull('c3')]); + $this->delete->where(['one' => 1, 'two' => 2]); $where = $this->delete->where; $predicates = $this->readAttribute($where, 'predicates'); @@ -112,7 +112,7 @@ public function testWhere() public function testPrepareStatement() { $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); $mockStatement->expects($this->at(2)) @@ -127,7 +127,7 @@ public function testPrepareStatement() // with TableIdentifier $this->delete = new Delete; $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); $mockStatement->expects($this->at(2)) @@ -164,7 +164,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $deleteIgnore = new DeleteIgnore(); $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); $mockStatement->expects($this->at(2)) @@ -182,7 +182,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $deleteIgnore = new DeleteIgnore(); $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); $mockStatement->expects($this->at(2)) @@ -218,10 +218,10 @@ class DeleteIgnore extends Delete { const SPECIFICATION_DELETE = 'deleteIgnore'; - protected $specifications = array( + protected $specifications = [ self::SPECIFICATION_DELETE => 'DELETE IGNORE FROM %1$s', self::SPECIFICATION_WHERE => 'WHERE %1$s', - ); + ]; protected function processdeleteIgnore(\Zend\Db\Adapter\Platform\PlatformInterface $platform, \Zend\Db\Adapter\Driver\DriverInterface $driver = null, \Zend\Db\Adapter\ParameterContainer $parameterContainer = null) { diff --git a/test/Sql/ExpressionTest.php b/test/Sql/ExpressionTest.php index adc4e7a584..be11cef2bd 100644 --- a/test/Sql/ExpressionTest.php +++ b/test/Sql/ExpressionTest.php @@ -87,7 +87,7 @@ public function testGetParameters(Expression $expression) public function testSetTypes() { $expression = new Expression(); - $return = $expression->setTypes(array(Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_LITERAL)); + $return = $expression->setTypes([Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_LITERAL]); $this->assertSame($expression, $return); return $expression; } @@ -99,7 +99,7 @@ public function testSetTypes() public function testGetTypes(Expression $expression) { $this->assertEquals( - array(Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_LITERAL), + [Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_LITERAL], $expression->getTypes() ); } @@ -111,32 +111,32 @@ public function testGetExpressionData() { $expression = new Expression( 'X SAME AS ? AND Y = ? BUT LITERALLY ?', - array('foo', 5, 'FUNC(FF%X)'), - array(Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_LITERAL) + ['foo', 5, 'FUNC(FF%X)'], + [Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_LITERAL] ); $this->assertEquals( - array(array( + [[ 'X SAME AS %s AND Y = %s BUT LITERALLY %s', - array('foo', 5, 'FUNC(FF%X)'), - array(Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_LITERAL) - )), + ['foo', 5, 'FUNC(FF%X)'], + [Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_LITERAL] + ]], $expression->getExpressionData() ); $expression = new Expression( 'X SAME AS ? AND Y = ? BUT LITERALLY ?', - array( - array('foo' => Expression::TYPE_IDENTIFIER), - array(5 => Expression::TYPE_VALUE), - array('FUNC(FF%X)' => Expression::TYPE_LITERAL), - ) + [ + ['foo' => Expression::TYPE_IDENTIFIER], + [5 => Expression::TYPE_VALUE], + ['FUNC(FF%X)' => Expression::TYPE_LITERAL], + ] ); - $expected = array(array( + $expected = [[ 'X SAME AS %s AND Y = %s BUT LITERALLY %s', - array('foo', 5, 'FUNC(FF%X)'), - array(Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_LITERAL) - )); + ['foo', 5, 'FUNC(FF%X)'], + [Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_LITERAL] + ]]; $this->assertEquals($expected, $expression->getExpressionData()); } @@ -145,7 +145,7 @@ public function testGetExpressionDataWillEscapePercent() { $expression = new Expression('X LIKE "foo%"'); $this->assertEquals( - array('X LIKE "foo%%"'), + ['X LIKE "foo%%"'], $expression->getExpressionData() ); } diff --git a/test/Sql/InsertTest.php b/test/Sql/InsertTest.php index be960d0546..4c0bb2f628 100644 --- a/test/Sql/InsertTest.php +++ b/test/Sql/InsertTest.php @@ -49,8 +49,8 @@ public function testInto() */ public function testColumns() { - $this->insert->columns(array('foo', 'bar')); - $this->assertEquals(array('foo', 'bar'), $this->insert->getRawState('columns')); + $this->insert->columns(['foo', 'bar']); + $this->assertEquals(['foo', 'bar'], $this->insert->getRawState('columns')); } /** @@ -58,19 +58,19 @@ public function testColumns() */ public function testValues() { - $this->insert->values(array('foo' => 'bar')); - $this->assertEquals(array('foo'), $this->insert->getRawState('columns')); - $this->assertEquals(array('bar'), $this->insert->getRawState('values')); + $this->insert->values(['foo' => 'bar']); + $this->assertEquals(['foo'], $this->insert->getRawState('columns')); + $this->assertEquals(['bar'], $this->insert->getRawState('values')); // test will merge cols and values of previously set stuff - $this->insert->values(array('foo' => 'bax'), Insert::VALUES_MERGE); - $this->insert->values(array('boom' => 'bam'), Insert::VALUES_MERGE); - $this->assertEquals(array('foo', 'boom'), $this->insert->getRawState('columns')); - $this->assertEquals(array('bax', 'bam'), $this->insert->getRawState('values')); - - $this->insert->values(array('foo' => 'bax')); - $this->assertEquals(array('foo'), $this->insert->getRawState('columns')); - $this->assertEquals(array('bax'), $this->insert->getRawState('values')); + $this->insert->values(['foo' => 'bax'], Insert::VALUES_MERGE); + $this->insert->values(['boom' => 'bam'], Insert::VALUES_MERGE); + $this->assertEquals(['foo', 'boom'], $this->insert->getRawState('columns')); + $this->assertEquals(['bax', 'bam'], $this->insert->getRawState('values')); + + $this->insert->values(['foo' => 'bax']); + $this->assertEquals(['foo'], $this->insert->getRawState('columns')); + $this->assertEquals(['bax'], $this->insert->getRawState('values')); } /** @@ -90,7 +90,7 @@ public function testValuesThrowsExceptionWhenNotArrayOrSelect() */ public function testValuesThrowsExceptionWhenSelectMergeOverArray() { - $this->insert->values(array('foo' => 'bar')); + $this->insert->values(['foo' => 'bar']); $this->setExpectedException( 'Zend\Db\Sql\Exception\InvalidArgumentException', @@ -110,7 +110,7 @@ public function testValuesThrowsExceptionWhenArrayMergeOverSelect() 'Zend\Db\Sql\Exception\InvalidArgumentException', 'An array of values cannot be provided with the merge flag when a Zend\Db\Sql\Select instance already exists as the value source' ); - $this->insert->values(array('foo' => 'bar'), Insert::VALUES_MERGE); + $this->insert->values(['foo' => 'bar'], Insert::VALUES_MERGE); } /** @@ -119,8 +119,8 @@ public function testValuesThrowsExceptionWhenArrayMergeOverSelect() */ public function testEmptyArrayValues() { - $this->insert->values(array()); - $this->assertEquals(array(), $this->readAttribute($this->insert, 'columns')); + $this->insert->values([]); + $this->assertEquals([], $this->readAttribute($this->insert, 'columns')); } /** @@ -131,17 +131,17 @@ public function testPrepareStatement() $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); $mockDriver->expects($this->any())->method('getPrepareType')->will($this->returnValue('positional')); $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?')); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); - $pContainer = new \Zend\Db\Adapter\ParameterContainer(array()); + $pContainer = new \Zend\Db\Adapter\ParameterContainer([]); $mockStatement->expects($this->any())->method('getParameterContainer')->will($this->returnValue($pContainer)); $mockStatement->expects($this->at(1)) ->method('setSql') ->with($this->equalTo('INSERT INTO "foo" ("bar", "boo") VALUES (?, NOW())')); $this->insert->into('foo') - ->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'))); + ->values(['bar' => 'baz', 'boo' => new Expression('NOW()')]); $this->insert->prepareStatement($mockAdapter, $mockStatement); @@ -150,17 +150,17 @@ public function testPrepareStatement() $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); $mockDriver->expects($this->any())->method('getPrepareType')->will($this->returnValue('positional')); $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?')); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); - $pContainer = new \Zend\Db\Adapter\ParameterContainer(array()); + $pContainer = new \Zend\Db\Adapter\ParameterContainer([]); $mockStatement->expects($this->any())->method('getParameterContainer')->will($this->returnValue($pContainer)); $mockStatement->expects($this->at(1)) ->method('setSql') ->with($this->equalTo('INSERT INTO "sch"."foo" ("bar", "boo") VALUES (?, NOW())')); $this->insert->into(new TableIdentifier('foo', 'sch')) - ->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'))); + ->values(['bar' => 'baz', 'boo' => new Expression('NOW()')]); $this->insert->prepareStatement($mockAdapter, $mockStatement); } @@ -173,15 +173,15 @@ public function testPrepareStatementWithSelect() $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); $mockDriver->expects($this->any())->method('getPrepareType')->will($this->returnValue('positional')); $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?')); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $mockStatement = new \Zend\Db\Adapter\StatementContainer(); $select = new Select('bar'); $this->insert ->into('foo') - ->columns(array('col1')) - ->select($select->where(array('x'=>5))) + ->columns(['col1']) + ->select($select->where(['x'=>5])) ->prepareStatement($mockAdapter, $mockStatement); $this->assertEquals( @@ -189,7 +189,7 @@ public function testPrepareStatementWithSelect() $mockStatement->getSql() ); $parameters = $mockStatement->getParameterContainer()->getNamedArray(); - $this->assertSame(array('subselect1where1'=>5), $parameters); + $this->assertSame(['subselect1where1'=>5], $parameters); } /** @@ -198,14 +198,14 @@ public function testPrepareStatementWithSelect() public function testGetSqlString() { $this->insert->into('foo') - ->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null)); + ->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); $this->assertEquals('INSERT INTO "foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $this->insert->getSqlString(new TrustingSql92Platform())); // with TableIdentifier $this->insert = new Insert; $this->insert->into(new TableIdentifier('foo', 'sch')) - ->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null)); + ->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); $this->assertEquals('INSERT INTO "sch"."foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $this->insert->getSqlString(new TrustingSql92Platform())); @@ -217,7 +217,7 @@ public function testGetSqlString() $this->assertEquals('INSERT INTO "foo" SELECT "bar".* FROM "bar"', $this->insert->getSqlString(new TrustingSql92Platform())); // with Select and columns - $this->insert->columns(array('col1', 'col2')); + $this->insert->columns(['col1', 'col2']); $this->assertEquals('INSERT INTO "foo" ("col1", "col2") SELECT "bar".* FROM "bar"', $this->insert->getSqlString(new TrustingSql92Platform())); } @@ -228,8 +228,8 @@ public function testGetSqlString() public function test__set() { $this->insert->foo = 'bar'; - $this->assertEquals(array('foo'), $this->insert->getRawState('columns')); - $this->assertEquals(array('bar'), $this->insert->getRawState('values')); + $this->assertEquals(['foo'], $this->insert->getRawState('columns')); + $this->assertEquals(['bar'], $this->insert->getRawState('values')); } /** @@ -238,11 +238,11 @@ public function test__set() public function test__unset() { $this->insert->foo = 'bar'; - $this->assertEquals(array('foo'), $this->insert->getRawState('columns')); - $this->assertEquals(array('bar'), $this->insert->getRawState('values')); + $this->assertEquals(['foo'], $this->insert->getRawState('columns')); + $this->assertEquals(['bar'], $this->insert->getRawState('values')); unset($this->insert->foo); - $this->assertEquals(array(), $this->insert->getRawState('columns')); - $this->assertEquals(array(), $this->insert->getRawState('values')); + $this->assertEquals([], $this->insert->getRawState('columns')); + $this->assertEquals([], $this->insert->getRawState('values')); } /** @@ -269,9 +269,9 @@ public function test__get() public function testValuesMerge() { $this->insert->into('foo') - ->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null)); + ->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); $this->insert->into('foo') - ->values(array('qux' => 100), Insert::VALUES_MERGE); + ->values(['qux' => 100], Insert::VALUES_MERGE); $this->assertEquals('INSERT INTO "foo" ("bar", "boo", "bam", "qux") VALUES (\'baz\', NOW(), NULL, \'100\')', $this->insert->getSqlString(new TrustingSql92Platform())); } @@ -286,17 +286,17 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); $mockDriver->expects($this->any())->method('getPrepareType')->will($this->returnValue('positional')); $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?')); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); - $pContainer = new \Zend\Db\Adapter\ParameterContainer(array()); + $pContainer = new \Zend\Db\Adapter\ParameterContainer([]); $mockStatement->expects($this->any())->method('getParameterContainer')->will($this->returnValue($pContainer)); $mockStatement->expects($this->at(1)) ->method('setSql') ->with($this->equalTo('REPLACE INTO "foo" ("bar", "boo") VALUES (?, NOW())')); $replace->into('foo') - ->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'))); + ->values(['bar' => 'baz', 'boo' => new Expression('NOW()')]); $replace->prepareStatement($mockAdapter, $mockStatement); @@ -306,17 +306,17 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); $mockDriver->expects($this->any())->method('getPrepareType')->will($this->returnValue('positional')); $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?')); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); - $pContainer = new \Zend\Db\Adapter\ParameterContainer(array()); + $pContainer = new \Zend\Db\Adapter\ParameterContainer([]); $mockStatement->expects($this->any())->method('getParameterContainer')->will($this->returnValue($pContainer)); $mockStatement->expects($this->at(1)) ->method('setSql') ->with($this->equalTo('REPLACE INTO "sch"."foo" ("bar", "boo") VALUES (?, NOW())')); $replace->into(new TableIdentifier('foo', 'sch')) - ->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'))); + ->values(['bar' => 'baz', 'boo' => new Expression('NOW()')]); $replace->prepareStatement($mockAdapter, $mockStatement); } @@ -328,14 +328,14 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlStr { $replace = new Replace(); $replace->into('foo') - ->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null)); + ->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); $this->assertEquals('REPLACE INTO "foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $replace->getSqlString(new TrustingSql92Platform())); // with TableIdentifier $replace = new Replace(); $replace->into(new TableIdentifier('foo', 'sch')) - ->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null)); + ->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); $this->assertEquals('REPLACE INTO "sch"."foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $replace->getSqlString(new TrustingSql92Platform())); } @@ -345,10 +345,10 @@ class Replace extends Insert { const SPECIFICATION_INSERT = 'replace'; - protected $specifications = array( + protected $specifications = [ self::SPECIFICATION_INSERT => 'REPLACE INTO %1$s (%2$s) VALUES (%3$s)', self::SPECIFICATION_SELECT => 'REPLACE INTO %1$s %2$s %3$s', - ); + ]; protected function processreplace(\Zend\Db\Adapter\Platform\PlatformInterface $platform, \Zend\Db\Adapter\Driver\DriverInterface $driver = null, \Zend\Db\Adapter\ParameterContainer $parameterContainer = null) { diff --git a/test/Sql/LiteralTest.php b/test/Sql/LiteralTest.php index 9d7d815cf7..79fa8fc569 100644 --- a/test/Sql/LiteralTest.php +++ b/test/Sql/LiteralTest.php @@ -28,17 +28,17 @@ public function testGetLiteral() public function testGetExpressionData() { $literal = new Literal('bar'); - $this->assertEquals(array(array('bar', array(), array())), $literal->getExpressionData()); + $this->assertEquals([['bar', [], []]], $literal->getExpressionData()); } public function testGetExpressionDataWillEscapePercent() { $expression = new Literal('X LIKE "foo%"'); - $this->assertEquals(array(array( + $this->assertEquals([[ 'X LIKE "foo%%"', - array(), - array() - )), + [], + [] + ]], $expression->getExpressionData() ); } diff --git a/test/Sql/Platform/IbmDb2/SelectDecoratorTest.php b/test/Sql/Platform/IbmDb2/SelectDecoratorTest.php index f1d8855acf..c6ad8ee798 100644 --- a/test/Sql/Platform/IbmDb2/SelectDecoratorTest.php +++ b/test/Sql/Platform/IbmDb2/SelectDecoratorTest.php @@ -33,10 +33,10 @@ public function testPrepareStatement(Select $select, $expectedPrepareSql, $expec $adapter = $this->getMock( 'Zend\Db\Adapter\Adapter', null, - array( + [ $driver, new IbmDb2Platform() - ) + ] ); $parameterContainer = new ParameterContainer; @@ -77,44 +77,44 @@ public function testGetSqlString(Select $select, $ignored0, $ignored1, $expected public function dataProvider() { $select0 = new Select; - $select0->from(array('x' => 'foo'))->limit(5); - $expectedParams0 = array( 'limit' => 5, 'offset' => 0 ); + $select0->from(['x' => 'foo'])->limit(5); + $expectedParams0 = [ 'limit' => 5, 'offset' => 0 ]; $expectedPrepareSql0 = 'SELECT * FROM ( SELECT "x".*, ROW_NUMBER() OVER () AS ZEND_DB_ROWNUM FROM "foo" "x" ) AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN ? AND ?'; $expectedSql0 = 'SELECT * FROM ( SELECT "x".*, ROW_NUMBER() OVER () AS ZEND_DB_ROWNUM FROM "foo" "x" ) AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN 0 AND 5'; $select1 = new Select; - $select1->from(array('x' => 'foo'))->limit(5)->offset(10); - $expectedParams1 = array( 'limit' => 15, 'offset' => 11 ); + $select1->from(['x' => 'foo'])->limit(5)->offset(10); + $expectedParams1 = [ 'limit' => 15, 'offset' => 11 ]; $expectedPrepareSql1 = 'SELECT * FROM ( SELECT "x".*, ROW_NUMBER() OVER () AS ZEND_DB_ROWNUM FROM "foo" "x" ) AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN ? AND ?'; $expectedSql1 = 'SELECT * FROM ( SELECT "x".*, ROW_NUMBER() OVER () AS ZEND_DB_ROWNUM FROM "foo" "x" ) AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN 11 AND 15'; $select2 = new Select; - $select2->columns(array(new Expression('DISTINCT(id) as id')))->from(array('x' => 'foo'))->limit(5)->offset(10); - $expectedParams2 = array( 'limit' => 15, 'offset' => 11); + $select2->columns([new Expression('DISTINCT(id) as id')])->from(['x' => 'foo'])->limit(5)->offset(10); + $expectedParams2 = [ 'limit' => 15, 'offset' => 11]; $expectedPrepareSql2 = 'SELECT DISTINCT(id) as id FROM ( SELECT DISTINCT(id) as id, DENSE_RANK() OVER () AS ZEND_DB_ROWNUM FROM "foo" "x" ) AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN ? AND ?'; $expectedSql2 = 'SELECT DISTINCT(id) as id FROM ( SELECT DISTINCT(id) as id, DENSE_RANK() OVER () AS ZEND_DB_ROWNUM FROM "foo" "x" ) AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN 11 AND 15'; $select3 = new Select; $where3 = new Where(); $where3->greaterThan('x.id', '10')->AND->lessThan('x.id', '31'); - $select3->from(array('x' => 'foo'))->where($where3)->limit(5)->offset(10); - $expectedParams3 = array( 'limit' => 15, 'offset' => 11, 'where1' => '10', 'where2' => '31' ); + $select3->from(['x' => 'foo'])->where($where3)->limit(5)->offset(10); + $expectedParams3 = [ 'limit' => 15, 'offset' => 11, 'where1' => '10', 'where2' => '31' ]; $expectedPrepareSql3 = 'SELECT * FROM ( SELECT "x".*, ROW_NUMBER() OVER () AS ZEND_DB_ROWNUM FROM "foo" "x" WHERE "x"."id" > ? AND "x"."id" < ? ) AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN ? AND ?'; $expectedSql3 = 'SELECT * FROM ( SELECT "x".*, ROW_NUMBER() OVER () AS ZEND_DB_ROWNUM FROM "foo" "x" WHERE "x"."id" > \'10\' AND "x"."id" < \'31\' ) AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN 11 AND 15'; $select4 = new Select; $where4 = $where3; - $select4->from(array('x' => 'foo'))->where($where4)->limit(5); - $expectedParams4 = array( 'limit' => 5, 'offset' => 0, 'where1' => 10, 'where2' => 31 ); + $select4->from(['x' => 'foo'])->where($where4)->limit(5); + $expectedParams4 = [ 'limit' => 5, 'offset' => 0, 'where1' => 10, 'where2' => 31 ]; $expectedPrepareSql4 = 'SELECT * FROM ( SELECT "x".*, ROW_NUMBER() OVER () AS ZEND_DB_ROWNUM FROM "foo" "x" WHERE "x"."id" > ? AND "x"."id" < ? ) AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN ? AND ?'; $expectedSql4 = 'SELECT * FROM ( SELECT "x".*, ROW_NUMBER() OVER () AS ZEND_DB_ROWNUM FROM "foo" "x" WHERE "x"."id" > \'10\' AND "x"."id" < \'31\' ) AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN 0 AND 5'; - return array( - array($select0, $expectedPrepareSql0, $expectedParams0, $expectedSql0), - array($select1, $expectedPrepareSql1, $expectedParams1, $expectedSql1), - array($select2, $expectedPrepareSql2, $expectedParams2, $expectedSql2), - array($select3, $expectedPrepareSql3, $expectedParams3, $expectedSql3), - array($select4, $expectedPrepareSql4, $expectedParams4, $expectedSql4), - ); + return [ + [$select0, $expectedPrepareSql0, $expectedParams0, $expectedSql0], + [$select1, $expectedPrepareSql1, $expectedParams1, $expectedSql1], + [$select2, $expectedPrepareSql2, $expectedParams2, $expectedSql2], + [$select3, $expectedPrepareSql3, $expectedParams3, $expectedSql3], + [$select4, $expectedPrepareSql4, $expectedParams4, $expectedSql4], + ]; } } diff --git a/test/Sql/Platform/Mysql/SelectDecoratorTest.php b/test/Sql/Platform/Mysql/SelectDecoratorTest.php index 7a0e9e2ebd..a55451db15 100644 --- a/test/Sql/Platform/Mysql/SelectDecoratorTest.php +++ b/test/Sql/Platform/Mysql/SelectDecoratorTest.php @@ -32,10 +32,10 @@ public function testPrepareStatement(Select $select, $expectedSql, $expectedPara $adapter = $this->getMock( 'Zend\Db\Adapter\Adapter', null, - array( + [ $driver, new MysqlPlatform() - ) + ] ); $parameterContainer = new ParameterContainer; @@ -74,27 +74,27 @@ public function dataProvider() $select0 = new Select; $select0->from('foo')->limit(5)->offset(10); $expectedPrepareSql0 = 'SELECT `foo`.* FROM `foo` LIMIT ? OFFSET ?'; - $expectedParams0 = array('offset' => 10, 'limit' => 5); + $expectedParams0 = ['offset' => 10, 'limit' => 5]; $expectedSql0 = 'SELECT `foo`.* FROM `foo` LIMIT 5 OFFSET 10'; // offset without limit $select1 = new Select; $select1->from('foo')->offset(10); $expectedPrepareSql1 = 'SELECT `foo`.* FROM `foo` LIMIT 18446744073709551615 OFFSET ?'; - $expectedParams1 = array('offset' => 10); + $expectedParams1 = ['offset' => 10]; $expectedSql1 = 'SELECT `foo`.* FROM `foo` LIMIT 18446744073709551615 OFFSET 10'; // offset and limit are not type casted when injected into parameter container $select2 = new Select; $select2->from('foo')->limit('5')->offset('10000000000000000000'); $expectedPrepareSql2 = 'SELECT `foo`.* FROM `foo` LIMIT ? OFFSET ?'; - $expectedParams2 = array('offset' => '10000000000000000000', 'limit' => '5'); + $expectedParams2 = ['offset' => '10000000000000000000', 'limit' => '5']; $expectedSql2 = 'SELECT `foo`.* FROM `foo` LIMIT 5 OFFSET 10000000000000000000'; - return array( - array($select0, $expectedPrepareSql0, $expectedParams0, $expectedSql0), - array($select1, $expectedPrepareSql1, $expectedParams1, $expectedSql1), - array($select2, $expectedPrepareSql2, $expectedParams2, $expectedSql2), - ); + return [ + [$select0, $expectedPrepareSql0, $expectedParams0, $expectedSql0], + [$select1, $expectedPrepareSql1, $expectedParams1, $expectedSql1], + [$select2, $expectedPrepareSql2, $expectedParams2, $expectedSql2], + ]; } } diff --git a/test/Sql/Platform/Oracle/SelectDecoratorTest.php b/test/Sql/Platform/Oracle/SelectDecoratorTest.php index 55b368e335..f044ee5141 100644 --- a/test/Sql/Platform/Oracle/SelectDecoratorTest.php +++ b/test/Sql/Platform/Oracle/SelectDecoratorTest.php @@ -31,10 +31,10 @@ public function testPrepareStatement(Select $select, $expectedSql, $expectedPara $adapter = $this->getMock( 'Zend\Db\Adapter\Adapter', null, - array( + [ $driver, new OraclePlatform() - ) + ] ); $parameterContainer = new ParameterContainer; @@ -74,19 +74,19 @@ public function testGetSqlString(Select $select, $ignored, $alsoIgnored, $expect public function dataProvider() { $select0 = new Select; - $select0->from(array('x' => 'foo')); + $select0->from(['x' => 'foo']); $expectedSql0 = 'SELECT "x".* FROM "foo" "x"'; $expectedFormatParamCount0 = 0; $select1a = new Select('test'); - $select1b = new Select(array('a' => $select1a)); - $select1 = new Select(array('b' => $select1b)); + $select1b = new Select(['a' => $select1a]); + $select1 = new Select(['b' => $select1b]); $expectedSql1 = 'SELECT "b".* FROM (SELECT "a".* FROM (SELECT "test".* FROM "test") "a") "b"'; $expectedFormatParamCount1 = 0; - return array( - array($select0, $expectedSql0, array(), $expectedSql0, $expectedFormatParamCount0), - array($select1, $expectedSql1, array(), $expectedSql1, $expectedFormatParamCount1), - ); + return [ + [$select0, $expectedSql0, [], $expectedSql0, $expectedFormatParamCount0], + [$select1, $expectedSql1, [], $expectedSql1, $expectedFormatParamCount1], + ]; } } diff --git a/test/Sql/Platform/SqlServer/SelectDecoratorTest.php b/test/Sql/Platform/SqlServer/SelectDecoratorTest.php index e9b498fa58..6c8c860b84 100644 --- a/test/Sql/Platform/SqlServer/SelectDecoratorTest.php +++ b/test/Sql/Platform/SqlServer/SelectDecoratorTest.php @@ -31,10 +31,10 @@ public function testPrepareStatement(Select $select, $expectedSql, $expectedPara $adapter = $this->getMock( 'Zend\Db\Adapter\Adapter', null, - array( + [ $driver, new SqlServerPlatform() - ) + ] ); $parameterContainer = new ParameterContainer; @@ -70,38 +70,38 @@ public function testGetSqlString(Select $select, $ignored, $alsoIgnored, $expect public function dataProvider() { $select0 = new Select; - $select0->from('foo')->columns(array('bar', 'baz'))->order('bar')->limit(5)->offset(10); + $select0->from('foo')->columns(['bar', 'baz'])->order('bar')->limit(5)->offset(10); $expectedPrepareSql0 = 'SELECT [bar], [baz] FROM ( SELECT [foo].[bar] AS [bar], [foo].[baz] AS [baz], ROW_NUMBER() OVER (ORDER BY [bar] ASC) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ?+1 AND ?+?'; - $expectedParams0 = array('offset' => 10, 'limit' => 5, 'offsetForSum' => 10); + $expectedParams0 = ['offset' => 10, 'limit' => 5, 'offsetForSum' => 10]; $expectedSql0 = 'SELECT [bar], [baz] FROM ( SELECT [foo].[bar] AS [bar], [foo].[baz] AS [baz], ROW_NUMBER() OVER (ORDER BY [bar] ASC) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN 10+1 AND 5+10'; $expectedFormatParamCount0 = 3; $select1 = new Select; - $select1->from('foo')->columns(array('bar', 'bam' => 'baz'))->limit(5)->offset(10); + $select1->from('foo')->columns(['bar', 'bam' => 'baz'])->limit(5)->offset(10); $expectedPrepareSql1 = 'SELECT [bar], [bam] FROM ( SELECT [foo].[bar] AS [bar], [foo].[baz] AS [bam], ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ?+1 AND ?+?'; - $expectedParams1 = array('offset' => 10, 'limit' => 5, 'offsetForSum' => 10); + $expectedParams1 = ['offset' => 10, 'limit' => 5, 'offsetForSum' => 10]; $expectedSql1 = 'SELECT [bar], [bam] FROM ( SELECT [foo].[bar] AS [bar], [foo].[baz] AS [bam], ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN 10+1 AND 5+10'; $expectedFormatParamCount1 = 3; $select2 = new Select; $select2->from('foo')->order('bar')->limit(5)->offset(10); $expectedPrepareSql2 = 'SELECT * FROM ( SELECT [foo].*, ROW_NUMBER() OVER (ORDER BY [bar] ASC) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ?+1 AND ?+?'; - $expectedParams2 = array('offset' => 10, 'limit' => 5, 'offsetForSum' => 10); + $expectedParams2 = ['offset' => 10, 'limit' => 5, 'offsetForSum' => 10]; $expectedSql2 = 'SELECT * FROM ( SELECT [foo].*, ROW_NUMBER() OVER (ORDER BY [bar] ASC) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN 10+1 AND 5+10'; $expectedFormatParamCount2 = 3; $select3 = new Select; $select3->from('foo'); $expectedPrepareSql3 = 'SELECT [foo].* FROM [foo]'; - $expectedParams3 = array(); + $expectedParams3 = []; $expectedSql3 = 'SELECT [foo].* FROM [foo]'; $expectedFormatParamCount3 = 0; - return array( - array($select0, $expectedPrepareSql0, $expectedParams0, $expectedSql0, $expectedFormatParamCount0), - array($select1, $expectedPrepareSql1, $expectedParams1, $expectedSql1, $expectedFormatParamCount1), - array($select2, $expectedPrepareSql2, $expectedParams2, $expectedSql2, $expectedFormatParamCount2), - array($select3, $expectedPrepareSql3, $expectedParams3, $expectedSql3, $expectedFormatParamCount3) - ); + return [ + [$select0, $expectedPrepareSql0, $expectedParams0, $expectedSql0, $expectedFormatParamCount0], + [$select1, $expectedPrepareSql1, $expectedParams1, $expectedSql1, $expectedFormatParamCount1], + [$select2, $expectedPrepareSql2, $expectedParams2, $expectedSql2, $expectedFormatParamCount2], + [$select3, $expectedPrepareSql3, $expectedParams3, $expectedSql3, $expectedFormatParamCount3] + ]; } } diff --git a/test/Sql/Predicate/BetweenTest.php b/test/Sql/Predicate/BetweenTest.php index b3a68353c6..50cba97634 100644 --- a/test/Sql/Predicate/BetweenTest.php +++ b/test/Sql/Predicate/BetweenTest.php @@ -119,21 +119,21 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAnd $this->between->setIdentifier('foo.bar') ->setMinValue(10) ->setMaxValue(19); - $expected = array(array( + $expected = [[ $this->between->getSpecification(), - array('foo.bar', 10, 19), - array(Between::TYPE_IDENTIFIER, Between::TYPE_VALUE, Between::TYPE_VALUE), - )); + ['foo.bar', 10, 19], + [Between::TYPE_IDENTIFIER, Between::TYPE_VALUE, Between::TYPE_VALUE], + ]]; $this->assertEquals($expected, $this->between->getExpressionData()); - $this->between->setIdentifier(array(10=>Between::TYPE_VALUE)) - ->setMinValue(array('foo.bar'=>Between::TYPE_IDENTIFIER)) - ->setMaxValue(array('foo.baz'=>Between::TYPE_IDENTIFIER)); - $expected = array(array( + $this->between->setIdentifier([10=>Between::TYPE_VALUE]) + ->setMinValue(['foo.bar'=>Between::TYPE_IDENTIFIER]) + ->setMaxValue(['foo.baz'=>Between::TYPE_IDENTIFIER]); + $expected = [[ $this->between->getSpecification(), - array(10, 'foo.bar', 'foo.baz'), - array(Between::TYPE_VALUE, Between::TYPE_IDENTIFIER, Between::TYPE_IDENTIFIER), - )); + [10, 'foo.bar', 'foo.baz'], + [Between::TYPE_VALUE, Between::TYPE_IDENTIFIER, Between::TYPE_IDENTIFIER], + ]]; $this->assertEquals($expected, $this->between->getExpressionData()); } } diff --git a/test/Sql/Predicate/ExpressionTest.php b/test/Sql/Predicate/ExpressionTest.php index ed9ba9f0cc..95a5b10e28 100644 --- a/test/Sql/Predicate/ExpressionTest.php +++ b/test/Sql/Predicate/ExpressionTest.php @@ -29,7 +29,7 @@ public function testCanPassLiteralAndSingleScalarParameterToConstructor() { $expression = new Expression('foo.bar = ?', 'bar'); $this->assertEquals('foo.bar = ?', $expression->getExpression()); - $this->assertEquals(array('bar'), $expression->getParameters()); + $this->assertEquals(['bar'], $expression->getParameters()); } /** @@ -38,7 +38,7 @@ public function testCanPassLiteralAndSingleScalarParameterToConstructor() public function testCanPassNoParameterToConstructor() { $expression = new Expression('foo.bar'); - $this->assertEquals(array(), $expression->getParameters()); + $this->assertEquals([], $expression->getParameters()); } /** @@ -47,7 +47,7 @@ public function testCanPassNoParameterToConstructor() public function testCanPassSingleNullParameterToConstructor() { $expression = new Expression('?', null); - $this->assertEquals(array(null), $expression->getParameters()); + $this->assertEquals([null], $expression->getParameters()); } /** @@ -56,7 +56,7 @@ public function testCanPassSingleNullParameterToConstructor() public function testCanPassSingleZeroParameterValueToConstructor() { $predicate = new Expression('?', 0); - $this->assertEquals(array(0), $predicate->getParameters()); + $this->assertEquals([0], $predicate->getParameters()); } /** @@ -66,7 +66,7 @@ public function testCanPassSinglePredicateParameterToConstructor() { $predicate = new IsNull('foo.baz'); $expression = new Expression('?', $predicate); - $this->assertEquals(array($predicate), $expression->getParameters()); + $this->assertEquals([$predicate], $expression->getParameters()); } /** @@ -75,7 +75,7 @@ public function testCanPassSinglePredicateParameterToConstructor() public function testCanPassMultiScalarParametersToConstructor() { $expression = new Expression('? OR ?', 'foo', 'bar'); - $this->assertEquals(array('foo', 'bar'), $expression->getParameters()); + $this->assertEquals(['foo', 'bar'], $expression->getParameters()); } /** @@ -84,7 +84,7 @@ public function testCanPassMultiScalarParametersToConstructor() public function testCanPassMultiNullParametersToConstructor() { $expression = new Expression('? OR ?', null, null); - $this->assertEquals(array(null, null), $expression->getParameters()); + $this->assertEquals([null, null], $expression->getParameters()); } /** @@ -94,7 +94,7 @@ public function testCanPassMultiPredicateParametersToConstructor() { $predicate = new IsNull('foo.baz'); $expression = new Expression('? OR ?', $predicate, $predicate); - $this->assertEquals(array($predicate, $predicate), $expression->getParameters()); + $this->assertEquals([$predicate, $predicate], $expression->getParameters()); } /** @@ -102,8 +102,8 @@ public function testCanPassMultiPredicateParametersToConstructor() */ public function testCanPassArrayOfOneScalarParameterToConstructor() { - $expression = new Expression('?', array('foo')); - $this->assertEquals(array('foo'), $expression->getParameters()); + $expression = new Expression('?', ['foo']); + $this->assertEquals(['foo'], $expression->getParameters()); } /** @@ -111,8 +111,8 @@ public function testCanPassArrayOfOneScalarParameterToConstructor() */ public function testCanPassArrayOfMultiScalarsParameterToConstructor() { - $expression = new Expression('? OR ?', array('foo', 'bar')); - $this->assertEquals(array('foo', 'bar'), $expression->getParameters()); + $expression = new Expression('? OR ?', ['foo', 'bar']); + $this->assertEquals(['foo', 'bar'], $expression->getParameters()); } /** @@ -120,8 +120,8 @@ public function testCanPassArrayOfMultiScalarsParameterToConstructor() */ public function testCanPassArrayOfOneNullParameterToConstructor() { - $expression = new Expression('?', array(null)); - $this->assertEquals(array(null), $expression->getParameters()); + $expression = new Expression('?', [null]); + $this->assertEquals([null], $expression->getParameters()); } /** @@ -129,8 +129,8 @@ public function testCanPassArrayOfOneNullParameterToConstructor() */ public function testCanPassArrayOfMultiNullsParameterToConstructor() { - $expression = new Expression('? OR ?', array(null, null)); - $this->assertEquals(array(null, null), $expression->getParameters()); + $expression = new Expression('? OR ?', [null, null]); + $this->assertEquals([null, null], $expression->getParameters()); } /** @@ -139,8 +139,8 @@ public function testCanPassArrayOfMultiNullsParameterToConstructor() public function testCanPassArrayOfOnePredicateParameterToConstructor() { $predicate = new IsNull('foo.baz'); - $expression = new Expression('?', array($predicate)); - $this->assertEquals(array($predicate), $expression->getParameters()); + $expression = new Expression('?', [$predicate]); + $this->assertEquals([$predicate], $expression->getParameters()); } /** @@ -149,8 +149,8 @@ public function testCanPassArrayOfOnePredicateParameterToConstructor() public function testCanPassArrayOfMultiPredicatesParameterToConstructor() { $predicate = new IsNull('foo.baz'); - $expression = new Expression('? OR ?', array($predicate, $predicate)); - $this->assertEquals(array($predicate, $predicate), $expression->getParameters()); + $expression = new Expression('? OR ?', [$predicate, $predicate]); + $this->assertEquals([$predicate, $predicate], $expression->getParameters()); } public function testLiteralIsMutable() @@ -163,20 +163,20 @@ public function testLiteralIsMutable() public function testParameterIsMutable() { $expression = new Expression(); - $expression->setParameters(array('foo', 'bar')); - $this->assertEquals(array('foo', 'bar'), $expression->getParameters()); + $expression->setParameters(['foo', 'bar']); + $this->assertEquals(['foo', 'bar'], $expression->getParameters()); } public function testRetrievingWherePartsReturnsSpecificationArrayOfLiteralAndParametersAndArrayOfTypes() { $expression = new Expression(); $expression->setExpression('foo.bar = ? AND id != ?') - ->setParameters(array('foo', 'bar')); - $expected = array(array( + ->setParameters(['foo', 'bar']); + $expected = [[ 'foo.bar = %s AND id != %s', - array('foo', 'bar'), - array(Expression::TYPE_VALUE, Expression::TYPE_VALUE), - )); + ['foo', 'bar'], + [Expression::TYPE_VALUE, Expression::TYPE_VALUE], + ]]; $test = $expression->getExpressionData(); $this->assertEquals($expected, $test, var_export($test, 1)); } diff --git a/test/Sql/Predicate/InTest.php b/test/Sql/Predicate/InTest.php index 3e7e0d8855..f53344e22d 100644 --- a/test/Sql/Predicate/InTest.php +++ b/test/Sql/Predicate/InTest.php @@ -24,9 +24,9 @@ public function testEmptyConstructorYieldsNullIdentifierAndValueSet() public function testCanPassIdentifierAndValueSetToConstructor() { - $in = new In('foo.bar', array(1, 2)); + $in = new In('foo.bar', [1, 2]); $this->assertEquals('foo.bar', $in->getIdentifier()); - $this->assertEquals(array(1, 2), $in->getValueSet()); + $this->assertEquals([1, 2], $in->getValueSet()); } public function testIdentifierIsMutable() @@ -39,33 +39,33 @@ public function testIdentifierIsMutable() public function testValueSetIsMutable() { $in = new In(); - $in->setValueSet(array(1, 2)); - $this->assertEquals(array(1, 2), $in->getValueSet()); + $in->setValueSet([1, 2]); + $this->assertEquals([1, 2], $in->getValueSet()); } public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes() { $in = new In(); $in->setIdentifier('foo.bar') - ->setValueSet(array(1, 2, 3)); - $expected = array(array( + ->setValueSet([1, 2, 3]); + $expected = [[ '%s IN (%s, %s, %s)', - array('foo.bar', 1, 2, 3), - array(In::TYPE_IDENTIFIER, In::TYPE_VALUE, In::TYPE_VALUE, In::TYPE_VALUE), - )); + ['foo.bar', 1, 2, 3], + [In::TYPE_IDENTIFIER, In::TYPE_VALUE, In::TYPE_VALUE, In::TYPE_VALUE], + ]]; $this->assertEquals($expected, $in->getExpressionData()); $in->setIdentifier('foo.bar') - ->setValueSet(array( - array(1=>In::TYPE_LITERAL), - array(2=>In::TYPE_VALUE), - array(3=>In::TYPE_LITERAL), - )); - $expected = array(array( + ->setValueSet([ + [1=>In::TYPE_LITERAL], + [2=>In::TYPE_VALUE], + [3=>In::TYPE_LITERAL], + ]); + $expected = [[ '%s IN (%s, %s, %s)', - array('foo.bar', 1, 2, 3), - array(In::TYPE_IDENTIFIER, In::TYPE_LITERAL, In::TYPE_VALUE, In::TYPE_LITERAL), - )); + ['foo.bar', 1, 2, 3], + [In::TYPE_IDENTIFIER, In::TYPE_LITERAL, In::TYPE_VALUE, In::TYPE_LITERAL], + ]]; $qqq = $in->getExpressionData(); $this->assertEquals($expected, $in->getExpressionData()); } @@ -74,11 +74,11 @@ public function testGetExpressionDataWithSubselect() { $select = new Select; $in = new In('foo', $select); - $expected = array(array( + $expected = [[ '%s IN %s', - array('foo', $select), - array($in::TYPE_IDENTIFIER, $in::TYPE_VALUE) - )); + ['foo', $select], + [$in::TYPE_IDENTIFIER, $in::TYPE_VALUE] + ]]; $this->assertEquals($expected, $in->getExpressionData()); } @@ -86,23 +86,23 @@ public function testGetExpressionDataWithSubselectAndIdentifier() { $select = new Select; $in = new In('foo', $select); - $expected = array(array( + $expected = [[ '%s IN %s', - array('foo', $select), - array($in::TYPE_IDENTIFIER, $in::TYPE_VALUE) - )); + ['foo', $select], + [$in::TYPE_IDENTIFIER, $in::TYPE_VALUE] + ]]; $this->assertEquals($expected, $in->getExpressionData()); } public function testGetExpressionDataWithSubselectAndArrayIdentifier() { $select = new Select; - $in = new In(array('foo', 'bar'), $select); - $expected = array(array( + $in = new In(['foo', 'bar'], $select); + $expected = [[ '(%s, %s) IN %s', - array('foo', 'bar', $select), - array($in::TYPE_IDENTIFIER, $in::TYPE_IDENTIFIER, $in::TYPE_VALUE) - )); + ['foo', 'bar', $select], + [$in::TYPE_IDENTIFIER, $in::TYPE_IDENTIFIER, $in::TYPE_VALUE] + ]]; $this->assertEquals($expected, $in->getExpressionData()); } } diff --git a/test/Sql/Predicate/IsNullTest.php b/test/Sql/Predicate/IsNullTest.php index d90cf44471..7a02ecd714 100644 --- a/test/Sql/Predicate/IsNullTest.php +++ b/test/Sql/Predicate/IsNullTest.php @@ -51,11 +51,11 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAnd { $isNotNull = new IsNotNull(); $isNotNull->setIdentifier('foo.bar'); - $expected = array(array( + $expected = [[ $isNotNull->getSpecification(), - array('foo.bar'), - array(IsNotNull::TYPE_IDENTIFIER), - )); + ['foo.bar'], + [IsNotNull::TYPE_IDENTIFIER], + ]]; $this->assertEquals($expected, $isNotNull->getExpressionData()); } } diff --git a/test/Sql/Predicate/LikeTest.php b/test/Sql/Predicate/LikeTest.php index f3fe4c9757..5209b993af 100644 --- a/test/Sql/Predicate/LikeTest.php +++ b/test/Sql/Predicate/LikeTest.php @@ -42,17 +42,17 @@ public function testGetExpressionData() { $like = new Like('bar', 'Foo%'); $this->assertEquals( - array( - array('%1$s LIKE %2$s', array('bar', 'Foo%'), array($like::TYPE_IDENTIFIER, $like::TYPE_VALUE)) - ), + [ + ['%1$s LIKE %2$s', ['bar', 'Foo%'], [$like::TYPE_IDENTIFIER, $like::TYPE_VALUE]] + ], $like->getExpressionData() ); - $like = new Like(array('Foo%'=>$like::TYPE_VALUE), array('bar'=>$like::TYPE_IDENTIFIER)); + $like = new Like(['Foo%'=>$like::TYPE_VALUE], ['bar'=>$like::TYPE_IDENTIFIER]); $this->assertEquals( - array( - array('%1$s LIKE %2$s', array('Foo%', 'bar'), array($like::TYPE_VALUE, $like::TYPE_IDENTIFIER)) - ), + [ + ['%1$s LIKE %2$s', ['Foo%', 'bar'], [$like::TYPE_VALUE, $like::TYPE_IDENTIFIER]] + ], $like->getExpressionData() ); } diff --git a/test/Sql/Predicate/LiteralTest.php b/test/Sql/Predicate/LiteralTest.php index b42788756a..50a2140b82 100644 --- a/test/Sql/Predicate/LiteralTest.php +++ b/test/Sql/Predicate/LiteralTest.php @@ -28,6 +28,6 @@ public function testGetLiteral() public function testGetExpressionData() { $literal = new Literal('bar'); - $this->assertEquals(array(array('bar', array(), array())), $literal->getExpressionData()); + $this->assertEquals([['bar', [], []]], $literal->getExpressionData()); } } diff --git a/test/Sql/Predicate/NotInTest.php b/test/Sql/Predicate/NotInTest.php index 4319efe04f..3d23b3d054 100644 --- a/test/Sql/Predicate/NotInTest.php +++ b/test/Sql/Predicate/NotInTest.php @@ -19,12 +19,12 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAnd { $in = new NotIn(); $in->setIdentifier('foo.bar') - ->setValueSet(array(1, 2, 3)); - $expected = array(array( + ->setValueSet([1, 2, 3]); + $expected = [[ '%s NOT IN (%s, %s, %s)', - array('foo.bar', 1, 2, 3), - array(NotIn::TYPE_IDENTIFIER, NotIn::TYPE_VALUE, NotIn::TYPE_VALUE, NotIn::TYPE_VALUE), - )); + ['foo.bar', 1, 2, 3], + [NotIn::TYPE_IDENTIFIER, NotIn::TYPE_VALUE, NotIn::TYPE_VALUE, NotIn::TYPE_VALUE], + ]]; $this->assertEquals($expected, $in->getExpressionData()); } @@ -32,11 +32,11 @@ public function testGetExpressionDataWithSubselect() { $select = new Select; $in = new NotIn('foo', $select); - $expected = array(array( + $expected = [[ '%s NOT IN %s', - array('foo', $select), - array($in::TYPE_IDENTIFIER, $in::TYPE_VALUE) - )); + ['foo', $select], + [$in::TYPE_IDENTIFIER, $in::TYPE_VALUE] + ]]; $this->assertEquals($expected, $in->getExpressionData()); } @@ -44,23 +44,23 @@ public function testGetExpressionDataWithSubselectAndIdentifier() { $select = new Select; $in = new NotIn('foo', $select); - $expected = array(array( + $expected = [[ '%s NOT IN %s', - array('foo', $select), - array($in::TYPE_IDENTIFIER, $in::TYPE_VALUE) - )); + ['foo', $select], + [$in::TYPE_IDENTIFIER, $in::TYPE_VALUE] + ]]; $this->assertEquals($expected, $in->getExpressionData()); } public function testGetExpressionDataWithSubselectAndArrayIdentifier() { $select = new Select; - $in = new NotIn(array('foo', 'bar'), $select); - $expected = array(array( + $in = new NotIn(['foo', 'bar'], $select); + $expected = [[ '(%s, %s) NOT IN %s', - array('foo', 'bar', $select), - array($in::TYPE_IDENTIFIER, $in::TYPE_IDENTIFIER, $in::TYPE_VALUE) - )); + ['foo', 'bar', $select], + [$in::TYPE_IDENTIFIER, $in::TYPE_IDENTIFIER, $in::TYPE_VALUE] + ]]; $this->assertEquals($expected, $in->getExpressionData()); } } diff --git a/test/Sql/Predicate/NotLikeTest.php b/test/Sql/Predicate/NotLikeTest.php index 9451b21b79..f4744e42c9 100644 --- a/test/Sql/Predicate/NotLikeTest.php +++ b/test/Sql/Predicate/NotLikeTest.php @@ -42,13 +42,13 @@ public function testGetExpressionData() { $notLike = new NotLike('bar', 'Foo%'); $this->assertEquals( - array( - array( + [ + [ '%1$s NOT LIKE %2$s', - array('bar', 'Foo%'), - array($notLike::TYPE_IDENTIFIER, $notLike::TYPE_VALUE) - ) - ), + ['bar', 'Foo%'], + [$notLike::TYPE_IDENTIFIER, $notLike::TYPE_VALUE] + ] + ], $notLike->getExpressionData() ); } diff --git a/test/Sql/Predicate/OperatorTest.php b/test/Sql/Predicate/OperatorTest.php index ddfe0ea24b..7c0245647a 100644 --- a/test/Sql/Predicate/OperatorTest.php +++ b/test/Sql/Predicate/OperatorTest.php @@ -38,10 +38,10 @@ public function testCanPassAllValuesToConstructor() $this->assertEquals(Operator::TYPE_VALUE, $operator->getLeftType()); $this->assertEquals(Operator::TYPE_IDENTIFIER, $operator->getRightType()); - $operator = new Operator(array('bar'=>Operator::TYPE_VALUE), '>=', array('foo.bar'=>Operator::TYPE_IDENTIFIER)); + $operator = new Operator(['bar'=>Operator::TYPE_VALUE], '>=', ['foo.bar'=>Operator::TYPE_IDENTIFIER]); $this->assertEquals(Operator::OP_GTE, $operator->getOperator()); - $this->assertEquals(array('bar'=>Operator::TYPE_VALUE), $operator->getLeft()); - $this->assertEquals(array('foo.bar'=>Operator::TYPE_IDENTIFIER), $operator->getRight()); + $this->assertEquals(['bar'=>Operator::TYPE_VALUE], $operator->getLeft()); + $this->assertEquals(['foo.bar'=>Operator::TYPE_IDENTIFIER], $operator->getRight()); $this->assertEquals(Operator::TYPE_VALUE, $operator->getLeftType()); $this->assertEquals(Operator::TYPE_IDENTIFIER, $operator->getRightType()); @@ -92,11 +92,11 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfLeftAndRightA ->setRight('foo.bar') ->setLeftType(Operator::TYPE_VALUE) ->setRightType(Operator::TYPE_IDENTIFIER); - $expected = array(array( + $expected = [[ '%s >= %s', - array('foo', 'foo.bar'), - array(Operator::TYPE_VALUE, Operator::TYPE_IDENTIFIER), - )); + ['foo', 'foo.bar'], + [Operator::TYPE_VALUE, Operator::TYPE_IDENTIFIER], + ]]; $test = $operator->getExpressionData(); $this->assertEquals($expected, $test, var_export($test, 1)); } diff --git a/test/Sql/Predicate/PredicateSetTest.php b/test/Sql/Predicate/PredicateSetTest.php index 2dab121a7b..03f39705ff 100644 --- a/test/Sql/Predicate/PredicateSetTest.php +++ b/test/Sql/Predicate/PredicateSetTest.php @@ -35,10 +35,10 @@ public function testCombinationIsAndByDefault() public function testCanPassPredicatesAndDefaultCombinationViaConstructor() { $predicateSet = new PredicateSet(); - $set = new PredicateSet(array( + $set = new PredicateSet([ new IsNull('foo'), new IsNull('bar'), - ), 'OR'); + ], 'OR'); $parts = $set->getExpressionData(); $this->assertEquals(3, count($parts)); $this->assertContains('OR', $parts[1]); @@ -93,12 +93,12 @@ public function testAddPredicates() $predicateSet = new PredicateSet(); $predicateSet->addPredicates('x = y'); - $predicateSet->addPredicates(array('foo > ?' => 5)); - $predicateSet->addPredicates(array('id' => 2)); - $predicateSet->addPredicates(array('a = b'), PredicateSet::OP_OR); - $predicateSet->addPredicates(array('c1' => null)); - $predicateSet->addPredicates(array('c2' => array(1, 2, 3))); - $predicateSet->addPredicates(array(new \Zend\Db\Sql\Predicate\IsNotNull('c3'))); + $predicateSet->addPredicates(['foo > ?' => 5]); + $predicateSet->addPredicates(['id' => 2]); + $predicateSet->addPredicates(['a = b'], PredicateSet::OP_OR); + $predicateSet->addPredicates(['c1' => null]); + $predicateSet->addPredicates(['c2' => [1, 2, 3]]); + $predicateSet->addPredicates([new \Zend\Db\Sql\Predicate\IsNotNull('c3')]); $predicates = $this->readAttribute($predicateSet, 'predicates'); $this->assertEquals('AND', $predicates[0][0]); diff --git a/test/Sql/Predicate/PredicateTest.php b/test/Sql/Predicate/PredicateTest.php index 9ce2233796..a3186f01da 100644 --- a/test/Sql/Predicate/PredicateTest.php +++ b/test/Sql/Predicate/PredicateTest.php @@ -23,7 +23,7 @@ public function testEqualToCreatesOperatorPredicate() $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%s = %s', $parts[0]); - $this->assertContains(array('foo.bar', 'bar'), $parts[0]); + $this->assertContains(['foo.bar', 'bar'], $parts[0]); } public function testNotEqualToCreatesOperatorPredicate() @@ -33,7 +33,7 @@ public function testNotEqualToCreatesOperatorPredicate() $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%s != %s', $parts[0]); - $this->assertContains(array('foo.bar', 'bar'), $parts[0]); + $this->assertContains(['foo.bar', 'bar'], $parts[0]); } @@ -44,7 +44,7 @@ public function testLessThanCreatesOperatorPredicate() $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%s < %s', $parts[0]); - $this->assertContains(array('foo.bar', 'bar'), $parts[0]); + $this->assertContains(['foo.bar', 'bar'], $parts[0]); } public function testGreaterThanCreatesOperatorPredicate() @@ -54,7 +54,7 @@ public function testGreaterThanCreatesOperatorPredicate() $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%s > %s', $parts[0]); - $this->assertContains(array('foo.bar', 'bar'), $parts[0]); + $this->assertContains(['foo.bar', 'bar'], $parts[0]); } public function testLessThanOrEqualToCreatesOperatorPredicate() @@ -64,7 +64,7 @@ public function testLessThanOrEqualToCreatesOperatorPredicate() $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%s <= %s', $parts[0]); - $this->assertContains(array('foo.bar', 'bar'), $parts[0]); + $this->assertContains(['foo.bar', 'bar'], $parts[0]); } public function testGreaterThanOrEqualToCreatesOperatorPredicate() @@ -74,7 +74,7 @@ public function testGreaterThanOrEqualToCreatesOperatorPredicate() $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%s >= %s', $parts[0]); - $this->assertContains(array('foo.bar', 'bar'), $parts[0]); + $this->assertContains(['foo.bar', 'bar'], $parts[0]); } public function testLikeCreatesLikePredicate() @@ -84,7 +84,7 @@ public function testLikeCreatesLikePredicate() $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%1$s LIKE %2$s', $parts[0]); - $this->assertContains(array('foo.bar', 'bar%'), $parts[0]); + $this->assertContains(['foo.bar', 'bar%'], $parts[0]); } public function testNotLikeCreatesLikePredicate() @@ -94,7 +94,7 @@ public function testNotLikeCreatesLikePredicate() $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%1$s NOT LIKE %2$s', $parts[0]); - $this->assertContains(array('foo.bar', 'bar%'), $parts[0]); + $this->assertContains(['foo.bar', 'bar%'], $parts[0]); } public function testLiteralCreatesLiteralPredicate() @@ -104,7 +104,7 @@ public function testLiteralCreatesLiteralPredicate() $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('foo.bar = %s', $parts[0]); - $this->assertContains(array('bar'), $parts[0]); + $this->assertContains(['bar'], $parts[0]); } public function testIsNullCreatesIsNullPredicate() @@ -114,7 +114,7 @@ public function testIsNullCreatesIsNullPredicate() $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%1$s IS NULL', $parts[0]); - $this->assertContains(array('foo.bar'), $parts[0]); + $this->assertContains(['foo.bar'], $parts[0]); } public function testIsNotNullCreatesIsNotNullPredicate() @@ -124,27 +124,27 @@ public function testIsNotNullCreatesIsNotNullPredicate() $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%1$s IS NOT NULL', $parts[0]); - $this->assertContains(array('foo.bar'), $parts[0]); + $this->assertContains(['foo.bar'], $parts[0]); } public function testInCreatesInPredicate() { $predicate = new Predicate(); - $predicate->in('foo.bar', array('foo', 'bar')); + $predicate->in('foo.bar', ['foo', 'bar']); $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%s IN (%s, %s)', $parts[0]); - $this->assertContains(array('foo.bar', 'foo', 'bar'), $parts[0]); + $this->assertContains(['foo.bar', 'foo', 'bar'], $parts[0]); } public function testNotInCreatesNotInPredicate() { $predicate = new Predicate(); - $predicate->notIn('foo.bar', array('foo', 'bar')); + $predicate->notIn('foo.bar', ['foo', 'bar']); $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%s NOT IN (%s, %s)', $parts[0]); - $this->assertContains(array('foo.bar', 'foo', 'bar'), $parts[0]); + $this->assertContains(['foo.bar', 'foo', 'bar'], $parts[0]); } public function testBetweenCreatesBetweenPredicate() @@ -154,7 +154,7 @@ public function testBetweenCreatesBetweenPredicate() $parts = $predicate->getExpressionData(); $this->assertEquals(1, count($parts)); $this->assertContains('%1$s BETWEEN %2$s AND %3$s', $parts[0]); - $this->assertContains(array('foo.bar', 1, 10), $parts[0]); + $this->assertContains(['foo.bar', 1, 10], $parts[0]); } public function testCanChainPredicateFactoriesBetweenOperators() @@ -169,17 +169,17 @@ public function testCanChainPredicateFactoriesBetweenOperators() $this->assertEquals(5, count($parts)); $this->assertContains('%1$s IS NULL', $parts[0]); - $this->assertContains(array('foo.bar'), $parts[0]); + $this->assertContains(['foo.bar'], $parts[0]); $this->assertEquals(' OR ', $parts[1]); $this->assertContains('%1$s IS NOT NULL', $parts[2]); - $this->assertContains(array('bar.baz'), $parts[2]); + $this->assertContains(['bar.baz'], $parts[2]); $this->assertEquals(' AND ', $parts[3]); $this->assertContains('%s = %s', $parts[4]); - $this->assertContains(array('baz.bat', 'foo'), $parts[4]); + $this->assertContains(['baz.bat', 'foo'], $parts[4]); } public function testCanNestPredicates() @@ -196,19 +196,19 @@ public function testCanNestPredicates() $this->assertEquals(7, count($parts)); $this->assertContains('%1$s IS NULL', $parts[0]); - $this->assertContains(array('foo.bar'), $parts[0]); + $this->assertContains(['foo.bar'], $parts[0]); $this->assertEquals(' AND ', $parts[1]); $this->assertEquals('(', $parts[2]); $this->assertContains('%1$s IS NOT NULL', $parts[3]); - $this->assertContains(array('bar.baz'), $parts[3]); + $this->assertContains(['bar.baz'], $parts[3]); $this->assertEquals(' AND ', $parts[4]); $this->assertContains('%s = %s', $parts[5]); - $this->assertContains(array('baz.bat', 'foo'), $parts[5]); + $this->assertContains(['baz.bat', 'foo'], $parts[5]); $this->assertEquals(')', $parts[6]); } @@ -224,7 +224,7 @@ public function testExpression() $this->assertSame($predicate, $predicate->expression('foo = ?', 0)); // with parameter $this->assertEquals( - array(array('foo = %s', array(0), array(Expression::TYPE_VALUE))), + [['foo = %s', [0], [Expression::TYPE_VALUE]]], $predicate->getExpressionData() ); } @@ -240,7 +240,7 @@ public function testLiteral() $this->assertSame($predicate, $predicate->literal('foo = bar')); // with parameter $this->assertEquals( - array(array('foo = bar', array(), array())), + [['foo = bar', [], []]], $predicate->getExpressionData() ); @@ -249,7 +249,7 @@ public function testLiteral() $predicate->expression('foo = ?', 'bar'); // with parameter $this->assertEquals( - array(array('foo = %s', array('bar'), array(Expression::TYPE_VALUE))), + [['foo = %s', ['bar'], [Expression::TYPE_VALUE]]], $predicate->getExpressionData() ); @@ -258,7 +258,7 @@ public function testLiteral() $predicate->expression('foo = ?', 0); // with parameter $this->assertEquals( - array(array('foo = %s', array(0), array(Expression::TYPE_VALUE))), + [['foo = %s', [0], [Expression::TYPE_VALUE]]], $predicate->getExpressionData() ); } diff --git a/test/Sql/SelectTest.php b/test/Sql/SelectTest.php index 18327b53d5..1a21b26ab8 100644 --- a/test/Sql/SelectTest.php +++ b/test/Sql/SelectTest.php @@ -98,7 +98,7 @@ public function testQuantifierParameterExpressionInterface() public function testColumns() { $select = new Select; - $return = $select->columns(array('foo', 'bar')); + $return = $select->columns(['foo', 'bar']); $this->assertSame($select, $return); return $select; @@ -124,7 +124,7 @@ public function testIsTableReadOnly() */ public function testGetRawStateViaColumns(Select $select) { - $this->assertEquals(array('foo', 'bar'), $select->getRawState('columns')); + $this->assertEquals(['foo', 'bar'], $select->getRawState('columns')); } /** @@ -148,7 +148,7 @@ public function testBadJoin() { $select = new Select; $this->setExpectedException('Zend\Db\Sql\Exception\InvalidArgumentException', "expects 'foo' as"); - $select->join(array('foo'), 'x = y', Select::SQL_STAR, Select::JOIN_INNER); + $select->join(['foo'], 'x = y', Select::SQL_STAR, Select::JOIN_INNER); } /** @@ -157,13 +157,13 @@ public function testBadJoin() */ public function testBadJoinName() { - $mockExpression = $this->getMock('Zend\Db\Sql\ExpressionInterface', array(), array('bar')); + $mockExpression = $this->getMock('Zend\Db\Sql\ExpressionInterface', [], ['bar']); $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?')); $parameterContainer = new ParameterContainer(); $select = new Select; - $select->join(array('foo' => $mockExpression), 'x = y', Select::SQL_STAR, Select::JOIN_INNER); + $select->join(['foo' => $mockExpression], 'x = y', Select::SQL_STAR, Select::JOIN_INNER); $sr = new ReflectionObject($select); @@ -173,7 +173,7 @@ public function testBadJoinName() $this->setExpectedException('Zend\Db\Sql\Exception\InvalidArgumentException'); - $mr->invokeArgs($select, array(new Sql92, $mockDriver, $parameterContainer)); + $mr->invokeArgs($select, [new Sql92, $mockDriver, $parameterContainer]); } /** @@ -184,12 +184,12 @@ public function testBadJoinName() public function testGetRawStateViaJoin(Select $select) { $this->assertEquals( - array(array( + [[ 'name' => 'foo', 'on' => 'x = y', - 'columns' => array(Select::SQL_STAR), + 'columns' => [Select::SQL_STAR], 'type' => Select::JOIN_INNER - )), + ]], $select->getRawState('joins') ); } @@ -237,7 +237,7 @@ public function testWhereArgument1IsString() public function testWhereArgument1IsAssociativeArrayContainingReplacementCharacter() { $select = new Select; - $select->where(array('foo > ?' => 5)); + $select->where(['foo > ?' => 5]); /** @var $where Where */ $where = $select->getRawState('where'); @@ -246,7 +246,7 @@ public function testWhereArgument1IsAssociativeArrayContainingReplacementCharact $this->assertInstanceOf('Zend\Db\Sql\Predicate\Expression', $predicates[0][1]); $this->assertEquals(Where::OP_AND, $predicates[0][0]); $this->assertEquals('foo > ?', $predicates[0][1]->getExpression()); - $this->assertEquals(array(5), $predicates[0][1]->getParameters()); + $this->assertEquals([5], $predicates[0][1]->getParameters()); } /** @@ -256,7 +256,7 @@ public function testWhereArgument1IsAssociativeArrayContainingReplacementCharact public function testWhereArgument1IsAssociativeArrayNotContainingReplacementCharacter() { $select = new Select; - $select->where(array('name' => 'Ralph', 'age' => 33)); + $select->where(['name' => 'Ralph', 'age' => 33]); /** @var $where Where */ $where = $select->getRawState('where'); @@ -274,7 +274,7 @@ public function testWhereArgument1IsAssociativeArrayNotContainingReplacementChar $this->assertEquals(33, $predicates[1][1]->getRight()); $select = new Select; - $select->where(array('x = y')); + $select->where(['x = y']); $where = $select->getRawState('where'); $predicates = $where->getPredicates(); @@ -288,10 +288,10 @@ public function testWhereArgument1IsAssociativeArrayNotContainingReplacementChar public function testWhereArgument1IsAssociativeArrayIsPredicate() { $select = new Select; - $where = array( + $where = [ 'name' => new Predicate\Literal("name = 'Ralph'"), 'age' => new Predicate\Expression('age = ?', 33), - ); + ]; $this->setExpectedException('Zend\Db\Sql\Exception\InvalidArgumentException', 'Using Predicate must not use string keys'); $select->where($where); } @@ -303,7 +303,7 @@ public function testWhereArgument1IsAssociativeArrayIsPredicate() public function testWhereArgument1IsIndexedArray() { $select = new Select; - $select->where(array('name = "Ralph"')); + $select->where(['name = "Ralph"']); /** @var $where Where */ $where = $select->getRawState('where'); @@ -322,7 +322,7 @@ public function testWhereArgument1IsIndexedArray() public function testWhereArgument1IsIndexedArrayArgument2IsOr() { $select = new Select; - $select->where(array('name = "Ralph"'), Where::OP_OR); + $select->where(['name = "Ralph"'], Where::OP_OR); /** @var $where Where */ $where = $select->getRawState('where'); @@ -356,10 +356,10 @@ public function testWhereArgument1IsClosure() public function testWhereArgument1IsPredicate() { $select = new Select; - $predicate = new Predicate\Predicate(array( + $predicate = new Predicate\Predicate([ new Predicate\Expression('name = ?', 'Ralph'), new Predicate\Expression('age = ?', 33), - )); + ]); $select->where($predicate); /** @var $where Where */ @@ -389,16 +389,16 @@ public function testOrder() $select = new Select; $return = $select->order('id DESC'); $this->assertSame($select, $return); // test fluent interface - $this->assertEquals(array('id DESC'), $select->getRawState('order')); + $this->assertEquals(['id DESC'], $select->getRawState('order')); $select = new Select; $select->order('id DESC') ->order('name ASC, age DESC'); - $this->assertEquals(array('id DESC', 'name ASC', 'age DESC'), $select->getRawState('order')); + $this->assertEquals(['id DESC', 'name ASC', 'age DESC'], $select->getRawState('order')); $select = new Select; - $select->order(array('name ASC', 'age DESC')); - $this->assertEquals(array('name ASC', 'age DESC'), $select->getRawState('order')); + $select->order(['name ASC', 'age DESC']); + $this->assertEquals(['name ASC', 'age DESC'], $select->getRawState('order')); $select = new Select; $select->order(new Expression('RAND()')); @@ -406,20 +406,20 @@ public function testOrder() $method = $sr->getMethod('processOrder'); $method->setAccessible(true); $this->assertEquals( - array(array(array('RAND()'))), - $method->invokeArgs($select, array(new TrustingSql92Platform())) + [[['RAND()']]], + $method->invokeArgs($select, [new TrustingSql92Platform()]) ); $select = new Select; $select->order( - $this->getMock('Zend\Db\Sql\Predicate\Operator', null, array('rating', '<', '10')) + $this->getMock('Zend\Db\Sql\Predicate\Operator', null, ['rating', '<', '10']) ); $sr = new ReflectionObject($select); $method = $sr->getMethod('processOrder'); $method->setAccessible(true); $this->assertEquals( - array(array(array('"rating" < \'10\''))), - $method->invokeArgs($select, array(new TrustingSql92Platform())) + [[['"rating" < \'10\'']]], + $method->invokeArgs($select, [new TrustingSql92Platform()]) ); } @@ -495,7 +495,7 @@ public function testOffsetExceptionOnInvalidParameter() public function testGroup() { $select = new Select; - $return = $select->group(array('col1', 'col2')); + $return = $select->group(['col1', 'col2']); $this->assertSame($select, $return); return $return; @@ -509,7 +509,7 @@ public function testGroup() public function testGetRawStateViaGroup(Select $select) { $this->assertEquals( - array('col1', 'col2'), + ['col1', 'col2'], $select->getRawState('group') ); } @@ -521,7 +521,7 @@ public function testGetRawStateViaGroup(Select $select) public function testHaving() { $select = new Select; - $return = $select->having(array('x = ?' => 5)); + $return = $select->having(['x = ?' => 5]); $this->assertSame($select, $return); return $return; @@ -595,14 +595,14 @@ public function testReset() $this->assertNull($select->getRawState(Select::TABLE)); // columns - $select->columns(array('foo')); - $this->assertEquals(array('foo'), $select->getRawState(Select::COLUMNS)); + $select->columns(['foo']); + $this->assertEquals(['foo'], $select->getRawState(Select::COLUMNS)); $select->reset(Select::COLUMNS); $this->assertEmpty($select->getRawState(Select::COLUMNS)); // joins $select->join('foo', 'id = boo'); - $this->assertEquals(array(array('name' => 'foo', 'on' => 'id = boo', 'columns' => array('*'), 'type' => 'inner')), $select->getRawState(Select::JOINS)); + $this->assertEquals([['name' => 'foo', 'on' => 'id = boo', 'columns' => ['*'], 'type' => 'inner']], $select->getRawState(Select::JOINS)); $select->reset(Select::JOINS); $this->assertEmpty($select->getRawState(Select::JOINS)); @@ -616,8 +616,8 @@ public function testReset() $this->assertNotSame($where1, $where2); // group - $select->group(array('foo')); - $this->assertEquals(array('foo'), $select->getRawState(Select::GROUP)); + $select->group(['foo']); + $this->assertEquals(['foo'], $select->getRawState(Select::GROUP)); $select->reset(Select::GROUP); $this->assertEmpty($select->getRawState(Select::GROUP)); @@ -644,7 +644,7 @@ public function testReset() // order $select->order('foo asc'); - $this->assertEquals(array('foo asc'), $select->getRawState(Select::ORDER)); + $this->assertEquals(['foo asc'], $select->getRawState(Select::ORDER)); $select->reset(Select::ORDER); $this->assertEmpty($select->getRawState(Select::ORDER)); } @@ -662,7 +662,7 @@ function ($name) use ($useNamedParameters) { return (($useNamedParameters) ? ':' . $name : '?'); } )); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $parameterContainer = new ParameterContainer(); @@ -755,7 +755,7 @@ public function testProcessMethods(Select $select, $unused, $unused2, $unused3, foreach ($internalTests as $method => $expected) { $mr = $sr->getMethod($method); $mr->setAccessible(true); - $return = $mr->invokeArgs($select, array(new Sql92, $mockDriver, $parameterContainer)); + $return = $mr->invokeArgs($select, [new Sql92, $mockDriver, $parameterContainer]); $this->assertEquals($expected, $return); } } @@ -767,365 +767,365 @@ public function providerData() $select0->from('foo'); $sqlPrep0 = // same $sqlStr0 = 'SELECT "foo".* FROM "foo"'; - $internalTests0 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"') - ); + $internalTests0 = [ + 'processSelect' => [[['"foo".*']], '"foo"'] + ]; // table as TableIdentifier $select1 = new Select; $select1->from(new TableIdentifier('foo', 'bar')); $sqlPrep1 = // same $sqlStr1 = 'SELECT "bar"."foo".* FROM "bar"."foo"'; - $internalTests1 = array( - 'processSelect' => array(array(array('"bar"."foo".*')), '"bar"."foo"') - ); + $internalTests1 = [ + 'processSelect' => [[['"bar"."foo".*']], '"bar"."foo"'] + ]; // table with alias $select2 = new Select; - $select2->from(array('f' => 'foo')); + $select2->from(['f' => 'foo']); $sqlPrep2 = // same $sqlStr2 = 'SELECT "f".* FROM "foo" AS "f"'; - $internalTests2 = array( - 'processSelect' => array(array(array('"f".*')), '"foo" AS "f"') - ); + $internalTests2 = [ + 'processSelect' => [[['"f".*']], '"foo" AS "f"'] + ]; // table with alias with table as TableIdentifier $select3 = new Select; - $select3->from(array('f' => new TableIdentifier('foo'))); + $select3->from(['f' => new TableIdentifier('foo')]); $sqlPrep3 = // same $sqlStr3 = 'SELECT "f".* FROM "foo" AS "f"'; - $internalTests3 = array( - 'processSelect' => array(array(array('"f".*')), '"foo" AS "f"') - ); + $internalTests3 = [ + 'processSelect' => [[['"f".*']], '"foo" AS "f"'] + ]; // columns $select4 = new Select; - $select4->from('foo')->columns(array('bar', 'baz')); + $select4->from('foo')->columns(['bar', 'baz']); $sqlPrep4 = // same $sqlStr4 = 'SELECT "foo"."bar" AS "bar", "foo"."baz" AS "baz" FROM "foo"'; - $internalTests4 = array( - 'processSelect' => array(array(array('"foo"."bar"', '"bar"'), array('"foo"."baz"', '"baz"')), '"foo"') - ); + $internalTests4 = [ + 'processSelect' => [[['"foo"."bar"', '"bar"'], ['"foo"."baz"', '"baz"']], '"foo"'] + ]; // columns with AS associative array $select5 = new Select; - $select5->from('foo')->columns(array('bar' => 'baz')); + $select5->from('foo')->columns(['bar' => 'baz']); $sqlPrep5 = // same $sqlStr5 = 'SELECT "foo"."baz" AS "bar" FROM "foo"'; - $internalTests5 = array( - 'processSelect' => array(array(array('"foo"."baz"', '"bar"')), '"foo"') - ); + $internalTests5 = [ + 'processSelect' => [[['"foo"."baz"', '"bar"']], '"foo"'] + ]; // columns with AS associative array mixed $select6 = new Select; - $select6->from('foo')->columns(array('bar' => 'baz', 'bam')); + $select6->from('foo')->columns(['bar' => 'baz', 'bam']); $sqlPrep6 = // same $sqlStr6 = 'SELECT "foo"."baz" AS "bar", "foo"."bam" AS "bam" FROM "foo"'; - $internalTests6 = array( - 'processSelect' => array(array(array('"foo"."baz"', '"bar"'), array('"foo"."bam"', '"bam"') ), '"foo"') - ); + $internalTests6 = [ + 'processSelect' => [[['"foo"."baz"', '"bar"'], ['"foo"."bam"', '"bam"'] ], '"foo"'] + ]; // columns where value is Expression, with AS $select7 = new Select; - $select7->from('foo')->columns(array('bar' => new Expression('COUNT(some_column)'))); + $select7->from('foo')->columns(['bar' => new Expression('COUNT(some_column)')]); $sqlPrep7 = // same $sqlStr7 = 'SELECT COUNT(some_column) AS "bar" FROM "foo"'; - $internalTests7 = array( - 'processSelect' => array(array(array('COUNT(some_column)', '"bar"')), '"foo"') - ); + $internalTests7 = [ + 'processSelect' => [[['COUNT(some_column)', '"bar"']], '"foo"'] + ]; // columns where value is Expression $select8 = new Select; - $select8->from('foo')->columns(array(new Expression('COUNT(some_column) AS bar'))); + $select8->from('foo')->columns([new Expression('COUNT(some_column) AS bar')]); $sqlPrep8 = // same $sqlStr8 = 'SELECT COUNT(some_column) AS bar FROM "foo"'; - $internalTests8 = array( - 'processSelect' => array(array(array('COUNT(some_column) AS bar')), '"foo"') - ); + $internalTests8 = [ + 'processSelect' => [[['COUNT(some_column) AS bar']], '"foo"'] + ]; // columns where value is Expression with parameters $select9 = new Select; $select9->from('foo')->columns( - array( + [ new Expression( '(COUNT(?) + ?) AS ?', - array('some_column', 5, 'bar'), - array(Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_IDENTIFIER) + ['some_column', 5, 'bar'], + [Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_IDENTIFIER] ) - ) + ] ); $sqlPrep9 = 'SELECT (COUNT("some_column") + ?) AS "bar" FROM "foo"'; $sqlStr9 = 'SELECT (COUNT("some_column") + \'5\') AS "bar" FROM "foo"'; - $params9 = array('column1' => 5); - $internalTests9 = array( - 'processSelect' => array(array(array('(COUNT("some_column") + ?) AS "bar"')), '"foo"') - ); + $params9 = ['column1' => 5]; + $internalTests9 = [ + 'processSelect' => [[['(COUNT("some_column") + ?) AS "bar"']], '"foo"'] + ]; // joins (plain) $select10 = new Select; $select10->from('foo')->join('zac', 'm = n'); $sqlPrep10 = // same $sqlStr10 = 'SELECT "foo".*, "zac".* FROM "foo" INNER JOIN "zac" ON "m" = "n"'; - $internalTests10 = array( - 'processSelect' => array(array(array('"foo".*'), array('"zac".*')), '"foo"'), - 'processJoins' => array(array(array('INNER', '"zac"', '"m" = "n"'))) - ); + $internalTests10 = [ + 'processSelect' => [[['"foo".*'], ['"zac".*']], '"foo"'], + 'processJoins' => [[['INNER', '"zac"', '"m" = "n"']]] + ]; // join with columns $select11 = new Select; - $select11->from('foo')->join('zac', 'm = n', array('bar', 'baz')); + $select11->from('foo')->join('zac', 'm = n', ['bar', 'baz']); $sqlPrep11 = // same $sqlStr11 = 'SELECT "foo".*, "zac"."bar" AS "bar", "zac"."baz" AS "baz" FROM "foo" INNER JOIN "zac" ON "m" = "n"'; - $internalTests11 = array( - 'processSelect' => array(array(array('"foo".*'), array('"zac"."bar"', '"bar"'), array('"zac"."baz"', '"baz"')), '"foo"'), - 'processJoins' => array(array(array('INNER', '"zac"', '"m" = "n"'))) - ); + $internalTests11 = [ + 'processSelect' => [[['"foo".*'], ['"zac"."bar"', '"bar"'], ['"zac"."baz"', '"baz"']], '"foo"'], + 'processJoins' => [[['INNER', '"zac"', '"m" = "n"']]] + ]; // join with alternate type $select12 = new Select; - $select12->from('foo')->join('zac', 'm = n', array('bar', 'baz'), Select::JOIN_OUTER); + $select12->from('foo')->join('zac', 'm = n', ['bar', 'baz'], Select::JOIN_OUTER); $sqlPrep12 = // same $sqlStr12 = 'SELECT "foo".*, "zac"."bar" AS "bar", "zac"."baz" AS "baz" FROM "foo" OUTER JOIN "zac" ON "m" = "n"'; - $internalTests12 = array( - 'processSelect' => array(array(array('"foo".*'), array('"zac"."bar"', '"bar"'), array('"zac"."baz"', '"baz"')), '"foo"'), - 'processJoins' => array(array(array('OUTER', '"zac"', '"m" = "n"'))) - ); + $internalTests12 = [ + 'processSelect' => [[['"foo".*'], ['"zac"."bar"', '"bar"'], ['"zac"."baz"', '"baz"']], '"foo"'], + 'processJoins' => [[['OUTER', '"zac"', '"m" = "n"']]] + ]; // join with column aliases $select13 = new Select; - $select13->from('foo')->join('zac', 'm = n', array('BAR' => 'bar', 'BAZ' => 'baz')); + $select13->from('foo')->join('zac', 'm = n', ['BAR' => 'bar', 'BAZ' => 'baz']); $sqlPrep13 = // same $sqlStr13 = 'SELECT "foo".*, "zac"."bar" AS "BAR", "zac"."baz" AS "BAZ" FROM "foo" INNER JOIN "zac" ON "m" = "n"'; - $internalTests13 = array( - 'processSelect' => array(array(array('"foo".*'), array('"zac"."bar"', '"BAR"'), array('"zac"."baz"', '"BAZ"')), '"foo"'), - 'processJoins' => array(array(array('INNER', '"zac"', '"m" = "n"'))) - ); + $internalTests13 = [ + 'processSelect' => [[['"foo".*'], ['"zac"."bar"', '"BAR"'], ['"zac"."baz"', '"BAZ"']], '"foo"'], + 'processJoins' => [[['INNER', '"zac"', '"m" = "n"']]] + ]; // join with table aliases $select14 = new Select; - $select14->from('foo')->join(array('b' => 'bar'), 'b.foo_id = foo.foo_id'); + $select14->from('foo')->join(['b' => 'bar'], 'b.foo_id = foo.foo_id'); $sqlPrep14 = // same $sqlStr14 = 'SELECT "foo".*, "b".* FROM "foo" INNER JOIN "bar" AS "b" ON "b"."foo_id" = "foo"."foo_id"'; - $internalTests14 = array( - 'processSelect' => array(array(array('"foo".*'), array('"b".*')), '"foo"'), - 'processJoins' => array(array(array('INNER', '"bar" AS "b"', '"b"."foo_id" = "foo"."foo_id"'))) - ); + $internalTests14 = [ + 'processSelect' => [[['"foo".*'], ['"b".*']], '"foo"'], + 'processJoins' => [[['INNER', '"bar" AS "b"', '"b"."foo_id" = "foo"."foo_id"']]] + ]; // where (simple string) $select15 = new Select; $select15->from('foo')->where('x = 5'); $sqlPrep15 = // same $sqlStr15 = 'SELECT "foo".* FROM "foo" WHERE x = 5'; - $internalTests15 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processWhere' => array('x = 5') - ); + $internalTests15 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processWhere' => ['x = 5'] + ]; // where (returning parameters) $select16 = new Select; - $select16->from('foo')->where(array('x = ?' => 5)); + $select16->from('foo')->where(['x = ?' => 5]); $sqlPrep16 = 'SELECT "foo".* FROM "foo" WHERE x = ?'; $sqlStr16 = 'SELECT "foo".* FROM "foo" WHERE x = \'5\''; - $params16 = array('where1' => 5); - $internalTests16 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processWhere' => array('x = ?') - ); + $params16 = ['where1' => 5]; + $internalTests16 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processWhere' => ['x = ?'] + ]; // group $select17 = new Select; - $select17->from('foo')->group(array('col1', 'col2')); + $select17->from('foo')->group(['col1', 'col2']); $sqlPrep17 = // same $sqlStr17 = 'SELECT "foo".* FROM "foo" GROUP BY "col1", "col2"'; - $internalTests17 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processGroup' => array(array('"col1"', '"col2"')) - ); + $internalTests17 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processGroup' => [['"col1"', '"col2"']] + ]; $select18 = new Select; $select18->from('foo')->group('col1')->group('col2'); $sqlPrep18 = // same $sqlStr18 = 'SELECT "foo".* FROM "foo" GROUP BY "col1", "col2"'; - $internalTests18 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processGroup' => array(array('"col1"', '"col2"')) - ); + $internalTests18 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processGroup' => [['"col1"', '"col2"']] + ]; $select19 = new Select; - $select19->from('foo')->group(new Expression('DAY(?)', array('col1'), array(Expression::TYPE_IDENTIFIER))); + $select19->from('foo')->group(new Expression('DAY(?)', ['col1'], [Expression::TYPE_IDENTIFIER])); $sqlPrep19 = // same $sqlStr19 = 'SELECT "foo".* FROM "foo" GROUP BY DAY("col1")'; - $internalTests19 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processGroup' => array(array('DAY("col1")')) - ); + $internalTests19 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processGroup' => [['DAY("col1")']] + ]; // having (simple string) $select20 = new Select; $select20->from('foo')->having('x = 5'); $sqlPrep20 = // same $sqlStr20 = 'SELECT "foo".* FROM "foo" HAVING x = 5'; - $internalTests20 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processHaving' => array('x = 5') - ); + $internalTests20 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processHaving' => ['x = 5'] + ]; // having (returning parameters) $select21 = new Select; - $select21->from('foo')->having(array('x = ?' => 5)); + $select21->from('foo')->having(['x = ?' => 5]); $sqlPrep21 = 'SELECT "foo".* FROM "foo" HAVING x = ?'; $sqlStr21 = 'SELECT "foo".* FROM "foo" HAVING x = \'5\''; - $params21 = array('having1' => 5); - $internalTests21 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processHaving' => array('x = ?') - ); + $params21 = ['having1' => 5]; + $internalTests21 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processHaving' => ['x = ?'] + ]; // order $select22 = new Select; $select22->from('foo')->order('c1'); $sqlPrep22 = // $sqlStr22 = 'SELECT "foo".* FROM "foo" ORDER BY "c1" ASC'; - $internalTests22 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processOrder' => array(array(array('"c1"', Select::ORDER_ASCENDING))) - ); + $internalTests22 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processOrder' => [[['"c1"', Select::ORDER_ASCENDING]]] + ]; $select23 = new Select; - $select23->from('foo')->order(array('c1', 'c2')); + $select23->from('foo')->order(['c1', 'c2']); $sqlPrep23 = // same $sqlStr23 = 'SELECT "foo".* FROM "foo" ORDER BY "c1" ASC, "c2" ASC'; - $internalTests23 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processOrder' => array(array(array('"c1"', Select::ORDER_ASCENDING), array('"c2"', Select::ORDER_ASCENDING))) - ); + $internalTests23 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processOrder' => [[['"c1"', Select::ORDER_ASCENDING], ['"c2"', Select::ORDER_ASCENDING]]] + ]; $select24 = new Select; - $select24->from('foo')->order(array('c1' => 'DESC', 'c2' => 'Asc')); // notice partially lower case ASC + $select24->from('foo')->order(['c1' => 'DESC', 'c2' => 'Asc']); // notice partially lower case ASC $sqlPrep24 = // same $sqlStr24 = 'SELECT "foo".* FROM "foo" ORDER BY "c1" DESC, "c2" ASC'; - $internalTests24 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processOrder' => array(array(array('"c1"', Select::ORDER_DESCENDING), array('"c2"', Select::ORDER_ASCENDING))) - ); + $internalTests24 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processOrder' => [[['"c1"', Select::ORDER_DESCENDING], ['"c2"', Select::ORDER_ASCENDING]]] + ]; $select25 = new Select; - $select25->from('foo')->order(array('c1' => 'asc'))->order('c2 desc'); // notice partially lower case ASC + $select25->from('foo')->order(['c1' => 'asc'])->order('c2 desc'); // notice partially lower case ASC $sqlPrep25 = // same $sqlStr25 = 'SELECT "foo".* FROM "foo" ORDER BY "c1" ASC, "c2" DESC'; - $internalTests25 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processOrder' => array(array(array('"c1"', Select::ORDER_ASCENDING), array('"c2"', Select::ORDER_DESCENDING))) - ); + $internalTests25 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processOrder' => [[['"c1"', Select::ORDER_ASCENDING], ['"c2"', Select::ORDER_DESCENDING]]] + ]; // limit $select26 = new Select; $select26->from('foo')->limit(5); $sqlPrep26 = 'SELECT "foo".* FROM "foo" LIMIT ?'; $sqlStr26 = 'SELECT "foo".* FROM "foo" LIMIT \'5\''; - $params26 = array('limit' => 5); - $internalTests26 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processLimit' => array('?') - ); + $params26 = ['limit' => 5]; + $internalTests26 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processLimit' => ['?'] + ]; // limit with offset $select27 = new Select; $select27->from('foo')->limit(5)->offset(10); $sqlPrep27 = 'SELECT "foo".* FROM "foo" LIMIT ? OFFSET ?'; $sqlStr27 = 'SELECT "foo".* FROM "foo" LIMIT \'5\' OFFSET \'10\''; - $params27 = array('limit' => 5, 'offset' => 10); - $internalTests27 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processLimit' => array('?'), - 'processOffset' => array('?') - ); + $params27 = ['limit' => 5, 'offset' => 10]; + $internalTests27 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processLimit' => ['?'], + 'processOffset' => ['?'] + ]; // joins with a few keywords in the on clause $select28 = new Select; $select28->from('foo')->join('zac', '(m = n AND c.x) BETWEEN x AND y.z OR (c.x < y.z AND c.x <= y.z AND c.x > y.z AND c.x >= y.z)'); $sqlPrep28 = // same $sqlStr28 = 'SELECT "foo".*, "zac".* FROM "foo" INNER JOIN "zac" ON ("m" = "n" AND "c"."x") BETWEEN "x" AND "y"."z" OR ("c"."x" < "y"."z" AND "c"."x" <= "y"."z" AND "c"."x" > "y"."z" AND "c"."x" >= "y"."z")'; - $internalTests28 = array( - 'processSelect' => array(array(array('"foo".*'), array('"zac".*')), '"foo"'), - 'processJoins' => array(array(array('INNER', '"zac"', '("m" = "n" AND "c"."x") BETWEEN "x" AND "y"."z" OR ("c"."x" < "y"."z" AND "c"."x" <= "y"."z" AND "c"."x" > "y"."z" AND "c"."x" >= "y"."z")'))) - ); + $internalTests28 = [ + 'processSelect' => [[['"foo".*'], ['"zac".*']], '"foo"'], + 'processJoins' => [[['INNER', '"zac"', '("m" = "n" AND "c"."x") BETWEEN "x" AND "y"."z" OR ("c"."x" < "y"."z" AND "c"."x" <= "y"."z" AND "c"."x" > "y"."z" AND "c"."x" >= "y"."z")']]] + ]; // order with compound name $select29 = new Select; $select29->from('foo')->order('c1.d2'); $sqlPrep29 = // $sqlStr29 = 'SELECT "foo".* FROM "foo" ORDER BY "c1"."d2" ASC'; - $internalTests29 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processOrder' => array(array(array('"c1"."d2"', Select::ORDER_ASCENDING))) - ); + $internalTests29 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processOrder' => [[['"c1"."d2"', Select::ORDER_ASCENDING]]] + ]; // group with compound name $select30 = new Select; $select30->from('foo')->group('c1.d2'); $sqlPrep30 = // same $sqlStr30 = 'SELECT "foo".* FROM "foo" GROUP BY "c1"."d2"'; - $internalTests30 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processGroup' => array(array('"c1"."d2"')) - ); + $internalTests30 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processGroup' => [['"c1"."d2"']] + ]; // join with expression in ON part $select31 = new Select; $select31->from('foo')->join('zac', new Expression('(m = n AND c.x) BETWEEN x AND y.z')); $sqlPrep31 = // same $sqlStr31 = 'SELECT "foo".*, "zac".* FROM "foo" INNER JOIN "zac" ON (m = n AND c.x) BETWEEN x AND y.z'; - $internalTests31 = array( - 'processSelect' => array(array(array('"foo".*'), array('"zac".*')), '"foo"'), - 'processJoins' => array(array(array('INNER', '"zac"', '(m = n AND c.x) BETWEEN x AND y.z'))) - ); + $internalTests31 = [ + 'processSelect' => [[['"foo".*'], ['"zac".*']], '"foo"'], + 'processJoins' => [[['INNER', '"zac"', '(m = n AND c.x) BETWEEN x AND y.z']]] + ]; $select32subselect = new Select; $select32subselect->from('bar')->where->like('y', '%Foo%'); $select32 = new Select; - $select32->from(array('x' => $select32subselect)); + $select32->from(['x' => $select32subselect]); $sqlPrep32 = 'SELECT "x".* FROM (SELECT "bar".* FROM "bar" WHERE "y" LIKE ?) AS "x"'; $sqlStr32 = 'SELECT "x".* FROM (SELECT "bar".* FROM "bar" WHERE "y" LIKE \'%Foo%\') AS "x"'; - $internalTests32 = array( - 'processSelect' => array(array(array('"x".*')), '(SELECT "bar".* FROM "bar" WHERE "y" LIKE ?) AS "x"'), - ); + $internalTests32 = [ + 'processSelect' => [[['"x".*']], '(SELECT "bar".* FROM "bar" WHERE "y" LIKE ?) AS "x"'], + ]; $select33 = new Select; - $select33->from('table')->columns(array('*'))->where(array( + $select33->from('table')->columns(['*'])->where([ 'c1' => null, - 'c2' => array(1, 2, 3), + 'c2' => [1, 2, 3], new \Zend\Db\Sql\Predicate\IsNotNull('c3') - )); + ]); $sqlPrep33 = 'SELECT "table".* FROM "table" WHERE "c1" IS NULL AND "c2" IN (?, ?, ?) AND "c3" IS NOT NULL'; $sqlStr33 = 'SELECT "table".* FROM "table" WHERE "c1" IS NULL AND "c2" IN (\'1\', \'2\', \'3\') AND "c3" IS NOT NULL'; - $internalTests33 = array( - 'processSelect' => array(array(array('"table".*')), '"table"'), - 'processWhere' => array('"c1" IS NULL AND "c2" IN (?, ?, ?) AND "c3" IS NOT NULL') - ); + $internalTests33 = [ + 'processSelect' => [[['"table".*']], '"table"'], + 'processWhere' => ['"c1" IS NULL AND "c2" IN (?, ?, ?) AND "c3" IS NOT NULL'] + ]; // @author Demian Katz $select34 = new Select; - $select34->from('table')->order(array( - new Expression('isnull(?) DESC', array('name'), array(Expression::TYPE_IDENTIFIER)), + $select34->from('table')->order([ + new Expression('isnull(?) DESC', ['name'], [Expression::TYPE_IDENTIFIER]), 'name' - )); + ]); $sqlPrep34 = 'SELECT "table".* FROM "table" ORDER BY isnull("name") DESC, "name" ASC'; $sqlStr34 = 'SELECT "table".* FROM "table" ORDER BY isnull("name") DESC, "name" ASC'; - $internalTests34 = array( - 'processOrder' => array(array(array('isnull("name") DESC'), array('"name"', Select::ORDER_ASCENDING))) - ); + $internalTests34 = [ + 'processOrder' => [[['isnull("name") DESC'], ['"name"', Select::ORDER_ASCENDING]]] + ]; // join with Expression object in COLUMNS part (ZF2-514) // @co-author Koen Pieters (kpieters) $select35 = new Select; - $select35->from('foo')->columns(array())->join('bar', 'm = n', array('thecount' => new Expression("COUNT(*)"))); + $select35->from('foo')->columns([])->join('bar', 'm = n', ['thecount' => new Expression("COUNT(*)")]); $sqlPrep35 = // same $sqlStr35 = 'SELECT COUNT(*) AS "thecount" FROM "foo" INNER JOIN "bar" ON "m" = "n"'; - $internalTests35 = array( - 'processSelect' => array(array(array('COUNT(*)', '"thecount"')), '"foo"'), - 'processJoins' => array(array(array('INNER', '"bar"', '"m" = "n"'))) - ); + $internalTests35 = [ + 'processSelect' => [[['COUNT(*)', '"thecount"']], '"foo"'], + 'processJoins' => [[['INNER', '"bar"', '"m" = "n"']]] + ]; // multiple joins with expressions // reported by @jdolieslager @@ -1133,17 +1133,17 @@ public function providerData() $select36->from('foo') ->join('tableA', new Predicate\Operator('id', '=', 1)) ->join('tableB', new Predicate\Operator('id', '=', 2)) - ->join('tableC', new Predicate\PredicateSet(array( + ->join('tableC', new Predicate\PredicateSet([ new Predicate\Operator('id', '=', 3), new Predicate\Operator('number', '>', 20) - ))); + ])); $sqlPrep36 = 'SELECT "foo".*, "tableA".*, "tableB".*, "tableC".* FROM "foo"' . ' INNER JOIN "tableA" ON "id" = :join1part1 INNER JOIN "tableB" ON "id" = :join2part1 ' . 'INNER JOIN "tableC" ON "id" = :join3part1 AND "number" > :join3part2'; $sqlStr36 = 'SELECT "foo".*, "tableA".*, "tableB".*, "tableC".* FROM "foo" ' . 'INNER JOIN "tableA" ON "id" = \'1\' INNER JOIN "tableB" ON "id" = \'2\' ' . 'INNER JOIN "tableC" ON "id" = \'3\' AND "number" > \'20\''; - $internalTests36 = array(); + $internalTests36 = []; $useNamedParams36 = true; /** @@ -1151,76 +1151,76 @@ public function providerData() * @link https://github.com/zendframework/zf2/pull/2714 */ $select37 = new Select; - $select37->from('foo')->columns(array('bar'), false); + $select37->from('foo')->columns(['bar'], false); $sqlPrep37 = // same $sqlStr37 = 'SELECT "bar" AS "bar" FROM "foo"'; - $internalTests37 = array( - 'processSelect' => array(array(array('"bar"', '"bar"')), '"foo"') - ); + $internalTests37 = [ + 'processSelect' => [[['"bar"', '"bar"']], '"foo"'] + ]; // @link https://github.com/zendframework/zf2/issues/3294 // Test TableIdentifier In Joins $select38 = new Select; - $select38->from('foo')->columns(array())->join(new TableIdentifier('bar', 'baz'), 'm = n', array('thecount' => new Expression("COUNT(*)"))); + $select38->from('foo')->columns([])->join(new TableIdentifier('bar', 'baz'), 'm = n', ['thecount' => new Expression("COUNT(*)")]); $sqlPrep38 = // same $sqlStr38 = 'SELECT COUNT(*) AS "thecount" FROM "foo" INNER JOIN "baz"."bar" ON "m" = "n"'; - $internalTests38 = array( - 'processSelect' => array(array(array('COUNT(*)', '"thecount"')), '"foo"'), - 'processJoins' => array(array(array('INNER', '"baz"."bar"', '"m" = "n"'))) - ); + $internalTests38 = [ + 'processSelect' => [[['COUNT(*)', '"thecount"']], '"foo"'], + 'processJoins' => [[['INNER', '"baz"."bar"', '"m" = "n"']]] + ]; // subselect in join $select39subselect = new Select; $select39subselect->from('bar')->where->like('y', '%Foo%'); $select39 = new Select; - $select39->from('foo')->join(array('z' => $select39subselect), 'z.foo = bar.id'); + $select39->from('foo')->join(['z' => $select39subselect], 'z.foo = bar.id'); $sqlPrep39 = 'SELECT "foo".*, "z".* FROM "foo" INNER JOIN (SELECT "bar".* FROM "bar" WHERE "y" LIKE ?) AS "z" ON "z"."foo" = "bar"."id"'; $sqlStr39 = 'SELECT "foo".*, "z".* FROM "foo" INNER JOIN (SELECT "bar".* FROM "bar" WHERE "y" LIKE \'%Foo%\') AS "z" ON "z"."foo" = "bar"."id"'; - $internalTests39 = array( - 'processJoins' => array(array(array('INNER', '(SELECT "bar".* FROM "bar" WHERE "y" LIKE ?) AS "z"', '"z"."foo" = "bar"."id"'))) - ); + $internalTests39 = [ + 'processJoins' => [[['INNER', '(SELECT "bar".* FROM "bar" WHERE "y" LIKE ?) AS "z"', '"z"."foo" = "bar"."id"']]] + ]; // @link https://github.com/zendframework/zf2/issues/3294 // Test TableIdentifier In Joins, with multiple joins $select40 = new Select; $select40->from('foo') - ->join(array('a' => new TableIdentifier('another_foo', 'another_schema')), 'a.x = foo.foo_column') + ->join(['a' => new TableIdentifier('another_foo', 'another_schema')], 'a.x = foo.foo_column') ->join('bar', 'foo.colx = bar.colx'); $sqlPrep40 = // same $sqlStr40 = 'SELECT "foo".*, "a".*, "bar".* FROM "foo"' . ' INNER JOIN "another_schema"."another_foo" AS "a" ON "a"."x" = "foo"."foo_column"' . ' INNER JOIN "bar" ON "foo"."colx" = "bar"."colx"'; - $internalTests40 = array( - 'processSelect' => array(array(array('"foo".*'), array('"a".*'), array('"bar".*')), '"foo"'), - 'processJoins' => array(array( - array('INNER', '"another_schema"."another_foo" AS "a"', '"a"."x" = "foo"."foo_column"'), - array('INNER', '"bar"', '"foo"."colx" = "bar"."colx"') - )) - ); + $internalTests40 = [ + 'processSelect' => [[['"foo".*'], ['"a".*'], ['"bar".*']], '"foo"'], + 'processJoins' => [[ + ['INNER', '"another_schema"."another_foo" AS "a"', '"a"."x" = "foo"."foo_column"'], + ['INNER', '"bar"', '"foo"."colx" = "bar"."colx"'] + ]] + ]; $select41 = new Select; $select41->from('foo')->quantifier(Select::QUANTIFIER_DISTINCT); $sqlPrep41 = // same $sqlStr41 = 'SELECT DISTINCT "foo".* FROM "foo"'; - $internalTests41 = array( - 'processSelect' => array(SELECT::QUANTIFIER_DISTINCT, array(array('"foo".*')), '"foo"'), - ); + $internalTests41 = [ + 'processSelect' => [SELECT::QUANTIFIER_DISTINCT, [['"foo".*']], '"foo"'], + ]; $select42 = new Select; - $select42->from('foo')->quantifier(new Expression('TOP ?', array(10))); + $select42->from('foo')->quantifier(new Expression('TOP ?', [10])); $sqlPrep42 = 'SELECT TOP ? "foo".* FROM "foo"'; $sqlStr42 = 'SELECT TOP \'10\' "foo".* FROM "foo"'; - $internalTests42 = array( - 'processSelect' => array('TOP ?', array(array('"foo".*')), '"foo"'), - ); + $internalTests42 = [ + 'processSelect' => ['TOP ?', [['"foo".*']], '"foo"'], + ]; $select43 = new Select(); - $select43->from(array('x' => 'foo'))->columns(array('bar' => 'foo.bar'), false); + $select43->from(['x' => 'foo'])->columns(['bar' => 'foo.bar'], false); $sqlPrep43 = 'SELECT "foo"."bar" AS "bar" FROM "foo" AS "x"'; $sqlStr43 = 'SELECT "foo"."bar" AS "bar" FROM "foo" AS "x"'; - $internalTests43 = array( - 'processSelect' => array(array(array('"foo"."bar"', '"bar"')), '"foo" AS "x"') - ); + $internalTests43 = [ + 'processSelect' => [[['"foo"."bar"', '"bar"']], '"foo" AS "x"'] + ]; $select44 = new Select; $select44->from('foo')->where('a = b'); @@ -1229,44 +1229,44 @@ public function providerData() $select44->combine($select44b, Select::COMBINE_UNION, 'ALL'); $sqlPrep44 = // same $sqlStr44 = '( SELECT "foo".* FROM "foo" WHERE a = b ) UNION ALL ( SELECT "bar".* FROM "bar" WHERE c = d )'; - $internalTests44 = array( - 'processCombine' => array('UNION ALL', 'SELECT "bar".* FROM "bar" WHERE c = d') - ); + $internalTests44 = [ + 'processCombine' => ['UNION ALL', 'SELECT "bar".* FROM "bar" WHERE c = d'] + ]; // limit with offset $select45 = new Select; $select45->from('foo')->limit("5")->offset("10"); $sqlPrep45 = 'SELECT "foo".* FROM "foo" LIMIT ? OFFSET ?'; $sqlStr45 = 'SELECT "foo".* FROM "foo" LIMIT \'5\' OFFSET \'10\''; - $params45 = array('limit' => 5, 'offset' => 10); - $internalTests45 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processLimit' => array('?'), - 'processOffset' => array('?') - ); + $params45 = ['limit' => 5, 'offset' => 10]; + $internalTests45 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processLimit' => ['?'], + 'processOffset' => ['?'] + ]; // functions without table $select46 = new Select; - $select46->columns(array( + $select46->columns([ new Expression('SOME_DB_FUNCTION_ONE()'), 'foo' => new Expression('SOME_DB_FUNCTION_TWO()'), - )); + ]); $sqlPrep46 = 'SELECT SOME_DB_FUNCTION_ONE() AS Expression1, SOME_DB_FUNCTION_TWO() AS "foo"'; $sqlStr46 = 'SELECT SOME_DB_FUNCTION_ONE() AS Expression1, SOME_DB_FUNCTION_TWO() AS "foo"'; - $params46 = array(); - $internalTests46 = array(); + $params46 = []; + $internalTests46 = []; // limit with big offset and limit $select47 = new Select; $select47->from('foo')->limit("10000000000000000000")->offset("10000000000000000000"); $sqlPrep47 = 'SELECT "foo".* FROM "foo" LIMIT ? OFFSET ?'; $sqlStr47 = 'SELECT "foo".* FROM "foo" LIMIT \'10000000000000000000\' OFFSET \'10000000000000000000\''; - $params47 = array('limit' => 10000000000000000000, 'offset' => 10000000000000000000); - $internalTests47 = array( - 'processSelect' => array(array(array('"foo".*')), '"foo"'), - 'processLimit' => array('?'), - 'processOffset' => array('?') - ); + $params47 = ['limit' => 10000000000000000000, 'offset' => 10000000000000000000]; + $internalTests47 = [ + 'processSelect' => [[['"foo".*']], '"foo"'], + 'processLimit' => ['?'], + 'processOffset' => ['?'] + ]; //combine and union with order at the end $select48 = new Select; @@ -1276,23 +1276,23 @@ public function providerData() $select48->combine($select48b); $select48combined = new Select(); - $select48 = $select48combined->from(array('sub' => $select48))->order('id DESC'); + $select48 = $select48combined->from(['sub' => $select48])->order('id DESC'); $sqlPrep48 = // same $sqlStr48 = 'SELECT "sub".* FROM (( SELECT "foo".* FROM "foo" WHERE a = b ) UNION ( SELECT "bar".* FROM "bar" WHERE c = d )) AS "sub" ORDER BY "id" DESC'; - $internalTests48 = array( + $internalTests48 = [ 'processCombine' => null, - ); + ]; //Expression as joinName $select49 = new Select; $select49->from(new TableIdentifier('foo')) - ->join(array('bar' => new Expression('psql_function_which_returns_table')), 'foo.id = bar.fooid'); + ->join(['bar' => new Expression('psql_function_which_returns_table')], 'foo.id = bar.fooid'); $sqlPrep49 = // same $sqlStr49 = 'SELECT "foo".*, "bar".* FROM "foo" INNER JOIN psql_function_which_returns_table AS "bar" ON "foo"."id" = "bar"."fooid"'; - $internalTests49 = array( - 'processSelect' => array(array(array('"foo".*'), array('"bar".*')), '"foo"'), - 'processJoins' => array(array(array('INNER', 'psql_function_which_returns_table AS "bar"', '"foo"."id" = "bar"."fooid"'))) - ); + $internalTests49 = [ + 'processSelect' => [[['"foo".*'], ['"bar".*']], '"foo"'], + 'processJoins' => [[['INNER', 'psql_function_which_returns_table AS "bar"', '"foo"."id" = "bar"."fooid"']]] + ]; // Test generic predicate is appended with AND $select50 = new Select; @@ -1305,7 +1305,7 @@ public function providerData() ->unnest; $sqlPrep50 = // same $sqlStr50 = 'SELECT "foo".* FROM "foo" WHERE ("bar" IS NULL AND 1=1)'; - $internalTests50 = array(); + $internalTests50 = []; // Test generic predicate is appended with OR $select51 = new Select; @@ -1318,7 +1318,7 @@ public function providerData() ->unnest; $sqlPrep51 = // same $sqlStr51 = 'SELECT "foo".* FROM "foo" WHERE ("bar" IS NULL OR 1=1)'; - $internalTests51 = array(); + $internalTests51 = []; /** * @author Andrzej Lewandowski @@ -1328,10 +1328,10 @@ public function providerData() $select52->from('foo')->join('zac', '(catalog_category_website.category_id = catalog_category.category_id)'); $sqlPrep52 = // same $sqlStr52 = 'SELECT "foo".*, "zac".* FROM "foo" INNER JOIN "zac" ON ("catalog_category_website"."category_id" = "catalog_category"."category_id")'; - $internalTests52 = array( - 'processSelect' => array(array(array('"foo".*'), array('"zac".*')), '"foo"'), - 'processJoins' => array(array(array('INNER', '"zac"', '("catalog_category_website"."category_id" = "catalog_category"."category_id")'))) - ); + $internalTests52 = [ + 'processSelect' => [[['"foo".*'], ['"zac".*']], '"foo"'], + 'processJoins' => [[['INNER', '"zac"', '("catalog_category_website"."category_id" = "catalog_category"."category_id")']]] + ]; /** * $select = the select object @@ -1341,61 +1341,61 @@ public function providerData() * $internalTests what the internal functions should return (safe-guarding extension) */ - return array( + return [ // $select $sqlPrep $params $sqlStr $internalTests // use named param - array($select0, $sqlPrep0, array(), $sqlStr0, $internalTests0), - array($select1, $sqlPrep1, array(), $sqlStr1, $internalTests1), - array($select2, $sqlPrep2, array(), $sqlStr2, $internalTests2), - array($select3, $sqlPrep3, array(), $sqlStr3, $internalTests3), - array($select4, $sqlPrep4, array(), $sqlStr4, $internalTests4), - array($select5, $sqlPrep5, array(), $sqlStr5, $internalTests5), - array($select6, $sqlPrep6, array(), $sqlStr6, $internalTests6), - array($select7, $sqlPrep7, array(), $sqlStr7, $internalTests7), - array($select8, $sqlPrep8, array(), $sqlStr8, $internalTests8), - array($select9, $sqlPrep9, $params9, $sqlStr9, $internalTests9), - array($select10, $sqlPrep10, array(), $sqlStr10, $internalTests10), - array($select11, $sqlPrep11, array(), $sqlStr11, $internalTests11), - array($select12, $sqlPrep12, array(), $sqlStr12, $internalTests12), - array($select13, $sqlPrep13, array(), $sqlStr13, $internalTests13), - array($select14, $sqlPrep14, array(), $sqlStr14, $internalTests14), - array($select15, $sqlPrep15, array(), $sqlStr15, $internalTests15), - array($select16, $sqlPrep16, $params16, $sqlStr16, $internalTests16), - array($select17, $sqlPrep17, array(), $sqlStr17, $internalTests17), - array($select18, $sqlPrep18, array(), $sqlStr18, $internalTests18), - array($select19, $sqlPrep19, array(), $sqlStr19, $internalTests19), - array($select20, $sqlPrep20, array(), $sqlStr20, $internalTests20), - array($select21, $sqlPrep21, $params21, $sqlStr21, $internalTests21), - array($select22, $sqlPrep22, array(), $sqlStr22, $internalTests22), - array($select23, $sqlPrep23, array(), $sqlStr23, $internalTests23), - array($select24, $sqlPrep24, array(), $sqlStr24, $internalTests24), - array($select25, $sqlPrep25, array(), $sqlStr25, $internalTests25), - array($select26, $sqlPrep26, $params26, $sqlStr26, $internalTests26), - array($select27, $sqlPrep27, $params27, $sqlStr27, $internalTests27), - array($select28, $sqlPrep28, array(), $sqlStr28, $internalTests28), - array($select29, $sqlPrep29, array(), $sqlStr29, $internalTests29), - array($select30, $sqlPrep30, array(), $sqlStr30, $internalTests30), - array($select31, $sqlPrep31, array(), $sqlStr31, $internalTests31), - array($select32, $sqlPrep32, array(), $sqlStr32, $internalTests32), - array($select33, $sqlPrep33, array(), $sqlStr33, $internalTests33), - array($select34, $sqlPrep34, array(), $sqlStr34, $internalTests34), - array($select35, $sqlPrep35, array(), $sqlStr35, $internalTests35), - array($select36, $sqlPrep36, array(), $sqlStr36, $internalTests36, $useNamedParams36), - array($select37, $sqlPrep37, array(), $sqlStr37, $internalTests37), - array($select38, $sqlPrep38, array(), $sqlStr38, $internalTests38), - array($select39, $sqlPrep39, array(), $sqlStr39, $internalTests39), - array($select40, $sqlPrep40, array(), $sqlStr40, $internalTests40), - array($select41, $sqlPrep41, array(), $sqlStr41, $internalTests41), - array($select42, $sqlPrep42, array(), $sqlStr42, $internalTests42), - array($select43, $sqlPrep43, array(), $sqlStr43, $internalTests43), - array($select44, $sqlPrep44, array(), $sqlStr44, $internalTests44), - array($select45, $sqlPrep45, $params45, $sqlStr45, $internalTests45), - array($select46, $sqlPrep46, $params46, $sqlStr46, $internalTests46), - array($select47, $sqlPrep47, $params47, $sqlStr47, $internalTests47), - array($select48, $sqlPrep48, array(), $sqlStr48, $internalTests48), - array($select49, $sqlPrep49, array(), $sqlStr49, $internalTests49), - array($select50, $sqlPrep50, array(), $sqlStr50, $internalTests50), - array($select51, $sqlPrep51, array(), $sqlStr51, $internalTests51), - array($select52, $sqlPrep52, array(), $sqlStr52, $internalTests52), - ); + [$select0, $sqlPrep0, [], $sqlStr0, $internalTests0], + [$select1, $sqlPrep1, [], $sqlStr1, $internalTests1], + [$select2, $sqlPrep2, [], $sqlStr2, $internalTests2], + [$select3, $sqlPrep3, [], $sqlStr3, $internalTests3], + [$select4, $sqlPrep4, [], $sqlStr4, $internalTests4], + [$select5, $sqlPrep5, [], $sqlStr5, $internalTests5], + [$select6, $sqlPrep6, [], $sqlStr6, $internalTests6], + [$select7, $sqlPrep7, [], $sqlStr7, $internalTests7], + [$select8, $sqlPrep8, [], $sqlStr8, $internalTests8], + [$select9, $sqlPrep9, $params9, $sqlStr9, $internalTests9], + [$select10, $sqlPrep10, [], $sqlStr10, $internalTests10], + [$select11, $sqlPrep11, [], $sqlStr11, $internalTests11], + [$select12, $sqlPrep12, [], $sqlStr12, $internalTests12], + [$select13, $sqlPrep13, [], $sqlStr13, $internalTests13], + [$select14, $sqlPrep14, [], $sqlStr14, $internalTests14], + [$select15, $sqlPrep15, [], $sqlStr15, $internalTests15], + [$select16, $sqlPrep16, $params16, $sqlStr16, $internalTests16], + [$select17, $sqlPrep17, [], $sqlStr17, $internalTests17], + [$select18, $sqlPrep18, [], $sqlStr18, $internalTests18], + [$select19, $sqlPrep19, [], $sqlStr19, $internalTests19], + [$select20, $sqlPrep20, [], $sqlStr20, $internalTests20], + [$select21, $sqlPrep21, $params21, $sqlStr21, $internalTests21], + [$select22, $sqlPrep22, [], $sqlStr22, $internalTests22], + [$select23, $sqlPrep23, [], $sqlStr23, $internalTests23], + [$select24, $sqlPrep24, [], $sqlStr24, $internalTests24], + [$select25, $sqlPrep25, [], $sqlStr25, $internalTests25], + [$select26, $sqlPrep26, $params26, $sqlStr26, $internalTests26], + [$select27, $sqlPrep27, $params27, $sqlStr27, $internalTests27], + [$select28, $sqlPrep28, [], $sqlStr28, $internalTests28], + [$select29, $sqlPrep29, [], $sqlStr29, $internalTests29], + [$select30, $sqlPrep30, [], $sqlStr30, $internalTests30], + [$select31, $sqlPrep31, [], $sqlStr31, $internalTests31], + [$select32, $sqlPrep32, [], $sqlStr32, $internalTests32], + [$select33, $sqlPrep33, [], $sqlStr33, $internalTests33], + [$select34, $sqlPrep34, [], $sqlStr34, $internalTests34], + [$select35, $sqlPrep35, [], $sqlStr35, $internalTests35], + [$select36, $sqlPrep36, [], $sqlStr36, $internalTests36, $useNamedParams36], + [$select37, $sqlPrep37, [], $sqlStr37, $internalTests37], + [$select38, $sqlPrep38, [], $sqlStr38, $internalTests38], + [$select39, $sqlPrep39, [], $sqlStr39, $internalTests39], + [$select40, $sqlPrep40, [], $sqlStr40, $internalTests40], + [$select41, $sqlPrep41, [], $sqlStr41, $internalTests41], + [$select42, $sqlPrep42, [], $sqlStr42, $internalTests42], + [$select43, $sqlPrep43, [], $sqlStr43, $internalTests43], + [$select44, $sqlPrep44, [], $sqlStr44, $internalTests44], + [$select45, $sqlPrep45, $params45, $sqlStr45, $internalTests45], + [$select46, $sqlPrep46, $params46, $sqlStr46, $internalTests46], + [$select47, $sqlPrep47, $params47, $sqlStr47, $internalTests47], + [$select48, $sqlPrep48, [], $sqlStr48, $internalTests48], + [$select49, $sqlPrep49, [], $sqlStr49, $internalTests49], + [$select50, $sqlPrep50, [], $sqlStr50, $internalTests50], + [$select51, $sqlPrep51, [], $sqlStr51, $internalTests51], + [$select52, $sqlPrep52, [], $sqlStr52, $internalTests52], + ]; } } diff --git a/test/Sql/SqlFunctionalTest.php b/test/Sql/SqlFunctionalTest.php index 8e418ca78e..a003dc832d 100644 --- a/test/Sql/SqlFunctionalTest.php +++ b/test/Sql/SqlFunctionalTest.php @@ -25,271 +25,271 @@ class SqlFunctionalTest extends \PHPUnit_Framework_TestCase { protected function dataProvider_CommonProcessMethods() { - return array( - 'Select::processOffset()' => array( + return [ + 'Select::processOffset()' => [ 'sqlObject' => $this->select('foo')->offset(10), - 'expected' => array( - 'sql92' => array( + 'expected' => [ + 'sql92' => [ 'string' => 'SELECT "foo".* FROM "foo" OFFSET \'10\'', 'prepare' => 'SELECT "foo".* FROM "foo" OFFSET ?', - 'parameters' => array('offset' => 10), - ), - 'MySql' => array( + 'parameters' => ['offset' => 10], + ], + 'MySql' => [ 'string' => 'SELECT `foo`.* FROM `foo` LIMIT 18446744073709551615 OFFSET 10', 'prepare' => 'SELECT `foo`.* FROM `foo` LIMIT 18446744073709551615 OFFSET ?', - 'parameters' => array('offset' => 10), - ), - 'Oracle' => array( + 'parameters' => ['offset' => 10], + ], + 'Oracle' => [ 'string' => 'SELECT * FROM (SELECT b.*, rownum b_rownum FROM ( SELECT "foo".* FROM "foo" ) b ) WHERE b_rownum > (10)', 'prepare' => 'SELECT * FROM (SELECT b.*, rownum b_rownum FROM ( SELECT "foo".* FROM "foo" ) b ) WHERE b_rownum > (:offset)', - 'parameters' => array('offset' => 10), - ), - 'SqlServer' => array( + 'parameters' => ['offset' => 10], + ], + 'SqlServer' => [ 'string' => 'SELECT * FROM ( SELECT [foo].*, ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN 10+1 AND 0+10', 'prepare' => 'SELECT * FROM ( SELECT [foo].*, ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ?+1 AND ?+?', - 'parameters' => array('offset' => 10, 'limit' => null, 'offsetForSum' => 10), - ), - ), - ), - 'Select::processLimit()' => array( + 'parameters' => ['offset' => 10, 'limit' => null, 'offsetForSum' => 10], + ], + ], + ], + 'Select::processLimit()' => [ 'sqlObject' => $this->select('foo')->limit(10), - 'expected' => array( - 'sql92' => array( + 'expected' => [ + 'sql92' => [ 'string' => 'SELECT "foo".* FROM "foo" LIMIT \'10\'', 'prepare' => 'SELECT "foo".* FROM "foo" LIMIT ?', - 'parameters' => array('limit' => 10), - ), - 'MySql' => array( + 'parameters' => ['limit' => 10], + ], + 'MySql' => [ 'string' => 'SELECT `foo`.* FROM `foo` LIMIT 10', 'prepare' => 'SELECT `foo`.* FROM `foo` LIMIT ?', - 'parameters' => array('limit' => 10), - ), - 'Oracle' => array( + 'parameters' => ['limit' => 10], + ], + 'Oracle' => [ 'string' => 'SELECT * FROM (SELECT b.*, rownum b_rownum FROM ( SELECT "foo".* FROM "foo" ) b WHERE rownum <= (0+10)) WHERE b_rownum >= (0 + 1)', 'prepare' => 'SELECT * FROM (SELECT b.*, rownum b_rownum FROM ( SELECT "foo".* FROM "foo" ) b WHERE rownum <= (:offset+:limit)) WHERE b_rownum >= (:offset + 1)', - 'parameters' => array('offset' => 0, 'limit' => 10), - ), - 'SqlServer' => array( + 'parameters' => ['offset' => 0, 'limit' => 10], + ], + 'SqlServer' => [ 'string' => 'SELECT * FROM ( SELECT [foo].*, ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN 0+1 AND 10+0', 'prepare' => 'SELECT * FROM ( SELECT [foo].*, ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ?+1 AND ?+?', - 'parameters' => array('offset' => null, 'limit' => 10, 'offsetForSum' => null), - ), - ), - ), - 'Select::processLimitOffset()' => array( + 'parameters' => ['offset' => null, 'limit' => 10, 'offsetForSum' => null], + ], + ], + ], + 'Select::processLimitOffset()' => [ 'sqlObject' => $this->select('foo')->limit(10)->offset(5), - 'expected' => array( - 'sql92' => array( + 'expected' => [ + 'sql92' => [ 'string' => 'SELECT "foo".* FROM "foo" LIMIT \'10\' OFFSET \'5\'', 'prepare' => 'SELECT "foo".* FROM "foo" LIMIT ? OFFSET ?', - 'parameters' => array('limit' => 10, 'offset' => 5), - ), - 'MySql' => array( + 'parameters' => ['limit' => 10, 'offset' => 5], + ], + 'MySql' => [ 'string' => 'SELECT `foo`.* FROM `foo` LIMIT 10 OFFSET 5', 'prepare' => 'SELECT `foo`.* FROM `foo` LIMIT ? OFFSET ?', - 'parameters' => array('limit' => 10, 'offset' => 5), - ), - 'Oracle' => array( + 'parameters' => ['limit' => 10, 'offset' => 5], + ], + 'Oracle' => [ 'string' => 'SELECT * FROM (SELECT b.*, rownum b_rownum FROM ( SELECT "foo".* FROM "foo" ) b WHERE rownum <= (5+10)) WHERE b_rownum >= (5 + 1)', 'prepare' => 'SELECT * FROM (SELECT b.*, rownum b_rownum FROM ( SELECT "foo".* FROM "foo" ) b WHERE rownum <= (:offset+:limit)) WHERE b_rownum >= (:offset + 1)', - 'parameters' => array('offset' => 5, 'limit' => 10), - ), - 'SqlServer' => array( + 'parameters' => ['offset' => 5, 'limit' => 10], + ], + 'SqlServer' => [ 'string' => 'SELECT * FROM ( SELECT [foo].*, ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN 5+1 AND 10+5', 'prepare' => 'SELECT * FROM ( SELECT [foo].*, ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [__ZEND_ROW_NUMBER] FROM [foo] ) AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ?+1 AND ?+?', - 'parameters' => array('offset' => 5, 'limit' => 10, 'offsetForSum' => 5), - ), - ), - ), - 'Select::processJoin()' => array( - 'sqlObject' => $this->select('a')->join(array('b'=>$this->select('c')->where(array('cc'=>10))), 'd=e')->where(array('x'=>20)), - 'expected' => array( - 'sql92' => array( + 'parameters' => ['offset' => 5, 'limit' => 10, 'offsetForSum' => 5], + ], + ], + ], + 'Select::processJoin()' => [ + 'sqlObject' => $this->select('a')->join(['b'=>$this->select('c')->where(['cc'=>10])], 'd=e')->where(['x'=>20]), + 'expected' => [ + 'sql92' => [ 'string' => 'SELECT "a".*, "b".* FROM "a" INNER JOIN (SELECT "c".* FROM "c" WHERE "cc" = \'10\') AS "b" ON "d"="e" WHERE "x" = \'20\'', 'prepare' => 'SELECT "a".*, "b".* FROM "a" INNER JOIN (SELECT "c".* FROM "c" WHERE "cc" = ?) AS "b" ON "d"="e" WHERE "x" = ?', - 'parameters' => array('subselect1where1'=>10, 'where1'=>20), - ), - 'MySql' => array( + 'parameters' => ['subselect1where1'=>10, 'where1'=>20], + ], + 'MySql' => [ 'string' => 'SELECT `a`.*, `b`.* FROM `a` INNER JOIN (SELECT `c`.* FROM `c` WHERE `cc` = \'10\') AS `b` ON `d`=`e` WHERE `x` = \'20\'', 'prepare' => 'SELECT `a`.*, `b`.* FROM `a` INNER JOIN (SELECT `c`.* FROM `c` WHERE `cc` = ?) AS `b` ON `d`=`e` WHERE `x` = ?', - 'parameters' => array('subselect2where1'=>10, 'where2'=>20), - ), - 'Oracle' => array( + 'parameters' => ['subselect2where1'=>10, 'where2'=>20], + ], + 'Oracle' => [ 'string' => 'SELECT "a".*, "b".* FROM "a" INNER JOIN (SELECT "c".* FROM "c" WHERE "cc" = \'10\') "b" ON "d"="e" WHERE "x" = \'20\'', 'prepare' => 'SELECT "a".*, "b".* FROM "a" INNER JOIN (SELECT "c".* FROM "c" WHERE "cc" = ?) "b" ON "d"="e" WHERE "x" = ?', - 'parameters' => array('subselect2where1'=>10, 'where2'=>20), - ), - 'SqlServer' => array( + 'parameters' => ['subselect2where1'=>10, 'where2'=>20], + ], + 'SqlServer' => [ 'string' => 'SELECT [a].*, [b].* FROM [a] INNER JOIN (SELECT [c].* FROM [c] WHERE [cc] = \'10\') AS [b] ON [d]=[e] WHERE [x] = \'20\'', 'prepare' => 'SELECT [a].*, [b].* FROM [a] INNER JOIN (SELECT [c].* FROM [c] WHERE [cc] = ?) AS [b] ON [d]=[e] WHERE [x] = ?', - 'parameters' => array('subselect2where1'=>10, 'where2'=>20), - ), - ), - ), - 'Ddl::CreateTable::processColumns()' => array( + 'parameters' => ['subselect2where1'=>10, 'where2'=>20], + ], + ], + ], + 'Ddl::CreateTable::processColumns()' => [ 'sqlObject' => $this->createTable('foo') ->addColumn($this->createColumn('col1')->setOption('identity', true)->setOption('comment', 'Comment1')) ->addColumn($this->createColumn('col2')->setOption('identity', true)->setOption('comment', 'Comment2')), - 'expected' => array( + 'expected' => [ 'sql92' => "CREATE TABLE \"foo\" ( \n \"col1\" INTEGER NOT NULL,\n \"col2\" INTEGER NOT NULL \n)", 'MySql' => "CREATE TABLE `foo` ( \n `col1` INTEGER NOT NULL AUTO_INCREMENT COMMENT 'Comment1',\n `col2` INTEGER NOT NULL AUTO_INCREMENT COMMENT 'Comment2' \n)", 'Oracle' => "CREATE TABLE \"foo\" ( \n \"col1\" INTEGER NOT NULL,\n \"col2\" INTEGER NOT NULL \n)", 'SqlServer' => "CREATE TABLE [foo] ( \n [col1] INTEGER NOT NULL,\n [col2] INTEGER NOT NULL \n)", - ), - ), - 'Ddl::CreateTable::processTable()' => array( + ], + ], + 'Ddl::CreateTable::processTable()' => [ 'sqlObject' => $this->createTable('foo')->setTemporary(true), - 'expected' => array( + 'expected' => [ 'sql92' => "CREATE TEMPORARY TABLE \"foo\" ( \n)", 'MySql' => "CREATE TEMPORARY TABLE `foo` ( \n)", 'Oracle' => "CREATE TEMPORARY TABLE \"foo\" ( \n)", 'SqlServer' => "CREATE TABLE [#foo] ( \n)", - ), - ), - 'Select::processSubSelect()' => array( - 'sqlObject' => $this->select(array('a' => $this->select(array('b' => $this->select('c')->where(array('cc'=>'CC'))))->where(array('bb'=>'BB'))))->where(array('aa'=>'AA')), - 'expected' => array( - 'sql92' => array( + ], + ], + 'Select::processSubSelect()' => [ + 'sqlObject' => $this->select(['a' => $this->select(['b' => $this->select('c')->where(['cc'=>'CC'])])->where(['bb'=>'BB'])])->where(['aa'=>'AA']), + 'expected' => [ + 'sql92' => [ 'string' => 'SELECT "a".* FROM (SELECT "b".* FROM (SELECT "c".* FROM "c" WHERE "cc" = \'CC\') AS "b" WHERE "bb" = \'BB\') AS "a" WHERE "aa" = \'AA\'', 'prepare' => 'SELECT "a".* FROM (SELECT "b".* FROM (SELECT "c".* FROM "c" WHERE "cc" = ?) AS "b" WHERE "bb" = ?) AS "a" WHERE "aa" = ?', - 'parameters' => array('subselect2where1' => 'CC', 'subselect1where1' => 'BB', 'where1' => 'AA'), - ), - 'MySql' => array( + 'parameters' => ['subselect2where1' => 'CC', 'subselect1where1' => 'BB', 'where1' => 'AA'], + ], + 'MySql' => [ 'string' => 'SELECT `a`.* FROM (SELECT `b`.* FROM (SELECT `c`.* FROM `c` WHERE `cc` = \'CC\') AS `b` WHERE `bb` = \'BB\') AS `a` WHERE `aa` = \'AA\'', 'prepare' => 'SELECT `a`.* FROM (SELECT `b`.* FROM (SELECT `c`.* FROM `c` WHERE `cc` = ?) AS `b` WHERE `bb` = ?) AS `a` WHERE `aa` = ?', - 'parameters' => array('subselect4where1' => 'CC', 'subselect3where1' => 'BB', 'where2' => 'AA'), - ), - 'Oracle' => array( + 'parameters' => ['subselect4where1' => 'CC', 'subselect3where1' => 'BB', 'where2' => 'AA'], + ], + 'Oracle' => [ 'string' => 'SELECT "a".* FROM (SELECT "b".* FROM (SELECT "c".* FROM "c" WHERE "cc" = \'CC\') "b" WHERE "bb" = \'BB\') "a" WHERE "aa" = \'AA\'', 'prepare' => 'SELECT "a".* FROM (SELECT "b".* FROM (SELECT "c".* FROM "c" WHERE "cc" = ?) "b" WHERE "bb" = ?) "a" WHERE "aa" = ?', - 'parameters' => array('subselect4where1' => 'CC', 'subselect3where1' => 'BB', 'where2' => 'AA'), - ), - 'SqlServer' => array( + 'parameters' => ['subselect4where1' => 'CC', 'subselect3where1' => 'BB', 'where2' => 'AA'], + ], + 'SqlServer' => [ 'string' => 'SELECT [a].* FROM (SELECT [b].* FROM (SELECT [c].* FROM [c] WHERE [cc] = \'CC\') AS [b] WHERE [bb] = \'BB\') AS [a] WHERE [aa] = \'AA\'', 'prepare' => 'SELECT [a].* FROM (SELECT [b].* FROM (SELECT [c].* FROM [c] WHERE [cc] = ?) AS [b] WHERE [bb] = ?) AS [a] WHERE [aa] = ?', - 'parameters' => array('subselect4where1' => 'CC', 'subselect3where1' => 'BB', 'where2' => 'AA'), - ), - ), - ), - 'Delete::processSubSelect()' => array( - 'sqlObject' => $this->delete('foo')->where(array('x'=>$this->select('foo')->where(array('x'=>'y')))), - 'expected' => array( - 'sql92' => array( + 'parameters' => ['subselect4where1' => 'CC', 'subselect3where1' => 'BB', 'where2' => 'AA'], + ], + ], + ], + 'Delete::processSubSelect()' => [ + 'sqlObject' => $this->delete('foo')->where(['x'=>$this->select('foo')->where(['x'=>'y'])]), + 'expected' => [ + 'sql92' => [ 'string' => 'DELETE FROM "foo" WHERE "x" = (SELECT "foo".* FROM "foo" WHERE "x" = \'y\')', 'prepare' => 'DELETE FROM "foo" WHERE "x" = (SELECT "foo".* FROM "foo" WHERE "x" = ?)', - 'parameters' => array('subselect1where1' => 'y'), - ), - 'MySql' => array( + 'parameters' => ['subselect1where1' => 'y'], + ], + 'MySql' => [ 'string' => 'DELETE FROM `foo` WHERE `x` = (SELECT `foo`.* FROM `foo` WHERE `x` = \'y\')', 'prepare' => 'DELETE FROM `foo` WHERE `x` = (SELECT `foo`.* FROM `foo` WHERE `x` = ?)', - 'parameters' => array('subselect2where1' => 'y'), - ), - 'Oracle' => array( + 'parameters' => ['subselect2where1' => 'y'], + ], + 'Oracle' => [ 'string' => 'DELETE FROM "foo" WHERE "x" = (SELECT "foo".* FROM "foo" WHERE "x" = \'y\')', 'prepare' => 'DELETE FROM "foo" WHERE "x" = (SELECT "foo".* FROM "foo" WHERE "x" = ?)', - 'parameters' => array('subselect3where1' => 'y'), - ), - 'SqlServer' => array( + 'parameters' => ['subselect3where1' => 'y'], + ], + 'SqlServer' => [ 'string' => 'DELETE FROM [foo] WHERE [x] = (SELECT [foo].* FROM [foo] WHERE [x] = \'y\')', 'prepare' => 'DELETE FROM [foo] WHERE [x] = (SELECT [foo].* FROM [foo] WHERE [x] = ?)', - 'parameters' => array('subselect4where1' => 'y'), - ), - ), - ), - 'Update::processSubSelect()' => array( - 'sqlObject' => $this->update('foo')->set(array('x'=>$this->select('foo'))), - 'expected' => array( + 'parameters' => ['subselect4where1' => 'y'], + ], + ], + ], + 'Update::processSubSelect()' => [ + 'sqlObject' => $this->update('foo')->set(['x'=>$this->select('foo')]), + 'expected' => [ 'sql92' => 'UPDATE "foo" SET "x" = (SELECT "foo".* FROM "foo")', 'MySql' => 'UPDATE `foo` SET `x` = (SELECT `foo`.* FROM `foo`)', 'Oracle' => 'UPDATE "foo" SET "x" = (SELECT "foo".* FROM "foo")', 'SqlServer' => 'UPDATE [foo] SET [x] = (SELECT [foo].* FROM [foo])', - ), - ), - 'Insert::processSubSelect()' => array( - 'sqlObject' => $this->insert('foo')->select($this->select('foo')->where(array('x'=>'y'))), - 'expected' => array( - 'sql92' => array( + ], + ], + 'Insert::processSubSelect()' => [ + 'sqlObject' => $this->insert('foo')->select($this->select('foo')->where(['x'=>'y'])), + 'expected' => [ + 'sql92' => [ 'string' => 'INSERT INTO "foo" SELECT "foo".* FROM "foo" WHERE "x" = \'y\'', 'prepare' => 'INSERT INTO "foo" SELECT "foo".* FROM "foo" WHERE "x" = ?', - 'parameters' => array('subselect1where1' => 'y'), - ), - 'MySql' => array( + 'parameters' => ['subselect1where1' => 'y'], + ], + 'MySql' => [ 'string' => 'INSERT INTO `foo` SELECT `foo`.* FROM `foo` WHERE `x` = \'y\'', 'prepare' => 'INSERT INTO `foo` SELECT `foo`.* FROM `foo` WHERE `x` = ?', - 'parameters' => array('subselect2where1' => 'y'), - ), - 'Oracle' => array( + 'parameters' => ['subselect2where1' => 'y'], + ], + 'Oracle' => [ 'string' => 'INSERT INTO "foo" SELECT "foo".* FROM "foo" WHERE "x" = \'y\'', 'prepare' => 'INSERT INTO "foo" SELECT "foo".* FROM "foo" WHERE "x" = ?', - 'parameters' => array('subselect3where1' => 'y'), - ), - 'SqlServer' => array( + 'parameters' => ['subselect3where1' => 'y'], + ], + 'SqlServer' => [ 'string' => 'INSERT INTO [foo] SELECT [foo].* FROM [foo] WHERE [x] = \'y\'', 'prepare' => 'INSERT INTO [foo] SELECT [foo].* FROM [foo] WHERE [x] = ?', - 'parameters' => array('subselect4where1' => 'y'), - ), - ), - ), - 'Update::processExpression()' => array( - 'sqlObject' => $this->update('foo')->set(array('x'=>new Sql\Expression('?', array($this->select('foo')->where(array('x'=>'y')))))), - 'expected' => array( - 'sql92' => array( + 'parameters' => ['subselect4where1' => 'y'], + ], + ], + ], + 'Update::processExpression()' => [ + 'sqlObject' => $this->update('foo')->set(['x'=>new Sql\Expression('?', [$this->select('foo')->where(['x'=>'y'])])]), + 'expected' => [ + 'sql92' => [ 'string' => 'UPDATE "foo" SET "x" = (SELECT "foo".* FROM "foo" WHERE "x" = \'y\')', 'prepare' => 'UPDATE "foo" SET "x" = (SELECT "foo".* FROM "foo" WHERE "x" = ?)', - 'parameters' => array('subselect1where1' => 'y'), - ), - 'MySql' => array( + 'parameters' => ['subselect1where1' => 'y'], + ], + 'MySql' => [ 'string' => 'UPDATE `foo` SET `x` = (SELECT `foo`.* FROM `foo` WHERE `x` = \'y\')', 'prepare' => 'UPDATE `foo` SET `x` = (SELECT `foo`.* FROM `foo` WHERE `x` = ?)', - 'parameters' => array('subselect2where1' => 'y'), - ), - 'Oracle' => array( + 'parameters' => ['subselect2where1' => 'y'], + ], + 'Oracle' => [ 'string' => 'UPDATE "foo" SET "x" = (SELECT "foo".* FROM "foo" WHERE "x" = \'y\')', 'prepare' => 'UPDATE "foo" SET "x" = (SELECT "foo".* FROM "foo" WHERE "x" = ?)', - 'parameters' => array('subselect3where1' => 'y'), - ), - 'SqlServer' => array( + 'parameters' => ['subselect3where1' => 'y'], + ], + 'SqlServer' => [ 'string' => 'UPDATE [foo] SET [x] = (SELECT [foo].* FROM [foo] WHERE [x] = \'y\')', 'prepare' => 'UPDATE [foo] SET [x] = (SELECT [foo].* FROM [foo] WHERE [x] = ?)', - 'parameters' => array('subselect4where1' => 'y'), - ), - ), - ), - ); + 'parameters' => ['subselect4where1' => 'y'], + ], + ], + ], + ]; } protected function dataProvider_Decorators() { - return array( - 'RootDecorators::Select' => array( - 'sqlObject' => $this->select('foo')->where(array('x'=>$this->select('bar'))), - 'expected' => array( - 'sql92' => array( - 'decorators' => array( + return [ + 'RootDecorators::Select' => [ + 'sqlObject' => $this->select('foo')->where(['x'=>$this->select('bar')]), + 'expected' => [ + 'sql92' => [ + 'decorators' => [ 'Zend\Db\Sql\Select' => new TestAsset\SelectDecorator, - ), + ], 'string' => 'SELECT "foo".* FROM "foo" WHERE "x" = (SELECT "bar".* FROM "bar")', - ), - 'MySql' => array( - 'decorators' => array( + ], + 'MySql' => [ + 'decorators' => [ 'Zend\Db\Sql\Select' => new TestAsset\SelectDecorator, - ), + ], 'string' => 'SELECT `foo`.* FROM `foo` WHERE `x` = (SELECT `bar`.* FROM `bar`)', - ), - 'Oracle' => array( - 'decorators' => array( + ], + 'Oracle' => [ + 'decorators' => [ 'Zend\Db\Sql\Select' => new TestAsset\SelectDecorator, - ), + ], 'string' => 'SELECT "foo".* FROM "foo" WHERE "x" = (SELECT "bar".* FROM "bar")', - ), - 'SqlServer' => array( - 'decorators' => array( + ], + 'SqlServer' => [ + 'decorators' => [ 'Zend\Db\Sql\Select' => new TestAsset\SelectDecorator, - ), + ], 'string' => 'SELECT [foo].* FROM [foo] WHERE [x] = (SELECT [bar].* FROM [bar])', - ), - ), - ), + ], + ], + ], /* TODO - should be implemeted 'RootDecorators::Insert' => array( 'sqlObject' => $this->insert('foo')->select($this->select()), @@ -423,7 +423,7 @@ protected function dataProvider_Decorators() ), ), ),*/ - ); + ]; } public function dataProvider() @@ -433,14 +433,14 @@ public function dataProvider() $this->dataProvider_Decorators() ); - $res = array(); + $res = []; foreach ($data as $index => $test) { foreach ($test['expected'] as $platform => $expected) { - $res[$index . '->' . $platform] = array( + $res[$index . '->' . $platform] = [ 'sqlObject' => $test['sqlObject'], 'platform' => $platform, 'expected' => $expected, - ); + ]; } } return $res; @@ -480,7 +480,7 @@ public function test($sqlObject, $platform, $expected) protected function resolveDecorator($decorator) { if (is_array($decorator)) { - $decoratorMock = $this->getMock($decorator[0], array('buildSqlString'), array(null)); + $decoratorMock = $this->getMock($decorator[0], ['buildSqlString'], [null]); $decoratorMock->expects($this->any())->method('buildSqlString')->will($this->returnValue($decorator[1])); return $decoratorMock; } diff --git a/test/Sql/SqlTest.php b/test/Sql/SqlTest.php index 493d1eeb6f..05ffa85a52 100644 --- a/test/Sql/SqlTest.php +++ b/test/Sql/SqlTest.php @@ -36,7 +36,7 @@ public function setup() $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?')); // setup mock adapter - $this->mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver, new TestAsset\TrustingSql92Platform())); + $this->mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver, new TestAsset\TrustingSql92Platform()]); $this->sql = new Sql($this->mockAdapter, 'foo'); } @@ -119,7 +119,7 @@ public function testDelete() */ public function testPrepareStatementForSqlObject() { - $insert = $this->sql->insert()->columns(array('foo'))->values(array('foo'=>'bar')); + $insert = $this->sql->insert()->columns(['foo'])->values(['foo'=>'bar']); $stmt = $this->sql->prepareStatementForSqlObject($insert); $this->assertInstanceOf('Zend\Db\Adapter\Driver\StatementInterface', $stmt); } diff --git a/test/Sql/TableIdentifierTest.php b/test/Sql/TableIdentifierTest.php index a43eb5bcae..95841ded80 100644 --- a/test/Sql/TableIdentifierTest.php +++ b/test/Sql/TableIdentifierTest.php @@ -42,7 +42,7 @@ public function testGetSchema() public function testGetTableFromObjectStringCast() { - $table = $this->getMock('stdClass', array('__toString')); + $table = $this->getMock('stdClass', ['__toString']); $table->expects($this->once())->method('__toString')->will($this->returnValue('castResult')); @@ -54,7 +54,7 @@ public function testGetTableFromObjectStringCast() public function testGetSchemaFromObjectStringCast() { - $schema = $this->getMock('stdClass', array('__toString')); + $schema = $this->getMock('stdClass', ['__toString']); $schema->expects($this->once())->method('__toString')->will($this->returnValue('castResult')); @@ -96,7 +96,7 @@ public function testRejectsInvalidSchema($invalidSchema) public function invalidTableProvider() { return array_merge( - array(array(null)), + [[null]], $this->invalidSchemaProvider() ); } @@ -108,10 +108,10 @@ public function invalidTableProvider() */ public function invalidSchemaProvider() { - return array( - array(''), - array(new stdClass()), - array(array()), - ); + return [ + [''], + [new stdClass()], + [[]], + ]; } } diff --git a/test/Sql/UpdateTest.php b/test/Sql/UpdateTest.php index afbcccaa6c..4c675f8939 100644 --- a/test/Sql/UpdateTest.php +++ b/test/Sql/UpdateTest.php @@ -66,8 +66,8 @@ public function testConstruct() */ public function testSet() { - $this->update->set(array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $this->update->getRawState('set')); + $this->update->set(['foo' => 'bar']); + $this->assertEquals(['foo' => 'bar'], $this->update->getRawState('set')); } /** @@ -75,18 +75,18 @@ public function testSet() */ public function testSortableSet() { - $this->update->set(array( + $this->update->set([ 'two' => 'с_two', 'three' => 'с_three', - )); - $this->update->set(array('one' => 'с_one'), 10); + ]); + $this->update->set(['one' => 'с_one'], 10); $this->assertEquals( - array( + [ 'one' => 'с_one', 'two' => 'с_two', 'three' => 'с_three', - ), + ], $this->update->getRawState('set') ); } @@ -97,12 +97,12 @@ public function testSortableSet() public function testWhere() { $this->update->where('x = y'); - $this->update->where(array('foo > ?' => 5)); - $this->update->where(array('id' => 2)); - $this->update->where(array('a = b'), Where::OP_OR); - $this->update->where(array('c1' => null)); - $this->update->where(array('c2' => array(1, 2, 3))); - $this->update->where(array(new \Zend\Db\Sql\Predicate\IsNotNull('c3'))); + $this->update->where(['foo > ?' => 5]); + $this->update->where(['id' => 2]); + $this->update->where(['a = b'], Where::OP_OR); + $this->update->where(['c1' => null]); + $this->update->where(['c2' => [1, 2, 3]]); + $this->update->where([new \Zend\Db\Sql\Predicate\IsNotNull('c3')]); $where = $this->update->where; $predicates = $this->readAttribute($where, 'predicates'); @@ -148,8 +148,8 @@ public function testPassingMultipleKeyValueInWhereClause() { $update = clone $this->update; $update->table('table'); - $update->set(array('fld1' => 'val1')); - $update->where(array('id1' => 'val1', 'id2' => 'val2')); + $update->set(['fld1' => 'val1']); + $update->where(['id1' => 'val1', 'id2' => 'val2']); $this->assertEquals('UPDATE "table" SET "fld1" = \'val1\' WHERE "id1" = \'val1\' AND "id2" = \'val2\'', $update->getSqlString(new TrustingSql92Platform())); } @@ -159,12 +159,12 @@ public function testPassingMultipleKeyValueInWhereClause() public function testGetRawState() { $this->update->table('foo') - ->set(array('bar' => 'baz')) + ->set(['bar' => 'baz']) ->where('x = y'); $this->assertEquals('foo', $this->update->getRawState('table')); $this->assertEquals(true, $this->update->getRawState('emptyWhereProtection')); - $this->assertEquals(array('bar' => 'baz'), $this->update->getRawState('set')); + $this->assertEquals(['bar' => 'baz'], $this->update->getRawState('set')); $this->assertInstanceOf('Zend\Db\Sql\Where', $this->update->getRawState('where')); } @@ -176,10 +176,10 @@ public function testPrepareStatement() $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); $mockDriver->expects($this->any())->method('getPrepareType')->will($this->returnValue('positional')); $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?')); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); - $pContainer = new \Zend\Db\Adapter\ParameterContainer(array()); + $pContainer = new \Zend\Db\Adapter\ParameterContainer([]); $mockStatement->expects($this->any())->method('getParameterContainer')->will($this->returnValue($pContainer)); $mockStatement->expects($this->at(1)) @@ -187,7 +187,7 @@ public function testPrepareStatement() ->with($this->equalTo('UPDATE "foo" SET "bar" = ?, "boo" = NOW() WHERE x = y')); $this->update->table('foo') - ->set(array('bar' => 'baz', 'boo' => new Expression('NOW()'))) + ->set(['bar' => 'baz', 'boo' => new Expression('NOW()')]) ->where('x = y'); $this->update->prepareStatement($mockAdapter, $mockStatement); @@ -197,10 +197,10 @@ public function testPrepareStatement() $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); $mockDriver->expects($this->any())->method('getPrepareType')->will($this->returnValue('positional')); $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?')); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); - $pContainer = new \Zend\Db\Adapter\ParameterContainer(array()); + $pContainer = new \Zend\Db\Adapter\ParameterContainer([]); $mockStatement->expects($this->any())->method('getParameterContainer')->will($this->returnValue($pContainer)); $mockStatement->expects($this->at(1)) @@ -208,7 +208,7 @@ public function testPrepareStatement() ->with($this->equalTo('UPDATE "sch"."foo" SET "bar" = ?, "boo" = NOW() WHERE x = y')); $this->update->table(new TableIdentifier('foo', 'sch')) - ->set(array('bar' => 'baz', 'boo' => new Expression('NOW()'))) + ->set(['bar' => 'baz', 'boo' => new Expression('NOW()')]) ->where('x = y'); $this->update->prepareStatement($mockAdapter, $mockStatement); @@ -220,7 +220,7 @@ public function testPrepareStatement() public function testGetSqlString() { $this->update->table('foo') - ->set(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null)) + ->set(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]) ->where('x = y'); $this->assertEquals('UPDATE "foo" SET "bar" = \'baz\', "boo" = NOW(), "bam" = NULL WHERE x = y', $this->update->getSqlString(new TrustingSql92Platform())); @@ -228,7 +228,7 @@ public function testGetSqlString() // with TableIdentifier $this->update = new Update; $this->update->table(new TableIdentifier('foo', 'sch')) - ->set(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null)) + ->set(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]) ->where('x = y'); $this->assertEquals('UPDATE "sch"."foo" SET "bar" = \'baz\', "boo" = NOW(), "bam" = NULL WHERE x = y', $this->update->getSqlString(new TrustingSql92Platform())); @@ -242,7 +242,7 @@ public function testGetSqlStringForFalseUpdateValueParameter() { $this->update = new Update; $this->update->table(new TableIdentifier('foo', 'sch')) - ->set(array('bar' => false, 'boo' => 'test', 'bam' => true)) + ->set(['bar' => false, 'boo' => 'test', 'bam' => true]) ->where('x = y'); $this->assertEquals('UPDATE "sch"."foo" SET "bar" = \'\', "boo" = \'test\', "bam" = \'1\' WHERE x = y', $this->update->getSqlString(new TrustingSql92Platform())); } @@ -272,15 +272,15 @@ public function testCloneUpdate() { $update1 = clone $this->update; $update1->table('foo') - ->set(array('bar' => 'baz')) + ->set(['bar' => 'baz']) ->where('x = y'); $update2 = clone $this->update; $update2->table('foo') - ->set(array('bar' => 'baz')) - ->where(array( + ->set(['bar' => 'baz']) + ->where([ 'id = ?'=>1 - )); + ]); $this->assertEquals('UPDATE "foo" SET "bar" = \'baz\' WHERE id = \'1\'', $update2->getSqlString(new TrustingSql92Platform)); } @@ -294,10 +294,10 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface'); $mockDriver->expects($this->any())->method('getPrepareType')->will($this->returnValue('positional')); $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?')); - $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface'); - $pContainer = new \Zend\Db\Adapter\ParameterContainer(array()); + $pContainer = new \Zend\Db\Adapter\ParameterContainer([]); $mockStatement->expects($this->any())->method('getParameterContainer')->will($this->returnValue($pContainer)); $mockStatement->expects($this->at(1)) @@ -305,7 +305,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt ->with($this->equalTo('UPDATE IGNORE "foo" SET "bar" = ?, "boo" = NOW() WHERE x = y')); $updateIgnore->table('foo') - ->set(array('bar' => 'baz', 'boo' => new Expression('NOW()'))) + ->set(['bar' => 'baz', 'boo' => new Expression('NOW()')]) ->where('x = y'); $updateIgnore->prepareStatement($mockAdapter, $mockStatement); @@ -319,7 +319,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlStr $this->update = new UpdateIgnore(); $this->update->table('foo') - ->set(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null)) + ->set(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]) ->where('x = y'); $this->assertEquals('UPDATE IGNORE "foo" SET "bar" = \'baz\', "boo" = NOW(), "bam" = NULL WHERE x = y', $this->update->getSqlString(new TrustingSql92Platform())); @@ -327,7 +327,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlStr // with TableIdentifier $this->update = new UpdateIgnore(); $this->update->table(new TableIdentifier('foo', 'sch')) - ->set(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null)) + ->set(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]) ->where('x = y'); $this->assertEquals('UPDATE IGNORE "sch"."foo" SET "bar" = \'baz\', "boo" = NOW(), "bam" = NULL WHERE x = y', $this->update->getSqlString(new TrustingSql92Platform())); @@ -338,10 +338,10 @@ class UpdateIgnore extends Update { const SPECIFICATION_UPDATE = 'updateIgnore'; - protected $specifications = array( + protected $specifications = [ self::SPECIFICATION_UPDATE => 'UPDATE IGNORE %1$s SET %2$s', self::SPECIFICATION_WHERE => 'WHERE %1$s' - ); + ]; protected function processupdateIgnore(\Zend\Db\Adapter\Platform\PlatformInterface $platform, \Zend\Db\Adapter\Driver\DriverInterface $driver = null, \Zend\Db\Adapter\ParameterContainer $parameterContainer = null) { diff --git a/test/TableGateway/AbstractTableGatewayTest.php b/test/TableGateway/AbstractTableGatewayTest.php index 374d8504c0..7260896949 100644 --- a/test/TableGateway/AbstractTableGatewayTest.php +++ b/test/TableGateway/AbstractTableGatewayTest.php @@ -53,12 +53,12 @@ protected function setUp() $mockDriver->expects($this->any())->method('createStatement')->will($this->returnValue($mockStatement)); $mockDriver->expects($this->any())->method('getConnection')->will($this->returnValue($mockConnection)); - $this->mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); - $this->mockSql = $this->getMock('Zend\Db\Sql\Sql', array('select', 'insert', 'update', 'delete'), array($this->mockAdapter, 'foo')); - $this->mockSql->expects($this->any())->method('select')->will($this->returnValue($this->getMock('Zend\Db\Sql\Select', array('where', 'getRawSate'), array('foo')))); - $this->mockSql->expects($this->any())->method('insert')->will($this->returnValue($this->getMock('Zend\Db\Sql\Insert', array('prepareStatement', 'values'), array('foo')))); - $this->mockSql->expects($this->any())->method('update')->will($this->returnValue($this->getMock('Zend\Db\Sql\Update', array('where'), array('foo')))); - $this->mockSql->expects($this->any())->method('delete')->will($this->returnValue($this->getMock('Zend\Db\Sql\Delete', array('where'), array('foo')))); + $this->mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); + $this->mockSql = $this->getMock('Zend\Db\Sql\Sql', ['select', 'insert', 'update', 'delete'], [$this->mockAdapter, 'foo']); + $this->mockSql->expects($this->any())->method('select')->will($this->returnValue($this->getMock('Zend\Db\Sql\Select', ['where', 'getRawSate'], ['foo']))); + $this->mockSql->expects($this->any())->method('insert')->will($this->returnValue($this->getMock('Zend\Db\Sql\Insert', ['prepareStatement', 'values'], ['foo']))); + $this->mockSql->expects($this->any())->method('update')->will($this->returnValue($this->getMock('Zend\Db\Sql\Update', ['where'], ['foo']))); + $this->mockSql->expects($this->any())->method('delete')->will($this->returnValue($this->getMock('Zend\Db\Sql\Delete', ['where'], ['foo']))); $this->table = $this->getMockForAbstractClass( 'Zend\Db\TableGateway\AbstractTableGateway' @@ -149,9 +149,9 @@ public function testSelectWithWhereString() $mockSelect->expects($this->any()) ->method('getRawState') - ->will($this->returnValue(array( + ->will($this->returnValue([ 'table' => $this->table->getTable(), - )) + ]) ); // assert select::from() is called @@ -183,25 +183,25 @@ public function testSelectWithArrayTable() { // Case 1 - $select1 = $this->getMock('Zend\Db\Sql\Select', array('getRawState')); + $select1 = $this->getMock('Zend\Db\Sql\Select', ['getRawState']); $select1->expects($this->once()) ->method('getRawState') - ->will($this->returnValue(array( + ->will($this->returnValue([ 'table' => 'foo', // Standard table name format, valid according to Select::from() 'columns' => null, - ))); + ])); $return = $this->table->selectWith($select1); $this->assertNotNull($return); // Case 2 - $select1 = $this->getMock('Zend\Db\Sql\Select', array('getRawState')); + $select1 = $this->getMock('Zend\Db\Sql\Select', ['getRawState']); $select1->expects($this->once()) ->method('getRawState') - ->will($this->returnValue(array( - 'table' => array('f' => 'foo'), // Alias table name format, valid according to Select::from() + ->will($this->returnValue([ + 'table' => ['f' => 'foo'], // Alias table name format, valid according to Select::from() 'columns' => null, - ))); + ])); $return = $this->table->selectWith($select1); $this->assertNotNull($return); } @@ -222,9 +222,9 @@ public function testInsert() $mockInsert->expects($this->once()) ->method('values') - ->with($this->equalTo(array('foo' => 'bar'))); + ->with($this->equalTo(['foo' => 'bar'])); - $affectedRows = $this->table->insert(array('foo' => 'bar')); + $affectedRows = $this->table->insert(['foo' => 'bar']); $this->assertEquals(5, $affectedRows); } @@ -242,7 +242,7 @@ public function testUpdate() ->method('where') ->with($this->equalTo('id = 2')); - $affectedRows = $this->table->update(array('foo' => 'bar'), 'id = 2'); + $affectedRows = $this->table->update(['foo' => 'bar'], 'id = 2'); $this->assertEquals(5, $affectedRows); } @@ -255,7 +255,7 @@ public function testUpdateWithNoCriteria() { $mockUpdate = $this->mockSql->update(); - $affectedRows = $this->table->update(array('foo' => 'bar')); + $affectedRows = $this->table->update(['foo' => 'bar']); $this->assertEquals(5, $affectedRows); } @@ -282,7 +282,7 @@ public function testDelete() */ public function testGetLastInsertValue() { - $this->table->insert(array('foo' => 'bar')); + $this->table->insert(['foo' => 'bar']); $this->assertEquals(10, $this->table->getLastInsertValue()); } @@ -291,7 +291,7 @@ public function testGetLastInsertValue() */ public function test__get() { - $this->table->insert(array('foo')); // trigger last insert id update + $this->table->insert(['foo']); // trigger last insert id update $this->assertEquals(10, $this->table->lastInsertValue); $this->assertSame($this->mockAdapter, $this->table->adapter); diff --git a/test/TableGateway/Feature/EventFeatureTest.php b/test/TableGateway/Feature/EventFeatureTest.php index 80168de96e..0810d0118d 100644 --- a/test/TableGateway/Feature/EventFeatureTest.php +++ b/test/TableGateway/Feature/EventFeatureTest.php @@ -31,7 +31,7 @@ public function setup() $this->eventManager = new EventManager; $this->event = new EventFeature\TableGatewayEvent(); $this->feature = new EventFeature($this->eventManager, $this->event); - $this->tableGateway = $this->getMockForAbstractClass('Zend\Db\TableGateway\TableGateway', array(), '', false); + $this->tableGateway = $this->getMockForAbstractClass('Zend\Db\TableGateway\TableGateway', [], '', false); $this->feature->setTableGateway($this->tableGateway); // typically runs before everything else diff --git a/test/TableGateway/Feature/FeatureSetTest.php b/test/TableGateway/Feature/FeatureSetTest.php index 3e228fd1c5..38c8af52cf 100644 --- a/test/TableGateway/Feature/FeatureSetTest.php +++ b/test/TableGateway/Feature/FeatureSetTest.php @@ -62,13 +62,13 @@ public function testAddFeatureThatFeatureHasTableGatewayButFeatureSetDoesnotHas( $tableGatewayMock = $this->getMockForAbstractClass('Zend\Db\TableGateway\AbstractTableGateway'); $metadataMock = $this->getMock('Zend\Db\Metadata\MetadataInterface'); - $metadataMock->expects($this->any())->method('getColumnNames')->will($this->returnValue(array('id', 'name'))); + $metadataMock->expects($this->any())->method('getColumnNames')->will($this->returnValue(['id', 'name'])); $constraintObject = new ConstraintObject('id_pk', 'table'); - $constraintObject->setColumns(array('id')); + $constraintObject->setColumns(['id']); $constraintObject->setType('PRIMARY KEY'); - $metadataMock->expects($this->any())->method('getConstraints')->will($this->returnValue(array($constraintObject))); + $metadataMock->expects($this->any())->method('getConstraints')->will($this->returnValue([$constraintObject])); //feature have tableGateway, but FeatureSet doesn't has $feature = new MetadataFeature($metadataMock); diff --git a/test/TableGateway/Feature/MasterSlaveFeatureTest.php b/test/TableGateway/Feature/MasterSlaveFeatureTest.php index 28737803cc..20927d5c73 100644 --- a/test/TableGateway/Feature/MasterSlaveFeatureTest.php +++ b/test/TableGateway/Feature/MasterSlaveFeatureTest.php @@ -56,7 +56,7 @@ public function testPostInitialize() /** @var $table \Zend\Db\TableGateway\TableGateway */ $this->getMockForAbstractClass( 'Zend\Db\TableGateway\TableGateway', - array('foo', $this->mockMasterAdapter, $this->feature) + ['foo', $this->mockMasterAdapter, $this->feature] ); // postInitialize is run $this->assertSame($this->mockSlaveAdapter, $this->feature->getSlaveSql()->getAdapter()); @@ -66,7 +66,7 @@ public function testPreSelect() { $table = $this->getMockForAbstractClass( 'Zend\Db\TableGateway\TableGateway', - array('foo', $this->mockMasterAdapter, $this->feature) + ['foo', $this->mockMasterAdapter, $this->feature] ); $this->mockSlaveAdapter->getDriver()->createStatement() @@ -80,7 +80,7 @@ public function testPostSelect() { $table = $this->getMockForAbstractClass( 'Zend\Db\TableGateway\TableGateway', - array('foo', $this->mockMasterAdapter, $this->feature) + ['foo', $this->mockMasterAdapter, $this->feature] ); $this->mockSlaveAdapter->getDriver()->createStatement() ->expects($this->once())->method('execute')->will($this->returnValue( diff --git a/test/TableGateway/Feature/MetadataFeatureTest.php b/test/TableGateway/Feature/MetadataFeatureTest.php index e3f04ecbf8..a55c162f8b 100644 --- a/test/TableGateway/Feature/MetadataFeatureTest.php +++ b/test/TableGateway/Feature/MetadataFeatureTest.php @@ -23,18 +23,18 @@ public function testPostInitialize() $tableGatewayMock = $this->getMockForAbstractClass('Zend\Db\TableGateway\AbstractTableGateway'); $metadataMock = $this->getMock('Zend\Db\Metadata\MetadataInterface'); - $metadataMock->expects($this->any())->method('getColumnNames')->will($this->returnValue(array('id', 'name'))); + $metadataMock->expects($this->any())->method('getColumnNames')->will($this->returnValue(['id', 'name'])); $constraintObject = new ConstraintObject('id_pk', 'table'); - $constraintObject->setColumns(array('id')); + $constraintObject->setColumns(['id']); $constraintObject->setType('PRIMARY KEY'); - $metadataMock->expects($this->any())->method('getConstraints')->will($this->returnValue(array($constraintObject))); + $metadataMock->expects($this->any())->method('getConstraints')->will($this->returnValue([$constraintObject])); $feature = new MetadataFeature($metadataMock); $feature->setTableGateway($tableGatewayMock); $feature->postInitialize(); - $this->assertEquals(array('id', 'name'), $tableGatewayMock->getColumns()); + $this->assertEquals(['id', 'name'], $tableGatewayMock->getColumns()); } } diff --git a/test/TableGateway/Feature/SequenceFeatureTest.php b/test/TableGateway/Feature/SequenceFeatureTest.php index 781f74d3dc..ea1c4d4c24 100644 --- a/test/TableGateway/Feature/SequenceFeatureTest.php +++ b/test/TableGateway/Feature/SequenceFeatureTest.php @@ -36,22 +36,22 @@ public function setup() */ public function testNextSequenceId($platformName, $statementSql) { - $platform = $this->getMockForAbstractClass('Zend\Db\Adapter\Platform\PlatformInterface', array('getName')); + $platform = $this->getMockForAbstractClass('Zend\Db\Adapter\Platform\PlatformInterface', ['getName']); $platform->expects($this->any()) ->method('getName') ->will($this->returnValue($platformName)); $platform->expects($this->any()) ->method('quoteIdentifier') ->will($this->returnValue($this->sequenceName)); - $adapter = $this->getMock('Zend\Db\Adapter\Adapter', array('getPlatform', 'createStatement'), array(), '', false); + $adapter = $this->getMock('Zend\Db\Adapter\Adapter', ['getPlatform', 'createStatement'], [], '', false); $adapter->expects($this->any()) ->method('getPlatform') ->will($this->returnValue($platform)); - $result = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\ResultInterface', array(), '', false, true, true, array('current')); + $result = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\ResultInterface', [], '', false, true, true, ['current']); $result->expects($this->any()) ->method('current') - ->will($this->returnValue(array('nextval' => 2))); - $statement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\StatementInterface', array(), '', false, true, true, array('prepare', 'execute')); + ->will($this->returnValue(['nextval' => 2])); + $statement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\StatementInterface', [], '', false, true, true, ['prepare', 'execute']); $statement->expects($this->any()) ->method('execute') ->will($this->returnValue($result)); @@ -61,14 +61,14 @@ public function testNextSequenceId($platformName, $statementSql) $adapter->expects($this->once()) ->method('createStatement') ->will($this->returnValue($statement)); - $this->tableGateway = $this->getMockForAbstractClass('Zend\Db\TableGateway\TableGateway', array('table', $adapter), '', true); + $this->tableGateway = $this->getMockForAbstractClass('Zend\Db\TableGateway\TableGateway', ['table', $adapter], '', true); $this->feature->setTableGateway($this->tableGateway); $this->feature->nextSequenceId(); } public function nextSequenceIdProvider() { - return array(array('PostgreSQL', 'SELECT NEXTVAL(\'"' . $this->sequenceName . '"\')'), - array('Oracle', 'SELECT ' . $this->sequenceName . '.NEXTVAL as "nextval" FROM dual')); + return [['PostgreSQL', 'SELECT NEXTVAL(\'"' . $this->sequenceName . '"\')'], + ['Oracle', 'SELECT ' . $this->sequenceName . '.NEXTVAL as "nextval" FROM dual']]; } } diff --git a/test/TableGateway/TableGatewayTest.php b/test/TableGateway/TableGatewayTest.php index 935d254dce..25ef9f992d 100644 --- a/test/TableGateway/TableGatewayTest.php +++ b/test/TableGateway/TableGatewayTest.php @@ -35,7 +35,7 @@ public function setup() $mockDriver->expects($this->any())->method('getConnection')->will($this->returnValue($mockConnection)); // setup mock adapter - $this->mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver)); + $this->mockAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, [$mockDriver]); } /** @@ -119,7 +119,7 @@ public function testTableAsTableIdentifierObject() */ public function testTableAsAliasedTableIdentifierObject() { - $aliasedTI = array('foo' => new TableIdentifier('fooTable', 'barSchema')); + $aliasedTI = ['foo' => new TableIdentifier('fooTable', 'barSchema')]; // constructor with only required args $table = new TableGateway( $aliasedTI, @@ -132,10 +132,10 @@ public function testTableAsAliasedTableIdentifierObject() public function aliasedTables() { $identifier = new TableIdentifier('Users'); - return array( - 'simple-alias' => array(array('U' => 'Users'), 'Users'), - 'identifier-alias' => array(array('U' => $identifier), $identifier), - ); + return [ + 'simple-alias' => [['U' => 'Users'], 'Users'], + 'identifier-alias' => [['U' => $identifier], $identifier], + ]; } /** @@ -189,9 +189,9 @@ public function testInsertShouldResetTableToUnaliasedTable($tableValue, $expecte $sql ); - $result = $table->insert(array( + $result = $table->insert([ 'foo' => 'FOO', - )); + ]); $state = $insert->getRawState(); $this->assertInternalType('array', $state['table']);