Skip to content

Commit

Permalink
Merge pull request #2228 from Cameri/3.0
Browse files Browse the repository at this point in the history
3.0 Replaced array() with [] in lib/Cake/Cache/Engine
  • Loading branch information
lorenzo committed Oct 29, 2013
2 parents dc1542f + b8123bd commit 80f2fb6
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 39 deletions.
6 changes: 3 additions & 3 deletions Cake/Cache/Engine/ApcEngine.php
Expand Up @@ -29,7 +29,7 @@ class ApcEngine extends CacheEngine {
*
* @var array
*/
protected $_compiledGroupNames = array();
protected $_compiledGroupNames = [];

/**
* Initialize the Cache Engine
Expand All @@ -39,7 +39,7 @@ class ApcEngine extends CacheEngine {
* @param array $settings array of setting for the engine
* @return boolean True if the engine has been successfully initialized, false if not
*/
public function init($settings = array()) {
public function init($settings = []) {
if (!isset($settings['prefix'])) {
$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
}
Expand Down Expand Up @@ -158,7 +158,7 @@ public function groups() {
ksort($groups);
}

$result = array();
$result = [];
$groups = array_values($groups);
foreach ($this->settings['groups'] as $i => $group) {
$result[] = $group . $groups[$i];
Expand Down
12 changes: 6 additions & 6 deletions Cake/Cache/Engine/FileEngine.php
Expand Up @@ -55,7 +55,7 @@ class FileEngine extends CacheEngine {
* @var array
* @see CacheEngine::__defaults
*/
public $settings = array();
public $settings = [];

/**
* True unless FileEngine::__active(); fails
Expand All @@ -72,15 +72,15 @@ class FileEngine extends CacheEngine {
* @param array $settings array of setting for the engine
* @return boolean True if the engine has been successfully initialized, false if not
*/
public function init($settings = array()) {
$settings += array(
public function init($settings = []) {
$settings += [
'path' => CACHE,
'prefix' => 'cake_',
'lock' => true,
'serialize' => true,
'isWindows' => false,
'mask' => 0664
);
];
parent::init($settings);

if (DS === '\\') {
Expand Down Expand Up @@ -365,7 +365,7 @@ protected function _setKey($key, $createKey = false) {
if (!$exists && !chmod($this->_File->getPathname(), (int)$this->settings['mask'])) {
trigger_error(__d(
'cake_dev', 'Could not apply permission mask "%s" on cache file "%s"',
array($this->_File->getPathname(), $this->settings['mask'])), E_USER_WARNING);
[$this->_File->getPathname(), $this->settings['mask']]), E_USER_WARNING);
}
}
return true;
Expand Down Expand Up @@ -403,7 +403,7 @@ public function key($key) {
return false;
}

$key = Inflector::underscore(str_replace(array(DS, '/', '.', '<', '>', '?', ':', '|', '*', '"'), '_', strval($key)));
$key = Inflector::underscore(str_replace([DS, '/', '.', '<', '>', '?', ':', '|', '*', '"'], '_', strval($key)));
return $key;
}

Expand Down
26 changes: 13 additions & 13 deletions Cake/Cache/Engine/MemcachedEngine.php
Expand Up @@ -53,7 +53,7 @@ class MemcachedEngine extends CacheEngine {
*
* @var array
*/
public $settings = array();
public $settings = [];

/**
* List of available serializer engines
Expand All @@ -62,41 +62,41 @@ class MemcachedEngine extends CacheEngine {
*
* @var array
*/
protected $_serializers = array(
protected $_serializers = [
'igbinary' => Memcached::SERIALIZER_IGBINARY,
'json' => Memcached::SERIALIZER_JSON,
'php' => Memcached::SERIALIZER_PHP
);
];

/**
* Initialize the Cache Engine
*
* Called automatically by the cache frontend
* To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
* To reinitialize the settings call Cache::engine('EngineName', [optional] settings = []);
*
* @param array $settings array of setting for the engine
* @return boolean True if the engine has been successfully initialized, false if not
* @throws Cake\Error\Exception when you try use authentication without Memcached compiled with SASL support
*/
public function init($settings = array()) {
public function init($settings = []) {
if (!class_exists('Memcached')) {
return false;
}
if (!isset($settings['prefix'])) {
$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
}
$settings += array(
'servers' => array('127.0.0.1'),
$settings += [
'servers' => ['127.0.0.1'],
'compress' => false,
'persistent' => false,
'login' => null,
'password' => null,
'serialize' => 'php'
);
];
parent::init($settings);

if (!is_array($this->settings['servers'])) {
$this->settings['servers'] = array($this->settings['servers']);
$this->settings['servers'] = [$this->settings['servers']];
}

if (isset($this->_Memcached)) {
Expand All @@ -110,7 +110,7 @@ public function init($settings = array()) {
return true;
}

$servers = array();
$servers = [];
foreach ($this->settings['servers'] as $server) {
$servers[] = $this->_parseServerString($server);
}
Expand Down Expand Up @@ -171,7 +171,7 @@ protected function _setOptions() {
*/
protected function _parseServerString($server) {
if ($server[0] === 'u') {
return array($server, 0);
return [$server, 0];
}
if (substr($server, 0, 1) === '[') {
$position = strpos($server, ']:');
Expand All @@ -187,7 +187,7 @@ protected function _parseServerString($server) {
$host = substr($server, 0, $position);
$port = substr($server, $position + 1);
}
return array($host, (int)$port);
return [$host, (int)$port];
}

/**
Expand Down Expand Up @@ -300,7 +300,7 @@ public function groups() {
ksort($groups);
}

$result = array();
$result = [];
$groups = array_values($groups);
foreach ($this->settings['groups'] as $i => $group) {
$result[] = $group . $groups[$i];
Expand Down
12 changes: 6 additions & 6 deletions Cake/Cache/Engine/RedisEngine.php
Expand Up @@ -40,29 +40,29 @@ class RedisEngine extends CacheEngine {
*
* @var array
*/
public $settings = array();
public $settings = [];

/**
* Initialize the Cache Engine
*
* Called automatically by the cache frontend
* To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
* To reinitialize the settings call Cache::engine('EngineName', [optional] settings = []);
*
* @param array $settings array of setting for the engine
* @return boolean True if the engine has been successfully initialized, false if not
*/
public function init($settings = array()) {
public function init($settings = []) {
if (!class_exists('Redis')) {
return false;
}
parent::init(array_merge(array(
parent::init(array_merge([
'prefix' => null,
'server' => '127.0.0.1',
'port' => 6379,
'password' => false,
'timeout' => 0,
'persistent' => true
), $settings)
], $settings)
);

return $this->_connect();
Expand Down Expand Up @@ -183,7 +183,7 @@ public function clear($check) {
* @return array
*/
public function groups() {
$result = array();
$result = [];
foreach ($this->settings['groups'] as $group) {
$value = $this->_Redis->get($this->settings['prefix'] . $group);
if (!$value) {
Expand Down
6 changes: 3 additions & 3 deletions Cake/Cache/Engine/WincacheEngine.php
Expand Up @@ -30,7 +30,7 @@ class WincacheEngine extends CacheEngine {
*
* @var array
*/
protected $_compiledGroupNames = array();
protected $_compiledGroupNames = [];

/**
* Initialize the Cache Engine
Expand All @@ -42,7 +42,7 @@ class WincacheEngine extends CacheEngine {
* @return boolean True if the engine has been successfully initialized, false if not
* @see CacheEngine::__defaults
*/
public function init($settings = array()) {
public function init($settings = []) {
if (!isset($settings['prefix'])) {
$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
}
Expand Down Expand Up @@ -165,7 +165,7 @@ public function groups() {
ksort($groups);
}

$result = array();
$result = [];
$groups = array_values($groups);
foreach ($this->settings['groups'] as $i => $group) {
$result[] = $group . $groups[$i];
Expand Down
16 changes: 8 additions & 8 deletions Cake/Cache/Engine/XcacheEngine.php
Expand Up @@ -35,24 +35,24 @@ class XcacheEngine extends CacheEngine {
*
* @var array
*/
public $settings = array();
public $settings = [];

/**
* Initialize the Cache Engine
*
* Called automatically by the cache frontend
* To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
* To reinitialize the settings call Cache::engine('EngineName', [optional] settings = []);
*
* @param array $settings array of setting for the engine
* @return boolean True if the engine has been successfully initialized, false if not
*/
public function init($settings = array()) {
public function init($settings = []) {
if (php_sapi_name() !== 'cli') {
parent::init(array_merge(array(
parent::init(array_merge([
'prefix' => Inflector::slug(APP_DIR) . '_',
'PHP_AUTH_USER' => 'user',
'PHP_AUTH_PW' => 'password'
), $settings)
], $settings)
);
return function_exists('xcache_info');
}
Expand Down Expand Up @@ -149,7 +149,7 @@ public function clear($check) {
* @return array
*/
public function groups() {
$result = array();
$result = [];
foreach ($this->settings['groups'] as $group) {
$value = xcache_get($this->settings['prefix'] . $group);
if (!$value) {
Expand Down Expand Up @@ -182,8 +182,8 @@ public function clearGroup($group) {
* @return void
*/
protected function _auth($reverse = false) {
static $backup = array();
$keys = array('PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'password');
static $backup = [];
$keys = ['PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'password'];
foreach ($keys as $key => $setting) {
if ($reverse) {
if (isset($backup[$key])) {
Expand Down

0 comments on commit 80f2fb6

Please sign in to comment.